Recently Written · git

dsad

Dmenu interface for Simple Audio Daemon

git clone https://github.com/equwal/dsad

Log | Files | Refs


dsad (1137 bytes)

1 #!/bin/sh
2 # dmenu script for sad
3 # - requires BSD-style netcat with -N (it is in gentoo and arch packagers, at least)
4 # - requires sadcmd
5 PROMPT="sad? "
6 
7 # hint: order the following however you want.
8 
9 CUSTOMCMDS="sadmenu
10 sad-start
11 sad-toggle-play"
12 
13 ZEROCMDS="next
14 prev
15 stop
16 kill
17 random
18 repeat
19 clear
20 playlist
21 close
22 ping
23 uptime
24 version"
25 
26 ARGCMDS="sad-add file/dir
27 sad-add-playlist playlist.ply
28 add path
29 volume 0-100
30 pause [0|1]
31 play [ID]
32 remove [ID]
33 enable output
34 disable output"
35 
36 # Echo, fixed so only the first argument can be flags.
37 cmd=$(printf "%s\\n%s\\n%s"  "$CUSTOMCMDS" "$ZEROCMDS" "$ARGCMDS" \
38       | dmenu -i -l "$(printf "%s\\n%s\\n%s"  "$CUSTOMCMDS" "$ZEROCMDS" "$ARGCMDS" | wc -l -)" -p "$PROMPT" \
39       | cut -f1 -d ' ')
40 
41 [ -n "$(printf "%s" "$CUSTOMCMDS" | grep "$cmd")" ] \
42     && eval "$cmd"  && exit 0
43 [ -n "$(printf "%s" "$ZEROCMDS"   | grep "$cmd")" ] \
44     && sad-cmd "$cmd" && exit 0
45 [ -n "$(printf "%s" "$ARGCMDS"    | grep "$cmd")" ] \
46     && sad-cmd "$cmd"  \
47               "$(printf "" | dmenu -i -l 0 -p "arg $(printf "%s" "$ARGCMDS" | grep "$cmd" | cut -d ' ' -f 2)? ")" \
48     && exit 0
49 
50 # not an arg
51 exit 1