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 (https://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"; then
   36     output "$_artist - $_title"
   37 elif test -n "$_url"; then
   38     output "$_title"
   39 else
   40     output "[$_status]"
   41 fi
   42 
   43