Add audio output controls to polybar

This commit is contained in:
Ethan Lane 2022-08-22 18:16:19 +01:00
parent 4fce81eff6
commit bd6fe43b4a
Signed by: Vylpes
GPG key ID: EED233CC06D12504
4 changed files with 24 additions and 5 deletions

View file

@ -73,6 +73,9 @@ bindsym $mod+Shift+o exec --no-startup-id "passmenu-otp -combi-modi window,drun,
# .desktop file. It is a wrapper around dmenu, so you need that installed. # .desktop file. It is a wrapper around dmenu, so you need that installed.
# bindcode $mod+40 exec --no-startup-id i3-dmenu-desktop # bindcode $mod+40 exec --no-startup-id i3-dmenu-desktop
bindsym $mod+Shift+F11 exec --no-startup-id "pactl set-default-sink 3 && sh ~/.scripts/audio/get-sink-name.sh > ~/.cache/scripts/get-sink-name.txt"
bindsym $mod+Shift+F12 exec --no-startup-id "pactl set-default-sink 76 && sh ~/.scripts/audio/get-sink-name.sh > ~/.cache/scripts/get-sink-name.txt"
# change focus # change focus
bindsym $mod+h focus left bindsym $mod+h focus left
bindsym $mod+j focus down bindsym $mod+j focus down

View file

@ -52,7 +52,7 @@ font-0 = Hack;2
font-1 = Font Awesome font-1 = Font Awesome
modules-left = xworkspaces xwindow modules-left = xworkspaces xwindow
modules-right = filesystem pulseaudio xkeyboard memory cpu eth date modules-right = filesystem audiooutput pulseaudio xkeyboard memory cpu eth date
cursor-click = pointer cursor-click = pointer
cursor-scroll = ns-resize cursor-scroll = ns-resize
@ -113,6 +113,15 @@ label-volume = %percentage%%
label-muted = muted label-muted = muted
label-muted-foreground = ${colors.disabled} label-muted-foreground = ${colors.disabled}
[module/audiooutput]
type = custom/script
exec = cat ~/.cache/scripts/get-sink-name.txt
interval = 1
format = <label>
format-prefix = "OUT "
format-prefix-foreground = ${colors.primary}
label = %output%
[module/xkeyboard] [module/xkeyboard]
type = internal/xkeyboard type = internal/xkeyboard
blacklist-0 = num lock blacklist-0 = num lock

View file

@ -0,0 +1,11 @@
#!/bin/bash
SINK=$(pactl get-default-sink)
if [ $SINK = "alsa_output.pci-0000_1f_00.3.analog-stereo" ]; then
echo "Speakers"
elif [ $SINK = "alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo" ]; then
echo "Headphones"
else
echo "-"
fi

View file

@ -1,4 +0,0 @@
if [ -d /sys/class/power_supply/BAT0 ]
then
echo $(acpi -V | grep 'Battery 0' | head -n 1 | cut -f2 -d, | sed 's/ //')
fi