Shutdown doesn't work after restarting XBMC
#1
Hello,

i'm using XBMC pvr-testing (henningpingel) on Lucid with an ordinary 24" Display (1920x1080 DVI), a Projector (1024x768 VGA) and a built-in 7" touchscreen (1280x1024 VGA, connected to VGA-out of the Projector).

My Issue is, that if RTC starts the PC to record from TV, I want the Display to be turned off.

My idea was to store a file in /tmp and delete that file, if it exists, within any action on my remote which can be done easily using irexec (idle indicator).

Additionally i create an at-job in rc.local which switches the Screen Resolution to a Mode where the DVI is disabled after 10 Minutes from startup if the file still exists.

To make this work with my Nvidia card i stored some metamodes in my xorg.conf's screen section:
Code:
Option         "metamodes" "CRT: 1280x1024 +0+0, DFP: NULL; CRT: NULL, DFP: 1920x1080 +0+0; CRT: 1024x768 +0+0, DFP: NULL"

With metamodes like this, it's possible to use xrandr to cycle through the available resolutions
Code:
xrandr -s $METAMODE_INDEX

I created a script that reads the available metamodes, quits xbmc via xbmc-send -a "Quit()", chooses the next available metamode and switches to it, restarts xbmc to make it fit into the new resolution and finally displays the new resolution using osd_cat.

The script is called using irexec with su -c /path/to/./script hannemann
Code:
#!/bin/bash

##
#
# Option         "metamodes" "CRT: 1280x1024 +0+0, DFP: NULL; CRT: NULL, DFP: 1920x1080 +0+0; CRT: 800x600 +0+0, DFP: NULL"
#
##

export DISPLAY=:0.0
NUM_MODES=0
OLDIFS=$IFS
IFS=$'\n'
for MODE in $(DISPLAY=:0.0 xrandr | egrep '[0-9]{3,4}x[0-9]{3,4} {2,}'); do
        if [ $(echo $MODE | grep -c '*') -gt 0 ]; then
                CURRENT=$NUM_MODES
        fi
        MODE=$(echo $MODE | cut -d" " -f4)
        MODES[$NUM_MODES]=$MODE
        let NUM_MODES=$NUM_MODES+1
done
IFS=$OLDIFS

let NEXT=$CURRENT+1
if [ $NEXT -ge $NUM_MODES ]; then
        NEXT=0;
fi

#echo 'NUM_MODES: '$NUM_MODES
#echo $NEXT
#echo 'NEXT_MODE: '${MODES[$NEXT]}

if [ X$(pidof -s xbmc.bin) != X ]; then
        xbmc-send -a "Quit()" &
        while [ X$(pidof -s xbmc.bin) != X ]; do
                sleep 1
        done;
fi
xrandr -s $NEXT &
sleep 2
/usr/bin/xbmc &

sleep 2
FONT="-adobe-helvetica-bold-*-*-*-30-*-*-*-*-*-*-*"
POS="bottom"
COLOR="cyan"
killall -s 9 osd_cat
echo ${MODES[$NEXT]} | osd_cat -c $COLOR -A right -f $FONT -d 10 &

exit 0

This does not work 100% stable yet as it's not ready for now.
If i use this script, it works like expected but XBMC is not able to shutdown anymore. The PC falls back to Gnome.
If i don't use the script, i can shutdown the computer, using xbmc's shutdownMenu.

I imagine it's a problem with the su command, as i think a subshell is created with user hannemann that is not properly logged off after executing the script.

My Question is, is there a possibility to turn off Displays within XBMC 'onidle' or ist it possible to use xbmc-send to switch to a specified Metamode (the modes are available through XBMC System -> Settings? Menu) or is it possible to enable XBMC to shutdown the computer after xbmc has been restarted?

Please excuse my English ;-) and thank you for you're great work on XBMC
Reply

Logout Mark Read Team Forum Stats Members Help
Shutdown doesn't work after restarting XBMC0