#!/bin/bash
#
# cmus-status-display
#
# Usage:
#   in cmus command ":set status_display_program=cmus-status-display"
#
# This scripts is executed by cmus when status changes:
#   cmus-status-display key1 val1 key2 val2 ...
#
# All keys contain only chars a-z. Values are UTF-8 strings.
#
# Keys: status file url artist album discnumber tracknumber title date
#   - status (stopped, playing, paused) is always given
#   - file or url is given only if track is 'loaded' in cmus
#   - other keys/values are given only if they are available
#  

output()
{
	# write status to /tmp/cmus-status (not very useful though)
	echo "$*" >> /tmp/cmus-status 2>&1

	# WMI (http://wmi.modprobe.de/)
	#wmiremote -t "$*" &> /dev/null
}

while [[ $# -ge 2 ]]
do
  eval _$1=\"$2\"
  shift
  shift
done

if [[ -n $_file ]]
then
	output "[$_status] $_artist - $_album - $_title ($_date)"
elif [[ -n $_url ]]
then
	output "[$_status] $_url - $_title"
else
	output "[$_status]"
fi
