Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Now playing script for CMUS
- # Provides artist, album, title, and optionally time / duration
- # Adapted from: http://v3gard.com/2011/01/getting-cmus-to-cooperate-with-conky/
- convertsecs() {
- ((h=${1}/3600))
- ((m=(${1}%3600)/60))
- ((s=${1}%60))
- printf "%02d:%02d\n" $m $s
- }
- if [ ! -x /usr/bin/cmus-remote ]; then
- echo "cmus is not installed."
- exit
- fi
- ARTIST=$( cmus-remote -Q 2>/dev/null | grep artist | cut -d " " -f 3- | sed -n 1p)
- TITLE=$( cmus-remote -Q 2>/dev/null | grep title | cut -d " " -f 3- )
- ALBUM=$( cmus-remote -Q | grep album | cut -d " " -f 3- | sed -n 1p )
- TIME=$( cmus-remote -Q | grep position | cut -d " " -f 2- | sed -n 1p )
- DUR=$( cmus-remote -Q | grep duration | cut -d " " -f 2- )
- if [ -z "$ARTIST" ];then
- echo ""
- else
- echo "| $ARTIST / $ALBUM / $TITLE | $( convertsecs $TIME ) / $( convertsecs $DUR)"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement