Search code examples
linuxbashxbmc

Detecting if XBMC is playing, from shellscript?


I have an XBMC setup that I absolutely love at home. Now, I've been doing a bunch of automation to make everything run smoothly and without manual maintenance (Like updating my library automatically on new arrivals etc.), however one thing I'm missing:

I want to write a shellscript, which takes care of suspending the machine at night, and waking it at a predefined time the next day. There's two things to it:

1) It should start up automatically at predefined intervals. I have this covered through RTC + wakealarm in Ubuntu.

2) It should, at a specific time at night, check if XBMC is currently playing anything (In case I'm up at night). If XBMC is NOT playing, it should suspend the machine. I'm unaware if this is possible ?


Solution

  • I actually found the answer to this one myself, after digging quite a lot into the new JSON RPC webservice in newer XBMC's.

    The webservice now allows you to poll to see if any players are currently active (When playing a video for instance). I'm going to use those in the aforementioned script to check if I'm currently watching anything, before shutting the mediacenter down for the night :)

    It's described on http://wiki.xbmc.org/index.php?title=JSON_RPC#JSONRPC.GetAnnouncementFlags