From a364b76da2b344518ae1c8fecd6c3b0bd8b5c6d0 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Mon, 22 Jul 2024 13:38:23 -0400 Subject: [PATCH] Revert "ironbar: Add attempt at using volume module" The volume module currently has a bug that causes audio output to stop working when plugging in new devices. Upstream issue: https://github.com/JakeStanger/ironbar/issues/673 --- home/hyprland.nix | 2 +- home/ironbar.nix | 43 +++++++++++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/home/hyprland.nix b/home/hyprland.nix index 43e5c59b..a524c177 100644 --- a/home/hyprland.nix +++ b/home/hyprland.nix @@ -212,7 +212,7 @@ in "${super}, S, swapactiveworkspaces, 0 1" "${super}_SHIFT, S, movetoworkspace, special" "${super}_SHIFT, A, exec, killall activate-linux || activate-linux -s 1.15 -x 412 -y 120 -c 1-1-1-0.05" - "${super}, O, exec, killall .ironbar-wrapper inotifywait || ironbar" + "${super}, O, exec, killall .ironbar-wrapper inotifywait pactl || ironbar" "${super}_SHIFT, O, exec, eww close overlay || eww open overlay" ''${super}, comma, exec, playerctl -p mpv position "5-" && ${notifySend} "Minus 5 seconds" "$(playerctl -p mpv position)"'' ''${super}, period, exec, playerctl -p mpv position "5+" && ${notifySend} "Plus 5 seconds" "$(playerctl -p mpv position)"'' diff --git a/home/ironbar.nix b/home/ironbar.nix index fb2f311d..4b174f1c 100644 --- a/home/ironbar.nix +++ b/home/ironbar.nix @@ -7,6 +7,8 @@ let inherit (builtins) toJSON; mullvadScript = "ironbar/mullvad.fish"; + volumeScript = "ironbar/volume.fish"; + volumeGet = "ironbar/volume-get.fish"; in { home.packages = [ ironbar ]; @@ -46,8 +48,11 @@ in end = [ { - type = "volume"; - format = "{icon} {percentage}%"; + type = "script"; + cmd = "~/.config/${volumeScript}"; + on_click_left = "swayosd-client --output-volume raise"; + on_click_right = "swayosd-client --output-volume lower"; + mode = "watch"; } { type = "upower"; @@ -98,14 +103,6 @@ in padding-right: 0.7em; } - slider { - background: #${base0D}; - } - - trough { - background: alpha(#${base04}, 0.4); - } - .upower { padding-left: 0.2em; padding-right: 0.2em; @@ -245,4 +242,30 @@ in end ''; }; + + xdg.configFile.${volumeScript} = { + executable = true; + text = /* fish */ '' + #!/usr/bin/env fish + + function get_volume + set VOLUME (wpctl get-volume @DEFAULT_AUDIO_SINK@ | choose 1) + echo "音量:$(math "$VOLUME * 100")%" + end + + ~/.config/${volumeGet} + + pactl subscribe | grep --line-buffered -e "シンク" | xargs -L 1 ~/.config/${volumeGet} + ''; + }; + + xdg.configFile.${volumeGet} = { + executable = true; + text = /* fish */ '' + #!/usr/bin/env fish + + set VOLUME (wpctl get-volume @DEFAULT_AUDIO_SINK@ | choose 1) + echo "音量:$(math "$VOLUME * 100")%" + ''; + }; }