toggleBT.sh
1 | #!/bin/bash |
---|---|
2 | # |
3 | # Toggle Bluetooth Audio Output |
4 | |
5 | . /home/mythtv/.mythtv/mysql.txt |
6 | |
7 | CURRENT=`mysql -B -N -u ${DBUserName} -p${DBPassword} -h ${DBHostName} -D ${DBName} -e "select data from settings WHERE value = 'AudioOutputDevice' and hostname = '${LocalHostName}';"` |
8 | SPEAKERS="ALSA:default" |
9 | BTHEADSET="ALSA:btheadset" |
10 | |
11 | if [ ${CURRENT} == ${SPEAKERS} ] ; then |
12 | /usr/bin/mysql -B -N -u ${DBUserName} -p${DBPassword} -h ${DBHostName} \ |
13 | -D ${DBName} -e "UPDATE settings SET data = '${BTHEADSET}' WHERE \ |
14 | value = 'AudioOutputDevice' and hostname = '${LocalHostName}'"; |
15 | else |
16 | /usr/bin/mysql -B -N -u ${DBUserName} -p${DBPassword} -h ${DBHostName} \ |
17 | -D ${DBName} -e "UPDATE settings SET data = '${SPEAKERS}' WHERE \ |
18 | value = 'AudioOutputDevice' and hostname = '${LocalHostName}'"; |
19 | fi |
20 | |
21 | # Force a reload of the frontend theme which will re-read the db settings. |
22 | /bin/kill -USR1 $(pidof mythfrontend) & |