Volume slider

rawa

New member
Screenshot_21_07_15_1905_16.jpg

With
shell script - input keyevent KEYCODE_VOLUME_UP, (script for non rooted),
i can pop up the "system Volume slider" and "volume increases by 1 step" same as hardware buttons do.
but only when MacroDroid is in foreground.
when MD is minimised or in background, volume slider do not pop up but volume increases by 1 step.
How can i pop up volume slider ? (when MD is not in foreground and launching from shortcut or floating button)

no battery optimisation, no MD killed, accessibility granted, display over other apps allowed, modify system setting allowed, no battery saver, all other macros running fine without single failure.
 

dsnz

Well-known member
what I do

launch app "Volume Slider Trigger"

works always
(all this app does is to bring on the volume slider)
 

rawa

New member
thank you for your advice. i tried it. it opens up with media volume. (i know it can be expanded by clicking arrow.)

but it will be better if it is possible using only MacroDroid for system volume slider. ( in call- call volume, in media - media volume, on home screen - ring volume etc)

it is possible with script which i mentioned in original post if MD is in foreground. but why not if not in foreground. ??

input keyevent KEYCODE_VOLUME_UP

input keyevent KEYCODE_VOLUME_DOWN

(volume changes as desired but no slider popups if MD is not in foreground)
 

dsnz

Well-known member
you can

1. launch shortcut -> Settings -> Volume
but this brings the whole volume menu, not a side slider

2. you can install Ultra Volume app which replaces slider app,
then launch shortcut -> Ultra Volume

3. connectivity -> send intent
with action android.settings.SOUND_SETTINGS
 

rawa

New member
Thank you for your help. I understand, You are really trying to help me.
With no offence, Sorry, I already tried these type of apps.
I am not being rude, but,
I just want to know, is it possible with system volume slider as i mentioned in original post ?
am i doing it wrong? my concern is why slider do not popups if MD is not in foreground with all permissions granted.
because, above written script sends the "system volume key command" to device.
 

dsnz

Well-known member
I know, I wrote this in my post

about keyevent you prefer to use

it returns 'Killed' when macrodroid is in background, which means the command did not really run !

there are 2 alternatives (which I got by some search but I haven't used myself so I can't say they work)

1. grant the USB debugging (Security setting) permission (this is different from the same named thing in Developer Options)

2. use the 'sendevent' command but you must Google search it's command arguments (total 4) and set them appropriately
 

rawa

New member
thank you for your genuine help. but i have some querries. if possible, can you please explain more? so i can find the way.
it returns 'Killed' when macrodroid is in background
what this means? please tell, so i can try to find the way.
command did not really run
BTW command runs, volume changes, only without slider.
1. grant the USB debugging (Security setting) permission
does it mean, to grant the WRITE_SECURE_SETTINGS permission via ADB?
use the 'sendevent' command
what i found on google is - sending "input keyevent" is one of the "sendevent" type of command. i think which is similar to the shell script already used "input keyevent KEYCODE_VOLUME_UP".
if it is not, please correct me. Any helpful reference link??
 

dsnz

Well-known member
1. and 2.

if you try the shell command for input keyevent .. and check the option for the output to go a local variable
you will see that the shell output is 'Killed'
this is a message from the shell and says that while input keyevent .. was running it was killed or crashed (eg. due to some permission missing)
it is indeed possible that the volume was changed but this was just one thing that should be done, the other thing (bring the slider) did not execute because ... 'Killed' 😂

about 3. read this


somebody said that he solved this issue with this strange permission
I haven't found any such permission !
but for completeness I must mention this

about 4.
there is scant documentation on sendevent, it's a low level operation
again I mentioned it for completeness
I doubt that it will fix the problem (it does the same thing that input does)


finally:
for me it's something peculiar to android because it seems that audio volume management by simulating the keys can be done only by an app in the foreground
that's why the app I told you exists 😂 because there is a need by many people (like you and me) to bring the volume slider without keys (this app displays nothing but comes in foreground, it's a trick)

it would be interesting if someone with a rooted phone does this test and post the result
 

420

Active member
1. and 2.

if you try the shell command for input keyevent .. and check the option for the output to go a local variable
you will see that the shell output is 'Killed'
this is a message from the shell and says that while input keyevent .. was running it was killed or crashed (eg. due to some permission missing)
it is indeed possible that the volume was changed but this was just one thing that should be done, the other thing (bring the slider) did not execute because ... 'Killed' 😂

about 3. read this


somebody said that he solved this issue with this strange permission
I haven't found any such permission !
but for completeness I must mention this

about 4.
there is scant documentation on sendevent, it's a low level operation
again I mentioned it for completeness
I doubt that it will fix the problem (it does the same thing that input does)


finally:
for me it's something peculiar to android because it seems that audio volume management by simulating the keys can be done only by an app in the foreground
that's why the app I told you exists 😂 because there is a need by many people (like you and me) to bring the volume slider without keys (this app displays nothing but comes in foreground, it's a trick)

it would be interesting if someone with a rooted phone does this test and post the result
i tested it in rooted NoxPlayer emulator running android 7.1 and it works in there.
 

420

Active member
does it pops up volume slider while MacroDroid is not in foreground? i.e. launching macro with homescreen shortcut.
yep it does, but i am not sure if that is because of the root or because of the android version :ROFLMAO:
 

420

Active member
i realized i can just set it to "non rooted" in the shell script action, and if i do that it no longer works, so yeah root is probably required..
 

dsnz

Well-known member
that's good, it gives an indication that some permission is needed but I think it will be at system level and not app level ,
only someone who knows Android well can say what's happening or macrodroid dev (I last programmed for Android almost 10 years ago, until Android 4 , then I quit and the platform has grown very huge since then and I can't help)

another idea I had is to

- bring macrodroid in foreground
- use input keyevent .. to bring volume slider (this works !)
- use input keyevent KEYCODE_APP_SWITCH
to go back to previous app or HOME (but this does not work !)

so if someone finds a trick to switch apps or at least put macrodroid in background, then this would be a good workaround
 

420

Active member
that's good, it gives an indication that some permission is needed but I think it will be at system level and not app level ,
only someone who knows Android well can say what's happening or macrodroid dev (I last programmed for Android almost 10 years ago, until Android 4 , then I quit and the platform has grown very huge since then and I can't help)

another idea I had is to

- bring macrodroid in foreground
- use input keyevent .. to bring volume slider (this works !)
- use input keyevent KEYCODE_APP_SWITCH
to go back to previous app or HOME (but this does not work !)

so if someone finds a trick to switch apps or at least put macrodroid in background, then this would be a good workaround
i thought we were able to open the macrodroid drawer to bring macrodroid to the foreground?

edit; this seems to work non rooted, if i press the macro shortcut on my home screen and quickly open the drawer, the volume pop-up appears.
 

dsnz

Well-known member
yes it works !

- drawer open
- input keyevent ..
- drawer close

edit:
I didn't notice this was possible before because I run macros from the drawer !
(and drawer open and the whole thing does not work)
but if you run the macro in other way or insert a small delay before drawer open (for macro that runs from drawer)
then all is working fine !

well .. the drawer visibly opens and closes , it's not perfect, but it's acceptable
 
Last edited:

420

Active member
yes it works !

- drawer open
- input keyevent ..
- drawer close

edit:
I didn't notice this was possible before because I run macros from the drawer !
(and drawer open and the whole thing does not work)
but if you run the macro in other way or insert a small delay before drawer open (for macro that runs from drawer)
then all is working fine !

well .. the drawer visibly opens and closes , it's not perfect, but it's acceptable
yeah i also tested non rooted android 10 and also works there, for me it did not work reliably with a shorter wait action in between.

-open drawer
-shell script
-wait 200ms
-close drawer

yeah it does visibly open and close the drawer, maybe an invisible way to bring macrodroid to the foreground can be found, i don't have a clue..

for the running them from the drawer issue, you could just add triggers for drawer opened/closed and have that set a boolean (in the same macro, or just in a seperate one) and check the boolean before opening the drawer to know if it's already open or not, and then run different action accordingly.
 

rawa

New member
yes this works with any MD window is in foreground.
also working with combination of following actions -
display dialog (which i configured to show volume level) & then running script - shows dialog and then volum slider pops up.
just need to press ok after changing volume.
but this pauses youtube but acceptable
 
Top