Simple one-button audio output switch for Hyprland.
Toggle between speakers and headphones.
Works out of the box with the cachyos-hyprland-settings package and configuration.
(February 2025)
This script is not officially affiliated with Hyprland.
Required Hyprland configuration:
- PipeWire
- WirePlumber
- (Optional) Mako for notifications
-
Copy the script
Place thehyprland-audio-switch.py
script in the following directory:~/.config/hypr/scripts/
-
Set permission for the script
Allow the execution ofhyprland-audio-switch.py
:chmod +x ~/.config/hypr/scripts/hyprland-audio-switch.py
-
Set a key bind in
hyprland.conf
Add the following line to yourhyprland.conf
:bind = , XF86HomePage, exec, ~/.config/hypr/scripts/hyprland-audio-switch.py
Replace
XF86HomePage
with your preferred keybinding.
If you want to exclude certain audio outputs from switching, edit this line in the script:
SKIP_SINK_NAMES = ["USB Audio S/PDIF Output", ""]
Use the following command to get the names of your audio outputs ("Sinks"):
wpctl status
If you have Mako installed, you can enable or disable notifications by modifying this line in the script:
ENABLE_NOTIFICATIONS = True