@@ -9,12 +9,13 @@ TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_HOST_DEFAULT="localhost"
99TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_PORT_DEFAULT=" 6600"
1010TMUX_POWERLINE_SEG_NOW_PLAYING_LASTFM_UPDATE_PERIOD_DEFAULT=" 30"
1111TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_SIMPLE_FORMAT_DEFAULT=" %artist% - %title%"
12+ TMUX_POWERLINE_SEG_NOW_PLAYING_PLAYERCTL_FORMAT_DEFAULT=" {{ artist }} - {{ title }}"
1213TMUX_POWERLINE_SEG_NOW_PLAYING_RHYTHMBOX_FORMAT_DEFAULT=" %aa - %tt"
1314TMUX_POWERLINE_SEG_NOW_PLAYING_NOTE_CHAR_DEFAULT=" ♫"
1415
1516generate_segmentrc () {
1617 read -d ' ' rccontents << EORC
17- # Music player to use. Can be any of {audacious, banshee, cmus, itunes, lastfm, mocp, mpd, mpd_simple, pithos, rdio, rhythmbox, spotify, spotify_wine, file}.
18+ # Music player to use. Can be any of {audacious, banshee, cmus, itunes, lastfm, mocp, mpd, mpd_simple, pithos, playerctl, rdio, rhythmbox, spotify, spotify_wine, file}.
1819export TMUX_POWERLINE_SEG_NOW_PLAYING_MUSIC_PLAYER=""
1920# File to be read in case the song is being read from a file
2021export TMUX_POWERLINE_SEG_NOW_PLAYING_FILE_NAME=""
@@ -31,6 +32,8 @@ export TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_HOST="${TMUX_POWERLINE_SEG_NOW_PLAYING
3132export TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_PORT="${TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_PORT_DEFAULT} "
3233# Song display format for mpd_simple. See mpc(1) for delimiters.
3334export TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_SIMPLE_FORMAT="${TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_SIMPLE_FORMAT_DEFAULT} "
35+ # Song display format for playerctl. see "Format Strings" in playerctl(1).
36+ export TMUX_POWERLINE_SEG_NOW_PLAYING_PLAYERCTL_FORMAT="${TMUX_POWERLINE_SEG_NOW_PLAYING_PLAYERCTL_FORMAT_DEFAULT} "
3437# Song display format for rhythmbox. see "FORMATS" in rhythmbox-client(1).
3538export TMUX_POWERLINE_SEG_NOW_PLAYING_RHYTHMBOX_FORMAT="${TMUX_POWERLINE_SEG_NOW_PLAYING_RHYTHMBOX_FORMAT_DEFAULT} "
3639
@@ -66,6 +69,7 @@ run_segment() {
6669 " mpd_simple" ) np=$( __np_mpd_simple) ;;
6770 " pithos" ) np=$( __np_pithos) ;;
6871 " rdio" ) np=$( __np_rdio) ;;
72+ " playerctl" ) np=$( __np_playerctl) ;;
6973 " rhythmbox" ) np=$( __np_rhythmbox) ;;
7074 " spotify" ) np=$( __np_spotify) ;;
7175 " file" ) np=$( __np_file) ;;
@@ -121,8 +125,11 @@ __process_settings() {
121125 if [ -z " $TMUX_POWERLINE_SEG_NOW_PLAYING_NOTE_CHAR " ]; then
122126 export TMUX_POWERLINE_SEG_NOW_PLAYING_NOTE_CHAR=" ${TMUX_POWERLINE_SEG_NOW_PLAYING_NOTE_CHAR_DEFAULT} "
123127 fi
128+ if [ -z " $TMUX_POWERLINE_SEG_NOW_PLAYING_PLAYERCTL_FORMAT " ]; then
129+ export TMUX_POWERLINE_SEG_NOW_PLAYING_PLAYERCTL_FORMAT=" ${TMUX_POWERLINE_SEG_NOW_PLAYING_PLAYERCTL_FORMAT_DEFAULT} "
130+ fi ;
124131 if [ -z " $TMUX_POWERLINE_SEG_NOW_PLAYING_RHYTHMBOX_FORMAT " ]; then
125- export TMUX_POWERLINE_SEG_NOW_PLAYING_RHYTHMBOX_FORMAT=" ${TMUX_POWERLINE_SEG_NOW_PLAYING_RHYTHMBOX_FORMAT } "
132+ export TMUX_POWERLINE_SEG_NOW_PLAYING_RHYTHMBOX_FORMAT=" ${TMUX_POWERLINE_SEG_NOW_PLAYING_RHYTHMBOX_FORMAT_DEFAULT } "
126133 fi ;
127134}
128135
@@ -268,6 +275,13 @@ __np_rhythmbox() {
268275 fi
269276}
270277
278+ __np_playerctl () {
279+ if [ " $( playerctl status) " = " Playing" ]; then
280+ np=$( playerctl metadata --format=" $TMUX_POWERLINE_SEG_NOW_PLAYING_PLAYERCTL_FORMAT " )
281+ echo " $np "
282+ fi
283+ }
284+
271285__np_spotify () {
272286 if shell_is_linux; then
273287 metadata=$( dbus-send --reply-timeout=42 --print-reply --session --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:' org.mpris.MediaPlayer2.Player' string:' Metadata' 2> /dev/null)
0 commit comments