dotfiles

*nix config files
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

cmus-status-display (1462B)


      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/wmt.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" && test -n "$_title" && [[ "$_status" == "playing" ]] ; then
     36 	if [[ $(cmus-remote -Q | grep "set play_library" | awk '{print $NF}') == "false" ]] ; then
     37 		_underscore=$(echo $_title | sed 's/\ /_/g')
     38 		_playlist=$(grep -i -e "$_title\|$_underscore" ~/.cmus/playlists/* | awk -F: '{print $1}' | awk -F/ '{print $NF}' | head -n1)
     39 		test -n "$_playlist" && output "custom $_playlist playlist"
     40 	elif [[ $(cmus-remote -Q | grep "set play_library" | awk '{print $NF}') == "true" ]] ; then
     41 		output "$_album by $_artist"
     42 	fi
     43 	#output "[$_status] $_artist - $_album - $_title ($_date) $duration"
     44 elif test -n "$_url" && [[ "$_status" == "playing" ]] ; then
     45 	output "$_url"
     46 fi