From 2b18e4aa9d0342eb925b12d1e78f712cfe162370 Mon Sep 17 00:00:00 2001 From: Ryan Kes Date: Thu, 12 Mar 2020 17:27:53 +0100 Subject: [PATCH] Desktop polybar audio widget now uses pulseaudio, as does the volume script --- deadd/.local/bin/volume | 37 ++++++++++++++++++---------------- polybar/.config/polybar/config | 34 +++++++------------------------ 2 files changed, 27 insertions(+), 44 deletions(-) diff --git a/deadd/.local/bin/volume b/deadd/.local/bin/volume index 2a3b9e5..9e26e85 100755 --- a/deadd/.local/bin/volume +++ b/deadd/.local/bin/volume @@ -1,32 +1,35 @@ #!/usr/bin/env bash +# This is a very hacky way of doing this. Default sink for desktop is 0 and for laptop is 3. Kies de eerste de beste die werkt +if pamixer --list-sinks | grep -q "^0"; then + sink=0 +elif pamixer --list-sinks | grep -q "^3"; then + sink=3 +fi + if [ "$1" == "inc" ]; then - amixer -q sset Master 5%+ + pactl -- set-sink-volume "$sink" +5% fi if [ "$1" == "dec" ]; then - amixer -q sset Master 5%- + pactl -- set-sink-volume "$sink" -5% fi if [ "$1" == "mute" ]; then - amixer -q sset Master toggle + pactl -- set-sink-mute "$sink" toggle fi - -AMIXER=$(amixer sget Master) -VOLUME=$(echo "$AMIXER" | grep 'Mono\|Front Right:' | awk -F'[][]' '{ print $2 }' | tr -d "%") -MUTE=$(echo "$AMIXER" | grep -o '\[off\]' | tail -n 1) -if [ "$MUTE" == "[off]" ]; then - ICON=audio-volume-muted +VOLUME=$(pamixer --sink "$sink" --get-volume) +if [ "$(pamixer --sink "$sink" --get-mute)" == "true" ]; then + ICON=audio-volume-muted elif [ "$VOLUME" -le 20 ]; then - ICON=audio-volume-low + ICON=audio-volume-low elif [ "$VOLUME" -le 60 ]; then - ICON=audio-volume-medium -else - ICON=audio-volume-high -fi - + ICON=audio-volume-medium +else + ICON=audio-volume-high +fi notify-send.py "Volume" "$VOLUME/100" \ - --hint string:image-path:$ICON boolean:transient:true \ - --replaces-process "volume-popup" + --hint string:image-path:$ICON boolean:transient:true \ + --replaces-process "volume-popup" & diff --git a/polybar/.config/polybar/config b/polybar/.config/polybar/config index 65d1b00..95b5d31 100644 --- a/polybar/.config/polybar/config +++ b/polybar/.config/polybar/config @@ -14,6 +14,7 @@ foreground-alt = ${xrdb:color7:#222} primary = ${xrdb:color1:#222} secondary = ${xrdb:color2:#222} alert = ${xrdb:color3:#222} +disabled = #666 [bar/base] background = ${colors.background} @@ -246,36 +247,15 @@ label = %date% %time% label-padding-right=1 [module/volume] -type = internal/alsa +type = internal/pulseaudio + +sink = alsa_output.pci-0000_00_1b.0.iec958-stereo -format-volume = label-volume = 蓼 %percentage%% -label-volume-foreground = ${root.foreground} - -format-muted-prefix = -format-muted-foreground = ${colors.foreground-alt} label-muted = "遼" +label-muted-foreground = ${colors.disabled} -bar-volume-width = 10 -bar-volume-foreground-0 = #55aa55 -bar-volume-foreground-1 = #55aa55 -bar-volume-foreground-2 = #55aa55 -bar-volume-foreground-3 = #55aa55 -bar-volume-foreground-4 = #55aa55 -bar-volume-foreground-5 = #f5a70a -bar-volume-foreground-6 = #ff5555 -bar-volume-gradient = false -bar-volume-indicator = | -bar-volume-indicator-font = 2 -bar-volume-fill = ─ -bar-volume-fill-font = 2 -bar-volume-empty = ─ -bar-volume-empty-font = 2 -bar-volume-empty-foreground = ${colors.foreground-alt} - -ramp-volume-0 =  -ramp-volume-1 =  -ramp-volume-2 =  +click-right = pavucontrol & [module/volume-laptop] type = internal/pulseaudio @@ -284,7 +264,7 @@ sink = alsa_output.pci-0000_00_1f.3.analog-stereo label-volume = 蓼 %percentage%% label-muted = "遼" -label-muted-foreground = #666 +label-muted-foreground = ${colors.disabled} click-right = pavucontrol &