Skip to content

Instantly share code, notes, and snippets.

@jackinloadup
Created January 3, 2017 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackinloadup/f13288ee298fae7af7157451a7460d56 to your computer and use it in GitHub Desktop.
Save jackinloadup/f13288ee298fae7af7157451a7460d56 to your computer and use it in GitHub Desktop.
mopidy for i3blocks
#!/bin/bash
#
# Author: Raphael P. Ribeiro <raphaelpr01@gmail.com>
MPCSTAT=`mpc | grep -v '^volume:'`
if [ -z "${MPCSTAT}" ]; then # if not playing, exit
echo "$line" || exit 1
else
if [ $1 == '1' ]; then # if arg = 1, show music symbols
MPCSTAT2=`echo "${MPCSTAT}" | sed 's, *, ,g; 1h;1d;2G' | head -n1 | cut -d ']' -f 1 | tr -d [`
PLAY=""
PAUSE=""
[ "$MPCSTAT2" = "playing" ] && echo $PLAY || echo $PAUSE
else # else, show what's playing
PLAYING=`echo "${MPCSTAT}" | sed 's, *, ,g; 1h;1d;2G' | paste -d' ' -s - | cut -d ')' -f2`
TIME=`echo "${MPCSTAT}" | sed 's, *, ,g; 1h;1d;2G' | paste -d' ' -s - | head -n1 | cut -d ' ' -f3`
echo "$PLAYING ($TIME)"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment