[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)

  Thread Rating:
  • 3 Vote(s) - 4.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
wolfn48 Offline
Junior Member
Posts: 2
Joined: Mar 2015
Reputation: 0
Post: #196
Hello KenV99,
I'm running Openelec/Kodi on a Intel-NUC with USB-HDDs and think about mirroring/backup my music-data to my NAS.
Your addon seems to me the best tool available for this, but I'm new to Kodi and an absolute python-noob...

So I need some 'kickoff'.
My 1st idea is:
1. If Kodi starts - send a WOL to the NAS (afaik is a function in Kodi)
2. when ready start rsync (client on Kodi, is already installed, server runs on the NAS)
- this should be packed into an shell-script.

Do you think I can get this 'wrapped' into your addon?
And, if yes, will this (as long as its running) prevent Kodi from shutting down if no other action takes place?
( I adjusted Kodi to shutdown after the max. possible 120 min.)

I'm not sure how to mix shell, python and this WOL-call.
If you can point me to some further reading...
find quote
KenV99 Offline
Senior Member
Posts: 276
Joined: Nov 2013
Reputation: 8
Post: #197
(Yesterday 14:26)wolfn48 Wrote:  Hello KenV99,
I'm running Openelec/Kodi on a Intel-NUC with USB-HDDs and think about mirroring/backup my music-data to my NAS.
Your addon seems to me the best tool available for this, but I'm new to Kodi and an absolute python-noob...

So I need some 'kickoff'.
My 1st idea is:
1. If Kodi starts - send a WOL to the NAS (afaik is a function in Kodi)

This is done directly in Kodi, not through this addon: Wake_on_lan (wiki)

(Yesterday 14:26)wolfn48 Wrote:  2. when ready start rsync (client on Kodi, is already installed, server runs on the NAS)
- this should be packed into an shell-script.

I don't know much about rsync. Unless you can set a long timeout, you will need to find a way to poll to see when the NAS is online in your shell script before you start the sync process.

(Yesterday 14:26)wolfn48 Wrote:  Do you think I can get this 'wrapped' into your addon?
And, if yes, will this (as long as its running) prevent Kodi from shutting down if no other action takes place?
( I adjusted Kodi to shutdown after the max. possible 120 min.)

I'm not sure how to mix shell, python and this WOL-call.
If you can point me to some further reading...

I doesn't need to be 'wrapped' as best as I can tell. Kodi will do the WOL. You will need to write the shell script and link it to the 'on Startup Event' as a shell executable.

There is no way to abort a Kodi shutdown - scripts are terminated automatically if they do not abort themselves in 5 seconds after shutdown starts. However, since the script executes in a subprocess call, it will likely run until it finishes, but it may cause issues when you retry to restart Kodi because the process may not terminate gracefully. I know this happens in windows, I'm not sure if it happens in Linux.
(This post was last modified: Today 01:05 by KenV99.)
find quote
wolfn48 Offline
Junior Member
Posts: 2
Joined: Mar 2015
Reputation: 0
Post: #198
Thank you very much KenV99,

just played around with your addon + found I can call 1x python OR 1x shell OR 1x call to Kodi.
So I will try to write a little python-script to 1st call Kodi for WOL to my NAS, then do some pings for waiting til ready and then start the rsync.
Found in the Kodi-wiki some links for get me going in python, will give it a try...

Thanks again, will report success or problems...
find quote
Post Reply