-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedia_control
executable file
·67 lines (60 loc) · 1.33 KB
/
media_control
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
#!/bin/sh
# Media controls for cmus, if running, or mpv (through xdotool).
mpv_binds() {
mpv_window="$(xdotool search --class mpv)"
if [ -z "$mpv_window" ] ; then
exit 0
fi
case "$prompt" in
toggle)
xdotool key --window "$mpv_window" p
;;
next)
xdotool key --window "$mpv_window" greater
;;
prev)
xdotool key --window "$mpv_window" less
;;
posseek)
xdotool key --window "$mpv_window" Right
;;
negseek)
xdotool key --window "$mpv_window" Left
;;
mod1)
xdotool key --window "$mpv_window" bracketright
;;
mod2)
xdotool key --window "$mpv_window" bracketleft
esac
}
cmus_binds() {
case "$prompt" in
toggle)
cmus-remote --pause
;;
next)
cmus-remote --next
;;
prev)
cmus-remote --prev
;;
posseek)
cmus-remote --seek +5
;;
negseek)
cmus-remote --seek -5
;;
mod1)
cmus-remote --shuffle
;;
mod2)
cmus-remote --repeat
esac
}
prompt="$1"
if [ -z $(pgrep cmus) ] ; then
mpv_binds
else
cmus_binds
fi