3 irw > /tmp/remote_command &
7 # BABOOSHKA_HOME=/home/pi # assigned in start.babooshka.sh
9 DBUS_CTRL_FILE=/tmp/dbuscontrol_command
10 SAVEPATH=$BABOOSHKA_HOME
12 # --------------------------------------
14 killCCONTROL() { # function called by trap (Ctrl-C handler)
16 echo CCONTROL_PID $CCONTROL_PID
18 kill -9 $CCONTROL_PID 2> /dev/null
19 echo "Have a nice day..."
25 # --------------------------------------
28 play -n synth sin %41 fade q 0.0 0.1 0.01 gain -25 &>/dev/null </dev/null &
37 data=$(stdbuf -i0 -o0 -e0 tail -1 /tmp/remote_command | awk -F' ' '{print $3; exit}' | xargs )
39 pressCnt=$(($pressCnt + 1))
41 # ---- note repeatable -----
43 if [ "$prevData" != "$data" ]; then
47 $BABOOSHKA_HOME/dbuscontrol.sh stop
58 # ---- repeatable ---------
66 echo "NEXT" > "$DBUS_CTRL_FILE"
67 $BABOOSHKA_HOME/dbuscontrol.sh stop
75 echo "PREV" > "$DBUS_CTRL_FILE"
76 $BABOOSHKA_HOME/dbuscontrol.sh stop
84 echo "NEXT" > "$DBUS_CTRL_FILE"
85 $BABOOSHKA_HOME/dbuscontrol.sh seekfl
93 $BABOOSHKA_HOME/dbuscontrol.sh seekbl
101 status=$(./dbuscontrol.sh status 2>/dev/null)
103 if [ "$status" != "" ]; then
104 position=$( echo "$status" | grep Position | awk '{split($0,a,":"); print a[2]}' )
105 position=$(( $position / (1000000) )) # sec
106 echo $position > $SAVEPATH/currentpos
107 paused=$( echo "$status" | grep Paused | awk '{split($0,a,":"); print a[2]}' | xargs )
110 if [ "$paused" == "true" ] || [ "$status" == "" ]; then # has been paused
112 if [ "$status" == "" ]; then echo "PLAY" > "$DBUS_CTRL_FILE"; fi
116 $BABOOSHKA_HOME/dbuscontrol.sh pause
120 # pause on switching-off
122 "EXT"|"ON_OFF") # AV or ON_OFF
125 status=$(./dbuscontrol.sh status 2>/dev/null)
127 if [ "$status" != "" ]; then
128 position=$( echo "$status" | grep Position | awk '{split($0,a,":"); print a[2]}' )
129 position=$(( $position / (1000000) )) # sec
130 echo $position > $SAVEPATH/currentpos
131 paused=$( echo "$status" | grep Paused | awk '{split($0,a,":"); print a[2]}' | xargs )
134 # paused=$( echo "$status" | grep Paused | awk '{split($0,a,":"); print a[2]}' | xargs )
136 if [ "$paused" == "false" ]; then # not paused
137 $BABOOSHKA_HOME/dbuscontrol.sh pause
138 # echo "$status" > status
149 status=$(./dbuscontrol.sh status 2>/dev/null)
151 if [ "$status" != "" ]; then
152 position=$(echo "$status" | grep Position | awk '{split($0,a,":"); print a[2]}' )
153 position=$(( $position / (1000000) )) # sec
154 echo $position > $SAVEPATH/currentpos
156 echo "STOP" > "$DBUS_CTRL_FILE"
157 $BABOOSHKA_HOME/dbuscontrol.sh stop
160 echo "STOP / NOT PLAYING"
168 audioTracks=$( $BABOOSHKA_HOME/dbuscontrol.sh audiolist 2>/dev/null )
169 trackCnt=$( echo "$audioTracks" | sed '/^\s*$/d' | wc -l )
170 currentTrack=$( echo "$audioTracks" | awk '/active/{ print NR; exit }' )
172 if [ "$trackCnt" != "0" ]; then
173 if [ "$currentTrack" -lt "$trackCnt" ]; then
174 $BABOOSHKA_HOME/dbuscontrol.sh audiop
177 for var in $audioTracks; do
178 $BABOOSHKA_HOME/dbuscontrol.sh audiom
183 echo "AUDIO: $trackCnt, $currentTrack"
189 subsTracks=$( $BABOOSHKA_HOME/dbuscontrol.sh subslist 2>/dev/null )
190 subsCnt=$( echo "$subsTracks" | sed '/^\s*$/d' | wc -l )
191 currentSub=$( echo "$subsTracks" | awk '/active/{ print NR; exit }' )
193 if [ "$subsCnt" != "0" ]; then
194 if [ "$currentSub" -lt "$subsCnt" ]; then
195 $BABOOSHKA_HOME/dbuscontrol.sh subsnext
198 if [ "$subsOff" != "1" ]; then
199 $BABOOSHKA_HOME/dbuscontrol.sh hidesubtitles
203 $BABOOSHKA_HOME/dbuscontrol.sh showsubtitles
204 for var in $subsTracks; do
205 $BABOOSHKA_HOME/dbuscontrol.sh subsprev
212 echo "SUBS: $subsCnt, $currentSub"
220 : > /tmp/remote_command