-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventcmd.sh
executable file
·113 lines (85 loc) · 2.67 KB
/
eventcmd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
######################################################
# Begin Character LCD Display - eventcmd
# by V. Loschiavo - 12FEB2017
# Based on: https://github.com/AyMac/Pandoras-Box
######################################################
# User Defined variables
OUTFILE=${EPHEMERAL}/pandoraout
PARSEANDWRITE2LCD="${SCRIPTSBASEDIR}/ParseAndWrite.py"
# Put data from piano bar into variables
while read L; do
k="`echo "$L" | cut -d '=' -f 1`"
v="`echo "$L" | cut -d '=' -f 2`"
export "$k=$v"
done < <(grep -e '^\(title\|artist\|album\|stationName\|songStationName\|pRet\|pRetStr\|wRet\|wRetStr\|songDuration\|songPlayed\|rating\|coverArt\|stationCount\|station[0-9]*\)=' /dev/stdin) # don't overwrite $1...
case "$1" in
songstart)
# Put title, artist, and station name into a file so we can display on the LCD
echo -e "$title\n$artist\n$stationName" > $OUTFILE
$PARSEANDWRITE2LCD
esac
######################################################
# Patiobar eventcmd script below this point
# see: https://github.com/kylejohnson/Patiobar
######################################################
# User defined variables #
host="http://127.0.0.1"
port=3000
baseurl="${host}:${port}"
# Here be dragons! #
# (Don't change anything below) #
######################################################
#stationList="${HOME}/.config/pianobar/stationList"
#currentSong="${HOME}/.config/pianobar/currentSong"
stationList="${EPHEMERAL}/stationList"
currentSong="${EPHEMERAL}/currentSong"
while read L; do
k="`echo "$L" | cut -d '=' -f 1`"
v="`echo "$L" | cut -d '=' -f 2`"
export "$k=$v"
done < <(grep -e '^\(title\|artist\|album\|stationName\|songStationName\|pRet\|pRetStr\|wRet\|wRetStr\|songDuration\|songPlayed\|rating\|coverArt\|stationCount\|station[0-9]*\)=' /dev/stdin) # don't overwrite $1...
post () {
url=${baseurl}${1}
curl -s -XPOST $url >/dev/null 2>&1
}
clean () {
query=$1
clean=$(echo $query | sed 's/ /%20/g')
post $clean
}
stationList () {
if [ -f "$stationList" ]; then
rm "$stationList"
fi
end=`expr $stationCount - 1`
for i in $(eval echo "{0..$end}"); do
sn=station${i}
eval sn=\$$sn
echo "${i}:${sn}" >> "$stationList"
done
}
case "$1" in
songstart)
query="/start/?title=${title}&artist=${artist}&coverArt=${coverArt}&album=${album}&rating=${rating}"
clean "$query"
echo -n "${artist},${title},${album},${coverArt},${rating}" > "$currentSong"
stationList
;;
# songfinish)
# ;;
songlove)
query="/lovehate/?rating=${rating}"
clean $query
;;
# songshelf)
# ;;
songban)
query="/lovehate/?rating=${rating}"
clean $query
;;
# songbookmark)
# ;;
# artistbookmark)
# ;;
esac