Advertisement
mosaid

get clementine data

Dec 21st, 2017
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.06 KB | None | 0 0
  1. #!/bin/bash
  2. if [[ `pgrep clementine` ]] ; then
  3.     data=$(qdbus org.mpris.clementine /Player org.freedesktop.MediaPlayer.GetMetadata )
  4.     artist=$( echo "$data" | grep  ^artist: | sed  -e 's/artist://' | sed -e 's/^ //' )
  5.     title=$( echo "$data" | grep  ^title: | sed  -e 's/title://' | sed -e 's/^ //' )
  6.     art=$(echo "$data" | grep ^arturl: | sed  -e 's/arturl://' | sed -e 's/^ //' | sed -e 's|file://||' )
  7.     mtime=$(echo "$data" | grep ^mtime: | sed  -e 's/mtime://' | sed -e 's/^ //' )
  8.     mtime=$(( mtime/1000 ))
  9.     etime=$( qdbus org.mpris.clementine /Player org.freedesktop.MediaPlayer.PositionGet )
  10.     etime=$(( etime/1000 ))
  11. fi
  12. case "$1" in
  13.     "a" )
  14.         echo $artist
  15.     ;;
  16.     "t" )
  17.         echo $title        
  18.     ;;
  19.     "e" )
  20.         if (( $(( etime%60)) > 9 ))
  21.             then  echo "$(( etime/60 )):$(( etime%60))"
  22.             else  echo "$(( etime/60 )):0$(( etime%60))"
  23.         fi
  24.     ;;
  25.     "m" )
  26.         if (( $(( mtime%60)) > 9 ))
  27.             then  echo "$(( mtime/60 )):$(( mtime%60))"
  28.             else  echo "$(( mtime/60 )):0$(( mtime%60))"
  29.         fi
  30.     ;;
  31.     "c" )
  32.         echo $art
  33.     ;;
  34.     "b" )
  35.         echo $(( etime*100/mtime ))
  36.     ;;
  37. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement