summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <55825613+luevano@users.noreply.github.com>2020-12-24 17:53:08 -0700
committerDavid Luevano Alvarado <55825613+luevano@users.noreply.github.com>2020-12-24 17:53:08 -0700
commitc97e7025e6cf7595ee04ff6177505f3c43e0a846 (patch)
tree70cefe1d2a2182299e5420dc4b0da433ce7aabf4 /.local
parent61a81bbd67e7e109cd1370dcb4c24d81f3baab14 (diff)
Create new player module
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/statusbar/player_mpris_module35
1 files changed, 35 insertions, 0 deletions
diff --git a/.local/bin/statusbar/player_mpris_module b/.local/bin/statusbar/player_mpris_module
new file mode 100755
index 0000000..42d6df6
--- /dev/null
+++ b/.local/bin/statusbar/player_mpris_module
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+show_panel (){
+ # Needs to send to /dev/null for the actual else case.
+ player_status=$(playerctl status 2> /dev/null)
+
+ if [ "$player_status" = "Playing" ]; then
+ echo " $(playerctl metadata artist) - $(playerctl metadata title)"
+ elif [ "$player_status" = "Paused" ]; then
+ echo "%{F$(xresource color8)} $(playerctl metadata artist) - $(playerctl metadata title)%{F-}"
+ else
+ echo "%{F$(xresource color8)} (nothing playing)"
+ fi
+}
+
+send_notification (){
+ artist="$(playerctl metadata artist)"
+ album="$(playerctl metadata album)"
+ title="$(playerctl metadata title)"
+
+ if [ $album = "\n"]; then
+ notify-send "$artist - $album" "$title"
+ else
+ notify-send "$artist" "$title"
+ fi
+}
+
+case $1 in
+ show)
+ show_panel
+ ;;
+ notify)
+ send_notification
+ ;;
+esac