auto shutdown feature questions?
#1
Big Grin 
Hey All,

I was wondering if there was away to have the auto shutdown call an external power script.

right now, I have the star and hash buttons linked to a script that powers on the tv, rcvr, sets the inputs and minimum volume on the rcvr.

I was hoping to automate this some more by having the auto shutdown feature call the suspend script and the power button call the resume script.

On the bedroom machine I have this done with pm.suspend modified to that machine and with a suspend and resume script. It is a little more involved as I have to stop and restart lirc as well as lcdD for the Antec fusion, but the off or on scripts power on or off the lg tv as well as the bell express-vu rcvr and sets the tv to the proper input. if I had this programmed into my pronto instead of my mce remote, i would automate it further by having options on the pronto for -pwr on XBMC Movies - Pwr on mythtv - pwr on bell express vu. but all of the above still involve the use shutting the machine down manually from the call to suspend script.

Any Ideas.

Thanks,

Dave
Reply
#2
I did some more research on this. I would like to know if I am heading in the right direction. Can I call a script with remote.xml for the power function or would I need to actually modify XBMC.shutdown.

What script/file does xbmc call in linux to execute suspend mode or auto-shutdown.

on my myth machine in the bedroom my script runs from the mythfrontend exit window which call my suspend script and then runs pm-suspend.

I have made a few scripts for resume that run from /etc/pm/sleep.d, one fore myth, lirc and LCDd. all so they will resume in the right order.

I could tidy this all up in one script for suspend and one for resume, xbmc.shutdown could call my suspend script and the power button would call the pwr on script.

Regards,

Dave
Reply
#3
XBMC handles it for you, we call the OS directly on suspend/hibernate/shutdown/restart, this is so it's simple and easy, and fits perfectly for the the vast majority of users.

So your options are limited I'm afraid, you can create a python script that does all you want it to do and at the end calls XBMC.Shutdown() (builtin method), after this you'd have to switch the XBMC.Shutdown() in the skin to start your script instead.

This won't work for the autoshutdown feature since it will call XBMC.Shutdown directly, in this case there is nothing to do, it has been suggested to exec a script on shutdown and I suggest you poke that ticket to spur some interest, if it doesn't exist feel free to create one (although I'm pretty sure it does exist)

Cheers,
Tobias
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#4
Thanks Tobias,

I will have a gander at the tickets. Would that feature allow to call any script or a python only script on the system.

I know this is done in Linuxmce from the get go after a certain time of no activity it will send off commands to all the devices that are on but that is a whole other ball of wax what with power-sensing and rs-232 and so on and no need to get that fancy, Just an external suspend - resume script would be ideal.

Thanks,

Dave
Reply
#5
It would be a python script (XBMC python) but could in turn for sure start a system script with System.Exec.

I just remembered another solution, wich would IMHO be even better for you and works right off the bat. Make a pm-utils script, should be plenty info on the web about how to make one, and I have made one in ticket #7486

Cheers,
Tobias
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#6
topfs2 Wrote:It would be a python script (XBMC python) but could in turn for sure start a system script with System.Exec.

I just remembered another solution, wich would IMHO be even better for you and works right off the bat. Make a pm-utils script, should be plenty info on the web about how to make one, and I have made one in ticket #7486

Cheers,
Tobias


Tobias,

I have several sleep.d scripts already created for myth that launch things in a specific order. I.E. 00mythtv, 07Lirc and 08LCDd. These only get called on resume, correct! I assume that is what you meant by your post of needing a pm-utils script. My suspend script is currently called on that machine from the myth shutdown menu window and that script calls power_toggle.sh and then pm-suspend and all goes to sleep.

I have myth9.10 and kernel 31.16 with Camelot 9.11 SVN from branches, I left it suspended for 8 or so hours yesterday via the remote after resume everything was up except rss feeds. I reloaded xbmc and the rss feeds returned.

Will the pm-utils script called on resume only, I am trying to get it to call on suspend. resume is working so I just have to modify my resume scripts currently as they work of the pwr button as is.

It's been a while since I setup the machine with all these scripts, I have to look tonight and get them all in order and find out for sure which one is doing what and in what order.

Regards,

Dave
Reply
#7
The sleep.d scripts can do stuff on suspend, resume, hibernate and thaw.

Cheers,
Tobias
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#8
Big Grin 
Tobias,

What the H-E-double hockey sticks, Touch Wood, that has to be about the easiest thing I have ever had to do in Linux since I started. Big Grin

Now to be fair I already had all my devices in a lircd file that I recorded ages ago and I already had scripts for power_off and power_on.

Anyhow here is what I did.

This is a new install of myth 9.10 and xbmc Camelot 9.11 SVN on an AsRock ION330 with an MCE remote and Dongle. I think even if I had purchased the HT model I would still use the MCE remote and USB dongle, I struggled down that path getting the Antec Fusion working in the bedroom with the built-in Ir with an mce remote supplying code and then an MCE usb dongle transmitting to the TV and Bell receiver - never again.

anyhow

cd /etc/pm/sleep.d
sudo vim 00pwr

Code:
#!/bin/bash

. /usr/lib/pm-utils/functions

case "$1" in
  suspend|hibernate)
    # pwr off tv and amp
    sudo sh '/home/user/install/scripts/power_off.sh'
    ;;

  resume|thaw)
    # pwr on tv and amp
    sudo sh '/home/user/install/scripts/power_on.sh'
    ;;
    *)
    ;;

esac


save and exit vim

sudo chmod +x 00pwr

sudo su
visudo - username is the user you log in with.
<username> ALL=(ALL) NOPASSWD: /usr/sbin/pm-suspend
ctl-x - save file - Y - write to /etc/sudoers - enter
type exit to leave root.

tail -f /var/log/pm-suspend.log

open a new putty session
sudo pm-suspend - WORKS instantly - success

works with power button suspend and resume
works with custom shutdown timer
works with auto-shutdown and it is almost instant up and down.

I avoided trying this with my old machine, for lack of wanting to edit xml files, Wow am I glad you chimed in on this post, I would have never thought of calling this from a pm-utils script.

Thank You - Thank You - Thank You.

Regards,

Dave
Reply
#9
Hehe, glad you got it working and good you posted the script.

Cheers,
Tobias
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply

Logout Mark Read Team Forum Stats Members Help
auto shutdown feature questions?0