1
0
mirror of https://github.com/alrayyes/dotfiles/ synced 2023-11-14 15:56:30 +00:00

Desktop polybar audio widget now uses pulseaudio, as does the volume script

This commit is contained in:
Ryan Kes 2020-03-12 17:27:53 +01:00
parent da371ab7aa
commit 2b18e4aa9d
2 changed files with 27 additions and 44 deletions

View File

@ -1,32 +1,35 @@
#!/usr/bin/env bash #!/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 if [ "$1" == "inc" ]; then
amixer -q sset Master 5%+ pactl -- set-sink-volume "$sink" +5%
fi fi
if [ "$1" == "dec" ]; then if [ "$1" == "dec" ]; then
amixer -q sset Master 5%- pactl -- set-sink-volume "$sink" -5%
fi fi
if [ "$1" == "mute" ]; then if [ "$1" == "mute" ]; then
amixer -q sset Master toggle pactl -- set-sink-mute "$sink" toggle
fi fi
VOLUME=$(pamixer --sink "$sink" --get-volume)
AMIXER=$(amixer sget Master) if [ "$(pamixer --sink "$sink" --get-mute)" == "true" ]; then
VOLUME=$(echo "$AMIXER" | grep 'Mono\|Front Right:' | awk -F'[][]' '{ print $2 }' | tr -d "%") ICON=audio-volume-muted
MUTE=$(echo "$AMIXER" | grep -o '\[off\]' | tail -n 1)
if [ "$MUTE" == "[off]" ]; then
ICON=audio-volume-muted
elif [ "$VOLUME" -le 20 ]; then elif [ "$VOLUME" -le 20 ]; then
ICON=audio-volume-low ICON=audio-volume-low
elif [ "$VOLUME" -le 60 ]; then elif [ "$VOLUME" -le 60 ]; then
ICON=audio-volume-medium ICON=audio-volume-medium
else else
ICON=audio-volume-high ICON=audio-volume-high
fi fi
notify-send.py "Volume" "$VOLUME/100" \ notify-send.py "Volume" "$VOLUME/100" \
--hint string:image-path:$ICON boolean:transient:true \ --hint string:image-path:$ICON boolean:transient:true \
--replaces-process "volume-popup" --replaces-process "volume-popup" &

View File

@ -14,6 +14,7 @@ foreground-alt = ${xrdb:color7:#222}
primary = ${xrdb:color1:#222} primary = ${xrdb:color1:#222}
secondary = ${xrdb:color2:#222} secondary = ${xrdb:color2:#222}
alert = ${xrdb:color3:#222} alert = ${xrdb:color3:#222}
disabled = #666
[bar/base] [bar/base]
background = ${colors.background} background = ${colors.background}
@ -246,36 +247,15 @@ label = %date% %time%
label-padding-right=1 label-padding-right=1
[module/volume] [module/volume]
type = internal/alsa type = internal/pulseaudio
sink = alsa_output.pci-0000_00_1b.0.iec958-stereo
format-volume = <label-volume>
label-volume = 蓼 %percentage%% label-volume = 蓼 %percentage%%
label-volume-foreground = ${root.foreground}
format-muted-prefix =
format-muted-foreground = ${colors.foreground-alt}
label-muted = "遼" label-muted = "遼"
label-muted-foreground = ${colors.disabled}
bar-volume-width = 10 click-right = pavucontrol &
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 = 
[module/volume-laptop] [module/volume-laptop]
type = internal/pulseaudio type = internal/pulseaudio
@ -284,7 +264,7 @@ sink = alsa_output.pci-0000_00_1f.3.analog-stereo
label-volume = 蓼 %percentage%% label-volume = 蓼 %percentage%%
label-muted = "遼" label-muted = "遼"
label-muted-foreground = #666 label-muted-foreground = ${colors.disabled}
click-right = pavucontrol & click-right = pavucontrol &