summaryrefslogtreecommitdiff
path: root/mystatus.sh
blob: 54de6d0963db51646ba07025354a5976b9eb0cba (plain)
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
#!/bin/sh

mpd_status() {
	mpc=$(mpc)
	lines=$(echo "$mpc" | wc -l)
	if [ "$lines" -eq 3 ]; then
		s=$(echo "$mpc" | head -n 1 | \
			sed -e 's/\\/\\\\\\\\/g' -e s/\\\"/\\\\\\\"/g \
			-e 's/ - Digitally Imported Premium//' \
			-e 's/ - RADIOTUNES.COM Premium//' \
			-e 's/ - ROCKRADIO.COM Premium//' \
			-e 's/ - JAZZRADIO.com Premium//' \
			-e 's/ - ClassicalRadio.com Premium//' \
			-e 's/ - Leading Trance Radio//' \
			-e 's/:.* \[SomaFM\]//' \
			)
		p=$( (echo "$mpc" | grep '\[playing\]' >/dev/null) \
			|| echo " (p)")
		echo "{\"name\":\"mpd\",\"color\":\"#99aabb\",\"full_text\":\"$s$p\"},"
	fi
}

mic_mute_status() {
	if $(pacmd list-sources|grep -A 15 '* index'|grep -q 'muted: yes'); then
		echo '{"name":"mic-mute","color":"#bb5533","full_text":"MIC MUTED"},'
	fi
}

n_line=0
i3status -c ~/.i3/i3status.conf | while :
do
	read line
	if [ $n_line -lt 4 ]; then
		n_line=$(( n_line + 1 ))
	fi
	if [ $n_line -eq 1 ]; then
		echo "$line"
		continue
	elif [ $n_line -eq 2 ]; then
		echo "$line"
		continue
	elif [ $n_line -eq 3 ]; then
		coma=""
	else
		coma=","
	fi
	echo "$coma[$(mpd_status)$(mic_mute_status)$(echo "$line" | sed 's/^\,*\[//')" || exit 1
done