#!/bin/sh
# Copyright (C) 2018 Minbari
# music on console player display script; needs pidof installed on your system
  
  maxlen=${BLOCK_INSTANCE:-99}
  full_text="MOC: !"
  short_text="$full_text"

if [ ! -z $(pidof mocp | cut -d " " -f2 ) ]; then
   full_text="$(mocp -i -Q "%state%artist - %song" | tail -n 1 | sed -e 's/PLAY/   /' -e 's/PAUSE/   /' -e 's/STOP/   /')"
   #short_text="$full_text"
   short_text="${full_text:-0:$maxlen}"
   color="#ff1a8c"
   else
      exit 33
fi
   echo "$short_text"
   echo "$full_text"
   echo "$color"
case $BLOCK_BUTTON in
   1) mocp -r ;; # left click = previous song
   2) mocp -G ;; # middle click = toggle pause - play
   3) mocp -f ;; # right click = next song
esac
exit 0
