-
Notifications
You must be signed in to change notification settings - Fork 8
Audio
From polybar, you can control your audio.
Here's what the modules look like on the polybar bar:
- Left click on the icon to switch between headphones and speaker.
- Left click on the volume number to mute the current output.
- Scroll wheel up/down on the volume number to increase/decrease volume.
- Right click the volume number to open pavucontrol (a gui for pulseaudio)
There are two polybar modules that help control audio:
This module outputs the volume level (number) of the current output, (un)muting, and launching pavucontrol.
# ~/.config/polybar/config
[module/pulseaudio-tail]
type = custom/script
exec = ~/.local/bin/tools/pulseaudio-tail.sh
tail = true
click-right = exec pavucontrol &
click-left = mute_toggle
scroll-up = volume up 3
scroll-down = volume down 3
format-padding = 1
This module is responsible for switching the output between headphones and speakers.
# ~/.config/polybar/config
[module/alsa-switch]
type = custom/script
click-left = ~/.local/bin/tools/polybar_alsa_module --switch
exec = ~/.local/bin/tools/polybar_alsa_module --mutefg "BF616A" --mutebg "88C0D0" --bg "88C0D0" --fg "3B4252"
tail = true
Dependencies are automatically installed as part of the install of Dotfiles. In case you want to install/update them yourself, here is a list:
Golang packages:
Here is how I install golang packages: example
Arch Packages:
- pulseaudio
- alsa-utils
AUR Packages:
- awesome-terminal-fonts (used for the icons in the scripts, the volume/headphone icons)
Really the only configuration you'll likely need to do is to edit a few fields in ~/.local/bin/tools/polybar_alsa_module
. There are instructions detailed in that script. It's got a lot documented, but most of it is for me. You just need to run the command it recommends, which outputs the names of your output devices (your headphones and speakers). Then take those names and overwrite the names in the script (if you are confused, it is detailed more in the script).
Once you've done that, you can restart polybar ($mod+Shift+r
-> reloads i3 -> reloads polybar)
To get the output of individual modules, run them directly in your terminal.
example:
sh ~/.local/bin/tools/polybar_alsa_module
If you need to debug interacting with the click/scroll events of the modules, it's better to run kill polybar and run it it via your terminal so you can view stdout/stderr as you interact with it's modules:
pkill polybar
sh ~/.config/polybar/launch.sh
Polybar will reload whenever it's config file is modified, but not when modules are modified. You will have to run the above command whenever you modify the modules.
The following is already configured via the install and should work out of the box. In case you need to set this up yourself for some reason, here are the relevant chunks of code.
play/pause/next/prev spotify songs using your keyboards media keys.
# ~/.config/i3/config
## play/next/previous using ~/.local/bin/tools/sp (control spotify via dbus)
bindsym XF86AudioPlay exec --no-startup-id sp play # play acts as a toggle
bindsym XF86AudioNext exec --no-startup-id sp next
bindsym XF86AudioPrev exec --no-startup-id sp prev
bindsym XF86AudioStop exec --no-startup-id sp pause
# ~/.config/i3/config
# uses golang github.com/itchyny/volume-go
bindsym XF86AudioRaiseVolume exec --no-startup-id volume up 3 && sh -c "volnoti-show $(volume get)" #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id volume down 3 && sh -c "volnoti-show $(volume get)" #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id sh -c "mute_toggle" # mute sound (uses tools/mute_toggle script)