Polybar: switched to pulseaudio module; bluetooth and temperature modules are loaded only when the respective devices are available

master
Meliurwen 2 years ago
parent 2affd69042
commit c275ec857d
Signed by: meliurwen
GPG Key ID: 818A8B35E9F1CE10
  1. 11
      polybar/.config/polybar/config
  2. 17
      polybar/.config/polybar/launch.sh
  3. 2
      polybar/.config/polybar/scripts/mpv.sh

@ -52,7 +52,7 @@ font-3 = "Material Wifi Signal Enhanced:style=Regular:weight=bold:size=10"
#modules-left = i3 clementine mpv #modules-left = i3 clementine mpv
modules-left = i3 mpv modules-left = i3 mpv
modules-center = date modules-center = date
modules-right = temperature bluetooth wireless-network wired-network alsa battery modules-right = ${env:POLY_MODR}
separator = " " separator = " "
spacing = 0 spacing = 0
@ -114,18 +114,17 @@ ramp-capacity-2 =
ramp-capacity-3 = ramp-capacity-3 =
ramp-capacity-4 = ramp-capacity-4 =
[module/alsa] [module/pulseaudio]
type = internal/alsa type = internal/pulseaudio
use-ui-max = false
interval = 5 interval = 5
format-volume = <ramp-volume> format-volume = <ramp-volume>
format-muted = <label-muted> format-muted = <label-muted>
label-muted = label-muted =
label-muted-foreground = ${color.grey} label-muted-foreground = ${color.grey}
; You cannot customize click actions on official modules? Really?!? >:( click-right = exec pavucontrol
;click-right = exec pavucontrol
; Only applies if <ramp-volume> is used
ramp-volume-0 = ramp-volume-0 =
ramp-volume-1 = ramp-volume-1 =
ramp-volume-2 = ramp-volume-2 =

@ -20,6 +20,8 @@ do
done done
unset cycle unset cycle
POLY_MODR="wireless-network wired-network pulseaudio battery"
NET_IFACES="$(ip link show | awk '/^[0-9]+:/ {sub(/:/,"",$2); print $2}')" NET_IFACES="$(ip link show | awk '/^[0-9]+:/ {sub(/:/,"",$2); print $2}')"
for NET_IFACE in $NET_IFACES ; do for NET_IFACE in $NET_IFACES ; do
case $NET_IFACE in case $NET_IFACE in
@ -34,13 +36,24 @@ if [ -d "$HWMON_MODULE" ]; then
HWMON_BASEDIR="$(find "$HWMON_MODULE" -maxdepth 1 -type d -name 'hwmon*' | tail -n +2 | head -1)" HWMON_BASEDIR="$(find "$HWMON_MODULE" -maxdepth 1 -type d -name 'hwmon*' | tail -n +2 | head -1)"
POLY_HWMON="$HWMON_BASEDIR"/temp1_input POLY_HWMON="$HWMON_BASEDIR"/temp1_input
unset HWMON_BASEDIR unset HWMON_BASEDIR
POLY_MODR="temperature $POLY_MODR"
fi fi
unset HWMON_MODULE unset HWMON_MODULE
# Skip if the folder doesn't exist (kernel module not loaded) or it's empty
if [ ! -d /sys/class/bluetooth ]; then
:
elif [ -z "$(ls -A /sys/class/bluetooth)" ]; then
:
else
POLY_MODR="bluetooth $POLY_MODR"
fi
if type "xrandr"; then if type "xrandr"; then
for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
POLY_WLP=$POLY_WLP POLY_ENP=$POLY_ENP POLY_HWMON=$POLY_HWMON MONITOR=$m polybar main -c "$HOME/.config/polybar/config" & POLY_WLP=$POLY_WLP POLY_ENP=$POLY_ENP POLY_HWMON=$POLY_HWMON POLY_MODR="$POLY_MODR" MONITOR=$m \
polybar main -c "$HOME/.config/polybar/config" &
done done
fi fi
unset POLY_WLP POLY_ENP POLY_HWMON unset POLY_WLP POLY_ENP POLY_HWMON POLY_MODR

@ -43,7 +43,7 @@ while [ $# -gt 0 ]; do
case $COMMAND in case $COMMAND in
"time-pos" | "time-remaining" | "duration" | "media-title" | "playlist-pos" | "playlist-pos-1" | "playlist-count" | "core-idle" | "play-pause-btn") "time-pos" | "time-remaining" | "duration" | "media-title" | "playlist-pos" | "playlist-pos-1" | "playlist-count" | "core-idle" | "play-pause-btn")
if [ "$COMMAND" = "play-pause-btn" ]; then if [ "$COMMAND" = "play-pause-btn" ]; then
COMMAND="core-idle" COMMAND="core-idle"
fi fi
API_OUTPUT=$(printf '{ "command": ["get_property", "%s"] }\n' "$COMMAND" | socat - "$MPV_SOCKET_PATH") API_OUTPUT=$(printf '{ "command": ["get_property", "%s"] }\n' "$COMMAND" | socat - "$MPV_SOCKET_PATH")
;; ;;

Loading…
Cancel
Save