Created
October 29, 2013 00:06
-
-
Save marsam/7207045 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # | |
| # MPRIS: http://xmms2.org/wiki/MPRIS | |
| # Clementine: http://code.google.com/p/clementine-player/wiki/MPRIS | |
| # Amarok: http://amarok.kde.org/wiki/Development/Scripting_HowTo_2.0 | |
| # | |
| song_name_clementine() { | |
| qdbus org.mpris.clementine /Player org.freedesktop.MediaPlayer.GetMetadata | awk ' | |
| BEGIN {FS=":"} | |
| function strip(string){ | |
| gsub(/^ /, "", string); | |
| gsub(/ $/, "", string); | |
| return string; | |
| } | |
| $1 ~ /title/ { | |
| title = strip($2); | |
| } | |
| $1 ~ /artist/ { | |
| artist = strip($2); | |
| } | |
| END { printf("#[fg=colour137,bg=colour234]#[bg=colour137,fg=colour16] ♫ %s — %s #[fg=colour254,bg=colour137,nobold] ", title, artist) } | |
| ' | |
| } | |
| if [[ $(pgrep clementine >/dev/null 2>&1) -eq 0 ]]; then | |
| status=$(qdbus --literal org.mpris.clementine /Player org.freedesktop.MediaPlayer.GetStatus 2>/dev/null | awk '{print $3}') | |
| if [ "$status" == "0," ]; then # is playing | |
| song_name_clementine | |
| else | |
| echo ' #[fg=colour254,bg=colour234]' | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment