Forum

Full Version: Starting XBMC on hdmi access
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is it possible to get the status from the hdmi port from the commandline, so whether it is accessed by the tv or not?

tvservice -s shows no difference in whether it's accessed or not.

Edit: see http://forum.xbian.org/thread-803-post-9461.html#pid9461 for linux script
is your TV recognized ?
Code:
/opt/vc/bin/tvservice -n
Yes it returns:

Code:
device_name=SAM-SAMSUNG
OK so it is working fine.
tbh Im not sure what you want to achieve
I want to start XBMC when the tv is turned to the hdmi channel and stop XBMC again when the channel is changed back again. So I thougt of building a script that periodically calls this tvservice -s and then starts or stops XBMC.

I also tried doing this by running cec-client -m and running a script whenever the hdmi acces command comes along.
But now suddenly when I run 'cec-client -m' in commandline it gives a segmentation fault after a while (I didn't make any changes to libcec or the cec-client).
Code:
xbian@xbian ~ $ cec-client -m
starting a monitor-only client. use 'mon 0' to switch to normal mode
No device type given. Using 'recording device'
CEC Parser created - libCEC version 2.1.1
no serial port given. trying autodetect:
path:     Raspberry Pi
com port: RPI

opening a connection to the CEC adapter...
DEBUG:   [             230]     unregistering all CEC clients
DEBUG:   [             235]     Broadcast (F): osd name set to 'Broadcast'
DEBUG:   [             244]     InitHostCEC - vchiq_initialise succeeded
DEBUG:   [             247]     InitHostCEC - vchi_initialise succeeded
DEBUG:   [             251]     InitHostCEC - vchi_connect succeeded
DEBUG:   [             256]     logical address changed to Broadcast (f)
DEBUG:   [             266]     RegisterLogicalAddress - registering address e
DEBUG:   [             449]     logical address changed to Free use (e)
DEBUG:   [             449]     logical address changed to Free use (e)
DEBUG:   [             449]     Open - vc_cec initialised
NOTICE:  [             449]     connection opened
DEBUG:   [             450]     processor thread started
waiting for input
Segmentation fault

Is there a way to reinstall libcec without screwing things up for XBMC?
Okay I have build this script now as a work around. This script runs forever and should start XBMC on hdmi access and shut it down when the channel is changed away from the hdmi again. The code is below and this code doesn't start or stop anything yet but just prints stuff for debugging.

I would like to get some advice on this, maybe you know a better solution.

Code:
#!/bin/bash
while true

do

cec_client=`cec-client -m | egrep -m 1 '0f:86:30:00|0f:80:00:00:30:00|0f:80:30:00:00:00'`

echo "${cec_client}"

if (( `echo $cec_client | grep -c "0f:86:30:00|0f:80:00:00:30:00"` > 0 ));then
    echo "turning on and waiting"
    sleep 60
    echo "waiting over, restarting"
elif (( `echo $cec_client | grep -c "0f:80:30:00:00:00"` > 0 ));then
    echo "turning off and waiting"
    sleep 60
    echo "waiting over, restarting"
else
    echo "error, restarting" #this is true when there is a segmentation fault
fi

done

I would also like to extend it with option to wait an x amount of time before shutting down, if hdmi is accessed within that time cancel shutdown. But for this I should be able to do actions while cec-client is still running, I don't know how to do that.
Is this still "under development" ? It could be really nice script, because xbmc uses a lot of resources in background, and i could use those f.e. for rtorrent.
Reference URL's