• 1(current)
  • 2
  • 3
  • 4
  • 5
  • 23
[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)
#1
Hi,

I have created a simple service addon to execute user scripts on specific XBMC actions, right now the actions supported are:
  • XBMC starts
  • Player starts / stops
  • Player pauses / resumes
  • Screensaver starts / stops
  • Database updates

I did a quick search and could not find anything similar. Also, this is my first attempt to write an addon so things might just not work. I use it to notify another computer when I am using XBMC so it stops its network activity (I am using a raspberry pi as server and it really cannot cope with a lot of things).

Add-on name: service.xbmc.callbacks
Current version: v0.5
Download: service.xbmc.callbacks-v0.5.zip
Compatibility: checked only in Frodo

Notes:
  • It is only tested on linux but it shoud also work on windows.
  • I am planning to add an XBMC stop event but right now I don't seem to find a reliable way to do it.

As said, it is quite simple but maybe it can help others...
Reply
#2
Thumbs Up 
Thanks for this, just the stuff I did need to solve my issues, had to reg a account to show my gratitude.

I use it to set the minfrequency higher on the CPU, avoiding lag in the interface and 1080p while the screensaver is off and dimming the lights in the room while playing a movie, only thing I miss is the ability to do stuff on pause/unpause - would be good to turn some light on to find the way to the loo Wink


thnx again
g
Reply
#3
Glad another soul is using it Smile

I just created a new version adding callbacks for pause / resume a movie. Let me know if they work.

Here is the link to the file (also on first post):

https://github.com/pilluli/service.xbmc....e/v0.2.zip

Regards,
Reply
#4
I just stumbled on this, and I think it's a great idea.

What kind of scripts does it run? bash? python?
Reply
#5
(2013-03-01, 17:20)sebj Wrote: What kind of scripts does it run? bash? python?

Hi,

It runs whatever script you can run in your computer (so can be in any language). Basically you point to a file (the script) you want to be executed when an action in XBMC occurs.

Hope it clarifies it! Regards,
Reply
#6
Just installed v0.2, and it's working purrfect on pause/resume - now I won't break any toes running for the loo Wink

Have to say that it makes integration of xbmc with the home automation stuff I do easy and slick, can't be happier! ;D

As my xbmc computer also is acting as an server for various less cpu needy stuff and is on 24/7 - the screensaver callback does make it possible to run it on lowest possible cpu speed and spin down drives when not needed as an HTPC (drawing less power = less heat = less noise) while cranking it up when in action to make it snappy.
Before finding your addon I had to run the computer on "cranked up" settings permanently or set it manually (usually forgetting to turn it down), now it just works automagic and the silence is golden.

Big thanks again
g
Reply
#7
Hey, I'm really interested in your service addon for my openelec main system.

I've calibrated the display and wish to apply the icc profile on xbmc startup not the system startup like I do now (In case xbmc crashes or whatever)

I'm getting an error though here it is :

Quote:10:13:51 T:2919230272 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.OSError'>
Error Contents: [Errno 8] Exec format error
Traceback (most recent call last):
File "/storage/.xbmc/addons/service.xbmc.callbacks-0.2/default.py", line 186, in <module>
Main()
File "/storage/.xbmc/addons/service.xbmc.callbacks-0.2/default.py", line 53, in __init__
subprocess.Popen([script_xbmc_starts])
File "./Lib/subprocess.py", line 679, in __init__
File "./Lib/subprocess.py", line 1249, in _execute_child
OSError: [Errno 8] Exec format error
-->End of Python script error report<--

Any ideas?

disclosure : using openelec 2.99.5 with the 32bit generic package
Reply
#8
Hi,

Could you please let me know which script you want to execute when XBMC starts? I think there is something wrong in that script and the addon can not locate it properly...

Regards,


(2013-03-16, 16:09)sebj Wrote: Hey, I'm really interested in your service addon for my openelec main system.

I've calibrated the display and wish to apply the icc profile on xbmc startup not the system startup like I do now (In case xbmc crashes or whatever)

I'm getting an error though here it is :

Quote:10:13:51 T:2919230272 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.OSError'>
Error Contents: [Errno 8] Exec format error
Traceback (most recent call last):
File "/storage/.xbmc/addons/service.xbmc.callbacks-0.2/default.py", line 186, in <module>
Main()
File "/storage/.xbmc/addons/service.xbmc.callbacks-0.2/default.py", line 53, in __init__
subprocess.Popen([script_xbmc_starts])
File "./Lib/subprocess.py", line 679, in __init__
File "./Lib/subprocess.py", line 1249, in _execute_child
OSError: [Errno 8] Exec format error
-->End of Python script error report<--

Any ideas?

disclosure : using openelec 2.99.5 with the 32bit generic package
Reply
#9
filename : icc.sh

permissions : -rwxrwxrwx

(
sleep 10
/storage/downloads/xcalib -d :0 -s 0 /storage/downloads/pioneer.icc
)&
Reply
#10
sebj, I understand your script runs OK when executed from command line right?

If so ... the only problem I see is that somehow the addon does not find the script location. Are you using the full path to locate the script in the addon settings?




(2013-03-20, 01:03)sebj Wrote: filename : icc.sh

permissions : -rwxrwxrwx

(
sleep 10
/storage/downloads/xcalib -d :0 -s 0 /storage/downloads/pioneer.icc
)&
Reply
#11
I can launch the script via the commandline and it's in an obvious path location...

I don't understand....

bummer... Confused
Reply
#12
Wink 
Ok, jumped to conclusions here. I have it working.

It needed #!/bin/bash at the beginning.

Code:
#!/bin/bash

DIR=/storage/.config/calib
$DIR/xcalib -d :0 -s 0 $DIR/pioneer.icc

This script automatically applies an icc profile when starting xbmc.

Loving it, thank you so much for this addon pilluliBig Grin
Reply
#13
Can I run this infinite loop script in you add-on?

It tail the kern.log and do a library update when a HDD gets mounted so I must run all the time because I plug/unplug my HDD a lot of times

/home/pi/sync.sh
Code:
#!/bin/bash
clear
echo "Tailing kern.log: searching for new HDD"
tail -fn0 /tmp/kern.log | while read line ; do
        echo "$line" | grep "kernel: sda: sda1"
        if [ $? = 0 ]
        then
                # Actions
                sleep 3
                curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "mybash"}' -H 'content-type: application/json;' http://localhost/jsonrpc
        fi
done
Reply
#14
Thanks! Its working!
Reply
#15
Would it be possible to catch the "Put display to sleep when idle" from Power Saving?

I am currently powering down my projector when the screen saver is activated, but i would like to be able to use Dim for screen saver and only poweroff the projector when idle.
Reply
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 23

Logout Mark Read Team Forum Stats Members Help
[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)4