dsad (1143 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="sad-menu 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 printf "%s" "$CUSTOMCMDS" | grep -qxF -- "$cmd" \ 42 && "$cmd" && exit 0 43 printf "%s" "$ZEROCMDS" | grep -qxF -- "$cmd" \ 44 && sad-cmd "$cmd" && exit 0 45 hint=$(printf "%s\n" "$ARGCMDS" | awk -v c="$cmd" '$1 == c {print $2}') 46 case $cmd in sad-*) run=$cmd ;; *) run="sad-cmd $cmd" ;; esac 47 [ -n "$hint" ] \ 48 && $run "$(printf "" | dmenu -i -l 0 -p "arg $hint? ")" \ 49 && exit 0 50 51 # not an arg 52 exit 1