forked from tsibley/soundbridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stream
executable file
·107 lines (99 loc) · 2.66 KB
/
stream
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
#!/bin/bash
dst=$1
shift
shopt -qs extglob
case "$dst" in
preset|from|power|whois|playing)
# These take arguments other than pulseaudio input sinks
;;
?([+-])+([0-9]))
vol="$dst"
dst="vol"
;;
vol)
vol=$1
;;
*)
src=$1
src_default=spotify
# Find the source asked for, or our default if none was asked for. Set
# src to how we found the input, if we found it.
inputidx=$(find-sink-input "${src:-$src_default}")
[[ -n $inputidx ]] && src=${src:-$src_default}
# If nothing was asked for and we couldn't find the default either, see
# if there are *any* inputs available. Set our src to distinguish it's
# fallback status in messages.
if [[ -z $inputidx && -z $src ]]; then
inputidx=$(find-sink-input)
src="whatever's playing"
fi
# Still found nothing!
if [[ -z $inputidx ]]; then
echo "Unable to find sink input index for $src"
exit 1
fi
shift
;;
esac
function move_to_sink() {
# takes only a sink
echo "Streaming $src ($inputidx) to $dst ($1)"
pactl move-sink-input $inputidx $1
}
case "$dst" in
home|soundbridge|sb)
sink='streaming'
pacmd set-sink-mute $sink 0 >/dev/null
pacmd set-source-mute $sink.monitor 0 >/dev/null
soundbridge-upnp-play $sink
move_to_sink $sink
;;
bps|work|office)
sink='raop.Conference-Room.local'
gconftool -s --type bool /system/pulseaudio/modules/raop-discover/enabled true
sleep 5
pacmd set-sink-mute $sink 0 >/dev/null
move_to_sink $sink
;;
preset)
play-preset "$@"
exit
;;
vol)
soundbridge-volume "$vol"
exit
;;
whois|playing)
soundbridge-whois
exit
;;
alsa|local|hw|off|stop)
move_to_sink 0
gconftool -s --type bool /system/pulseaudio/modules/raop-discover/enabled false
;;
power)
case $1 in
off|stop)
soundbridge-rcp "SetPowerState standby"
;;
reboot)
soundbridge-rcp "Reboot"
;;
*)
soundbridge-rcp "IrDispatchCommand CK_POWER"
;;
esac
;;
from)
if [[ $1 == "home" ]]; then
echo "Proxying to bloop; connect to localhost:3689"
banshee >/dev/null 2>&1 &
ssh -NL 3689:localhost:3689 bloop.zulutango.org
exit
fi
;&
*)
echo "Uh, what?"
exit 1
;;
esac