Forum
Starting XBMC on hdmi access - Printable Version

+- Forum (http://forum.xbian.org)
+-- Forum: Software (/forum-6.html)
+--- Forum: Others (/forum-24.html)
+--- Thread: Starting XBMC on hdmi access (/thread-803.html)



Starting XBMC on hdmi access - Fred - 17th Apr, 2013 07:18 PM

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


RE: Get HDMI status from commandline. - rikardo1979 - 18th Apr, 2013 07:58 AM

is your TV recognized ?
Code:
/opt/vc/bin/tvservice -n



RE: Get HDMI status from commandline. - Fred - 18th Apr, 2013 08:02 PM

Yes it returns:

Code:
device_name=SAM-SAMSUNG



Re: Get HDMI status from commandline. - rikardo1979 - 18th Apr, 2013 08:17 PM

OK so it is working fine.
tbh Im not sure what you want to achieve


RE: Get HDMI status from commandline. - Fred - 18th Apr, 2013 10:31 PM

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).


RE: Get HDMI status from commandline. - Fred - 19th Apr, 2013 02:58 AM

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?


RE: Get HDMI status from commandline. - Fred - 19th Apr, 2013 07:36 PM

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.


RE: Starting XBMC on hdmi access - koper89 - 27th Jan, 2014 04:35 AM

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.


RE: Starting XBMC on hdmi access - mk01 - 27th Jan, 2014 09:36 PM

@koper89

http://forum.xbian.org/thread-2040-post-20131.html#pid20131