Skip to content

Commit 557ae9b

Browse files
authored
Merge pull request #479 from xx4h/fix/467/remove-gnu-grep
Remove GNU grep from now_playing.sh
2 parents 7a1cec1 + 2ad9e0b commit 557ae9b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

segments/now_playing.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export TMUX_POWERLINE_SEG_NOW_PLAYING_LASTFM_UPDATE_PERIOD="${TMUX_POWERLINE_SEG
7272
# Fancy char to display before now playing track
7373
export TMUX_POWERLINE_SEG_NOW_PLAYING_NOTE_CHAR="${TMUX_POWERLINE_SEG_NOW_PLAYING_NOTE_CHAR_DEFAULT}"
7474
75-
# Plexamp
75+
# Plexamp
7676
# Set up steps for Plexamp
7777
# 1. Make sure jq(1) is installed on the system.
7878
# 2. Make sure you have an instance of Tautulli that is accessible by the computer running tmux-powerline.
@@ -410,8 +410,8 @@ __np_spotify() {
410410
if [ -n "$metadata" ]; then
411411
state=$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus' | grep -E -A 1 "string" | cut -b 26- | cut -d '"' -f 1 | grep -E -v ^$)
412412
if [[ $state == "Playing" ]]; then
413-
artist=$(echo "$metadata" | grep -PA2 "string\s\"xesam:artist\"" | tail -1 | grep -Po "(?<=\").*(?=\")")
414-
track=$(echo "$metadata" | grep -PA1 "string\s\"xesam:title\"" | tail -1 | grep -Po "(?<=\").*(?=\")")
413+
artist=$(echo "$metadata" | awk '/string\s+"xesam:artist"/{m=1;next};m && /string/{sub(/^.*string\s+/,"");print substr($0,2,length($0)-2);m=0}')
414+
track=$(echo "$metadata" | awk '/string\s+"xesam:title"/{m=1;next};m && /string/{sub(/^.*string\s+/,"");print substr($0,2,length($0)-2);m=0}')
415415
np="${artist} - ${track}"
416416
fi
417417
fi
@@ -421,4 +421,4 @@ __np_spotify() {
421421
np=$("${TMUX_POWERLINE_DIR_SEGMENTS}/np_spotify_mac.script")
422422
fi
423423
echo "$np"
424-
}
424+
}

0 commit comments

Comments
 (0)