ftp -o - https://jcs.org/move_in | sh -
1#!/bin/sh
2
3CMUS="cmus"
4PIANOBAR="pianobar"
5AUDACIOUS="audacious"
6
7PLAYER=""
8if [ ! X`pgrep cmus` = X"" ]; then
9 PLAYER=$CMUS
10elif [ ! X`pgrep pianobar` = X"" ]; then
11 PLAYER=$PIANOBAR
12elif [ ! X`pgrep audacious` = X"" ]; then
13 PLAYER=$AUDACIOUS
14else
15 echo "no music player"
16 exit 1
17fi
18
19case "$1" in
20next)
21 case $PLAYER in
22 $CMUS)
23 ;;
24 $PIANOBAR)
25 echo -n 'n' > ~/.config/pianobar/ctl
26 ;;
27 $AUDACIOUS)
28 audtool playlist-advance
29 ;;
30 esac
31 ;;
32nextalbum)
33 case $PLAYER in
34 $CMUS)
35 ;;
36 $PIANOBAR)
37 echo -n 'n' > ~/.config/pianobar/ctl
38 ;;
39 $AUDACIOUS)
40 audtool playlist-advance-album
41 ;;
42 esac
43 ;;
44prev)
45 case $PLAYER in
46 $CMUS)
47 ;;
48 $PIANOBAR)
49 # not possible
50 ;;
51 $AUDACIOUS)
52 audtool playlist-reverse
53 ;;
54 esac
55 ;;
56prevalbum)
57 case $PLAYER in
58 $CMUS)
59 ;;
60 $PIANOBAR)
61 ;;
62 $AUDACIOUS)
63 audtool playlist-reverse-album
64 ;;
65 esac
66 ;;
67pause)
68 case $PLAYER in
69 $CMUS)
70 cmus-remote -u
71 ;;
72 $PIANOBAR)
73 echo -n 'S' > ~/.config/pianobar/ctl
74 ;;
75 $AUDACIOUS)
76 # "audtool playback-pause" should just pause, but it stupidly inverts
77 # playing status so we need to check if it's both playing and not
78 # paused
79 if [ `audtool playback-status` == "playing" ]; then
80 audtool playback-pause
81 fi
82 ;;
83 esac
84 ;;
85playpause)
86 case $PLAYER in
87 $CMUS)
88 cmus-remote -u
89 ;;
90 $PIANOBAR)
91 echo -n 'p' > ~/.config/pianobar/ctl
92 ;;
93 $AUDACIOUS)
94 audtool playback-playpause
95 ;;
96 esac
97 ;;
98*)
99 echo "unknown command \"${1}\""
100 exit 1
101 ;;
102esac