So basically I want to run a few line of code each time a specific application is launched and closed.

Is there application which could do that ? (Busybox ?)

I actually have to print it my self in a terminal emulator and it's a bit harsh :/


Using Terminal Emulator and Macrodroid, an automation app

Create a macro in which the Trigger is launch application of your choice and action is Launch Shortcut where you choose Term Shortcut and key in the commands in the arguments . See Firelord's answer here for additional details Home screen icon for terminal program?

  • Great answer but it seems not to work withsu (application block when I want to add other lines, any advice ?)
    – Baldráni
    Sep 29 '16 at 10:19
  • Thanks. It works for me as shown here. Though i used a single command. Can you please recheck your syntax and try with su-c
    – beeshyams
    Sep 29 '16 at 10:36
  • Another thing you can try is split your commands into easier to troubleshoot sections and add each of this section as an action (you can hand multiple actions for a trigger). If you want you can separate these actions by wait X sec. Note that if you are using && to join command unless the first command is executed the next will not run. Breaking into sections and multiple actions can help troubleshoot
    – beeshyams
    Sep 29 '16 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.