summaryrefslogtreecommitdiff
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
parent61a81bbd67e7e109cd1370dcb4c24d81f3baab14 (diff)
Create new player module
-rw-r--r--.config/polybar/config2
-rw-r--r--.config/polybar/main.ini2
-rw-r--r--.config/polybar/pulseaudio.ini4
-rwxr-xr-x.local/bin/statusbar/player_mpris_module35
4 files changed, 39 insertions, 4 deletions
diff --git a/.config/polybar/config b/.config/polybar/config
index 2c33cad..334bd3c 100644
--- a/.config/polybar/config
+++ b/.config/polybar/config
@@ -32,7 +32,7 @@ include-file = $XDG_CONFIG_HOME/polybar/filesystem.ini
include-file = $XDG_CONFIG_HOME/polybar/eth.ini
include-file = $XDG_CONFIG_HOME/polybar/wlan.ini
include-file = $XDG_CONFIG_HOME/polybar/dunst.ini
-
+include-file = $XDG_CONFIG_HOME/polybar/player_mpris.ini
# Other modules that came by default on the example config.
# The ones that I configured are on separate ini files.
diff --git a/.config/polybar/main.ini b/.config/polybar/main.ini
index 0fbabb8..d66ffb8 100644
--- a/.config/polybar/main.ini
+++ b/.config/polybar/main.ini
@@ -4,7 +4,7 @@ monitor = ${env:MAINMON:HDMI-0}
modules-left=bspwm xwindow
modules-center=
-modules-right=xkeyboard cpu memory pulseaudio date dunst powermenu
+modules-right=player_mpris xkeyboard cpu memory pulseaudio date dunst powermenu
# tray-position = right
# tray-padding = 2
diff --git a/.config/polybar/pulseaudio.ini b/.config/polybar/pulseaudio.ini
index 3dfc7b4..016ac57 100644
--- a/.config/polybar/pulseaudio.ini
+++ b/.config/polybar/pulseaudio.ini
@@ -25,7 +25,7 @@ format-volume-underline = ${colors.green}
# <ramp-volume>
# <bar-volume>
format-muted = <label-muted>
-format-muted-underline = ${colors.white}
+format-muted-underline = ${colors.black-alt}
# Available tokens:
# %percentage% (default)
@@ -36,7 +36,7 @@ label-volume = %percentage%%
# %percentage% (default)
# %decibels%
label-muted =  (muted)
-label-muted-foreground = ${colors.white}
+label-muted-foreground = ${colors.black-alt}
# Only applies if <ramp-volume> is used
ramp-volume-0 = 
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