From 98d8d45529a56ec3208d56c9a57ddfc2282eaf5d Mon Sep 17 00:00:00 2001 From: John Costa Date: Mon, 28 Apr 2025 18:13:34 +0100 Subject: [PATCH] feat: toggling audio between speakers --- config/hypr/hyprland.conf | 4 ++++ config/waybar/config | 7 ++++--- scripts/status | 1 + scripts/toggle-speakers.bash | 12 ++++++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 scripts/status create mode 100644 scripts/toggle-speakers.bash diff --git a/config/hypr/hyprland.conf b/config/hypr/hyprland.conf index b9653ddf..c040a0b6 100644 --- a/config/hypr/hyprland.conf +++ b/config/hypr/hyprland.conf @@ -231,7 +231,11 @@ $mainMod = SUPER # Sets "Windows" key as main modifier bind = $mainMod SHIFT, S, exec, hyprshot -m region -o ~/Pictures/Screenshots bind = $mainMod, V, exec, cliphist list | fuzzel --dmenu | cliphist decode | wl-copy +# Audio control bind = Control, M, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle +bind = Control, M, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle +bind = Control, T, exec, bash ~/Code/dotfiles/scripts/toggle-speakers.bash + # Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more bind = $mainMod, T, exec, $terminal diff --git a/config/waybar/config b/config/waybar/config index ea08d899..29974e4d 100644 --- a/config/waybar/config +++ b/config/waybar/config @@ -39,12 +39,13 @@ }, "pulseaudio": { // "scroll-step": 1, // %, can be a float - "format": "{icon} {volume}% {format_source}", + "format": "{icon} {format_source} {volume}%", "format-muted": "", "format-source": "", - "format-source-muted": "Muted", + "format-source-muted": " ", "format-icons": { - "default": ["", "", " "] + "hdmi": ["", "", " "], + "default": ["", "", ""] }, "on-click": "pavucontrol" }, diff --git a/scripts/status b/scripts/status new file mode 100644 index 00000000..dc55dc91 --- /dev/null +++ b/scripts/status @@ -0,0 +1 @@ +headphones diff --git a/scripts/toggle-speakers.bash b/scripts/toggle-speakers.bash new file mode 100644 index 00000000..0847c61d --- /dev/null +++ b/scripts/toggle-speakers.bash @@ -0,0 +1,12 @@ +#!/bin/bash + +cd ~/Code/dotfiles/scripts +status=$(cat ./status) + +if [ $status == "speakers" ]; then + wpctl set-default 62 + echo "headphones" > ./status +else + wpctl set-default 68 + echo "speakers" > ./status +fi