This is a short script i use to switch between my VDR-frontend ( softhddevice) and XBMC.
Sure there is a lot of space for improvement.
#!/bin/bash
DEFAULT=run_softhd
LOCKFILE="/var/lock/switchtv.lock"
if [ -f $LOCKFILE ];then
logger "switchtv: running or stale lockfile $LOCKFILE..."
exit 1
fi
lock() {
touch $LOCKFILE
}
unlock() {
rm $LOCKFILE
}
run_frontend() {
$DEFAULT
}
run_softhd() {
svdrpsend.pl PLUG softhddevice ATTA
wmctrl -r softhddevice -b toggle,fullscreen
wmctrl -r softhddevice -e 0,0,0,1920,1080
wmctrl -r softhddevice -b toggle,fullscreen
}
run_xbmc() {
if [ -f /usr/bin/xbmc ];then
su - -c '/usr/bin/xbmc -fs -l /var/run/lirc/lircd $@ &'
fi
}
kill_apps() {
svdrpsend.pl PLUG softhddevice DETA
killall -w xbmc
killall -w xbmc.bin
killall /usr/bin/dbus-daemon
}
lock
if [ "$1" = "xbmc" ];then
kill_apps
/usr/bin/amixer sset Master 100%
/usr/bin/amixer sset PCM 100%
export DISPLAY=":0.0"
run_xbmc
sleep 2
unlock
elif [ "$1" = "vdr" ];then
logger "switchtv: switching to VDR..."
kill_apps
/usr/bin/amixer sset Master 80%
/usr/bin/amixer sset PCM 80%
export DISPLAY=":0.0"
run_frontend
sleep 2
unlock
logger "switchtv: switching to VDR...done"
elif [ "$1" = "kill" ];then
logger "switchtv: killing all frontends..."
kill_apps
sleep 2
unlock
logger "switchtv: killing all frontends...done"
elif [ -z "$1" ];then
kill_apps
export DISPLAY=":0.0"
run_frontend
sleep 2
unlock
fi
exit 0