Jump to content


Photo

Execute custom script on Wakeup/Standby


  • Please log in to reply
3 replies to this topic

#1 philsmd

  • Member
  • 20 posts

0
Neutral

Posted 30 December 2012 - 22:54

Hi,
I need to execute a custom script on my STB (be it either a binary executable or a shell script) that will be executed whenever I press the power button on the remote control.
More accurate it would be that it executes on system start and before both standby and deepstandby (possibly including also reboots etc).

I'm not sure how to do that. Do I have to install any utils (like pm-utils etc)?
I am missing something? I looked arround a little bit but neither a forum post here nor google did tell me what I need to do to accomplish this task. Maybe I'm searching in the wrong direction.

What I need is to e.g. symbol-link my custom script that will be executed by the start/stop trigger(s)/runlevels ....
Please help

What is the best solution? Is there a catch-all solution (for all cases above)?

Thanks

Edited by philsmd, 30 December 2012 - 22:54.


Re: Execute custom script on Wakeup/Standby #2 Dimitrij

  • PLi® Core member
  • 10,382 posts

+354
Excellent

Posted 31 December 2012 - 07:27

http://dream.altmast...81&postcount=11

GigaBlue UHD Quad 4K /Lunix3-4K/Duo 4K


Re: Execute custom script on Wakeup/Standby #3 hemertje

  • Forum Moderator
    PLi® Core member
  • 33,506 posts

+118
Excellent

Posted 31 December 2012 - 08:53

http://dream.altmaster.net/showpost.php?p=81881&postcount=11


Hi dima

Please post The english version here...

on the Glassfibre 1GB DVB-C...


Re: Execute custom script on Wakeup/Standby #4 philsmd

  • Member
  • 20 posts

0
Neutral

Posted 31 December 2012 - 10:30

Thanks @dima73,

the solution works for now, Great.
Although, the setup that I now have is very hackerish.
For those that want to do a similar thing.
You have to get the source py file of Standby.py (/usr/lib/enigma2/python/Screens/Standby.py, see openpli git to get the SOURCE), add to the Power() and __init__ methods the os.system("/home/root/bin/myscript.sh") call (don't forget to import os and you should check with os.path.exists() if the target script exists.

This two methods are invoked whenever there is a standby event. Therefore no catch-all solution (only non-deep standby and wakeup from non-deep standby).
Therefore I had to create a /etc/init.d/xxx script and add it via:
update-rc.d xxx start 20 2 3 4 5 . stop 20 0 1 6 . #(or whatever runlevels you want, see: /etc/inittab)
This shell script, whose basic structure is:
#!/bin/sh
# Run custom script (shutdown/halt,reboot,start)
#
start() {
/home/root/bin/myscript.sh # parameters
}
stop() {
/home/root/bin/myscript.sh #parameters
}
usage() {
echo "USAGE HERE"
}
case “$1″ in
start)
start
;;
stop)
stop
;;
*)
usage
esac
exit 0

Why I think it is hackerish:
- Standby.py could be overridden by system update (Ouch!)
- 2+ points of failure (runlevel script, Standby.py, myscript.sh)
- maybe runlevel timing problem w/ disc mounts etc (I must test this)
- possible many others

But 4 now it works great. Thx. Hope I also did the translation part for @dima73 (there isn't written much more on the link above), anyway just use translate.google.com if you insist getting the details of the thread linked above

Best

Edited by philsmd, 31 December 2012 - 10:31.



2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users