Shell Script Not Running if MacroDroid Isn’t in the Foreground

Trevor

New member
I set up a shell script on a timer on a Kindle Fire tablet and it will only actually run if MacroDroid is in the foreground. Every other kind of action I have tried works when MacroDroid is in the background.
 

Jacob L

Moderator (Lawsonator)
You could either follow steps at dontkillmyapp.com and or use the dim screen action before the shell script action and turn dim off when script finishes.
 

Trevor

New member
You could either follow steps at dontkillmyapp.com and or use the dim screen action before the shell script action and turn dim off when script finishes.
I tried disabling every battery saving option and using the dim screen and it didn't work. I also tried everything on a Pixel 3 with stock Android 12 and the behavior was the same.

I saved output to string variable and it says nothing when MacroDroid stays in the foreground, but says "Killed" as soon as MacroDroid is in the background. Just opening the notification shade causes this to happen. I'm using the shell command "input Keyevent 85" btw.

If I use the helper app, the same thing happens except the helper app needs to stay in the foreground now. I'm doing it as non-rooted.
 

dsnz

Well-known member
maybe keyevent is honored only in foreground (it's very logical)

change shell script to "date" and save output in a string variable (with block next actions unti complete option),
check the contents of the variable after some time (so that the macro must have run, cross-check with the system log),
and tell us what happens
 

Trevor

New member
I tried "date" and it is updating the variable while MacroDroid is in the background. I don't know where to see the system log, but that seems unnecessary at this point.

I guess this means I can't do what I need to do. MacroDroid already has a way to simulate the Play/Pause button etc. and it works in the background, but I need the rewind or fast forward buttons and MacroDroid excluded those as options. My only remaining choice was to try the shell.

Edit: Problem solved. I discovered that there is a:
Code:
media dispatch KEY
command that lets you pick:
Code:
play, pause, play-pause, mute, headsethook, stop, next, previous, rewind, record, fast-forward.
and these work when MacroDroid is in the background.
 
Last edited:
Top