Debian Codegraph @

cmus-status-display

raw symbols SCIP
1 #!/bin/sh
2 #
3 # cmus-status-display
4 #
5 # Usage:
6 # in cmus command ":set status_display_program=cmus-status-display"
7 #
8 # This scripts is executed by cmus when status changes:
9 # cmus-status-display key1 val1 key2 val2 ...
10 #
11 # All keys contain only chars a-z. Values are UTF-8 strings.
12 #
13 # Keys: status file url artist album discnumber tracknumber title date
14 # - status (stopped, playing, paused) is always given
15 # - file or url is given only if track is 'loaded' in cmus
16 # - other keys/values are given only if they are available
17 #
18
19 output()
20 {
21 # write status to ~/cmus-status.txt (not very useful though)
22 echo "$*" >> ~/cmus-status.txt 2>&1
23
24 # WMI (http://wmi.modprobe.de/)
25 #wmiremote -t "$*" &> /dev/null
26 }
27
28 while test $# -ge 2
29 do
30 eval _$1='$2'
31 shift
32 shift
33 done
34
35 if test -n "$_file"
36 then
37 h=$(($_duration / 3600))
38 m=$(($_duration % 3600))
39
40 duration=""
41 test $h -gt 0 && dur="$h:"
42 duration="$dur$(printf '%02d:%02d' $(($m / 60)) $(($m % 60)))"
43
44 output "[$_status] $_artist - $_album - $_title ($_date) $duration"
45 elif test -n "$_url"
46 then
47 output "[$_status] $_url - $_title"
48 else
49 output "[$_status]"
50 fi