song: Use regex for matching.

This commit is contained in:
Dylan Araps 2018-05-25 15:13:10 +10:00
parent 160276ff6d
commit 01ef60445e

View file

@ -2317,40 +2317,42 @@ get_memory() {
} }
get_song() { get_song() {
player="$(ps -e | grep -m 1 -F \ players=(
-e "Google Play" \ "amarok"
-e "Spotify" \ "audacious"
-e "amarok" \ "banshee"
-e "audacious" \ "bluemindo"
-e "banshee" \ "clementine"
-e "bluemindo" \ "cmus"
-e "clementine" \ "deadbeef"
-e "cmus" \ "deepin-music"
-e "deadbeef" \ "elise"
-e "deepin-music" \ "exaile"
-e "elisa" \ "gnome-music"
-e "exaile" \ "Google Play"
-e "gnome-music" \ "guayadeque"
-e "guayadeque" \ "iTunes"
-e "iTunes" \ "juk"
-e "juk" \ "lollypop"
-e "lollypop" \ "mocp"
-e "mocp" \ "mopidy"
-e "mopidy" \ "mpd"
-e "mpd" \ "pogo"
-e "pogo" \ "pragha"
-e "pragha" \ "qmmp"
-e "qmmp" \ "quodlibet"
-e "quodlibet" \ "rhythmbox"
-e "rhythmbox" \ "sayonara"
-e "spotify" \ "spotify"
-e "tomahawk" \ "Spotify"
-e "xmms2d" \ "tomahawk"
-e "yarock" \ "vlc"
-e "sayonara" \ "xmms2d"
-e "vlc")" "yarock"
player="${player/* }" )
player="${player##*/}"
printf -v players "|%s" "${players[@]}"
player="$(ps -e | awk -v pattern="(${players:1})$" '$0 ~ pattern {print $NF; exit}')"
[[ "$music_player" && "$music_player" != "auto" ]] && \ [[ "$music_player" && "$music_player" != "auto" ]] && \
player="$music_player" player="$music_player"