From e4c968bf7563aafe73a0ac69e092138d347eee4b Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Wed, 10 Jul 2024 22:28:28 -0400 Subject: [PATCH] meta: Replace custom scripts with swayosd No idea why I didn't do this before but this significantly simplifies things and makes the experience nicer overall. --- home/hyprland.nix | 58 +++++------------------------------------------ home/ironbar.nix | 4 ++-- home/swayosd.nix | 3 +++ 3 files changed, 11 insertions(+), 54 deletions(-) create mode 100644 home/swayosd.nix diff --git a/home/hyprland.nix b/home/hyprland.nix index c7261d2d..b32ef4f5 100644 --- a/home/hyprland.nix +++ b/home/hyprland.nix @@ -9,9 +9,6 @@ let osu-backgrounds = callPackage ../packages/osu-backgrounds.nix { }; - raiseVolumeScript = "hypr/raise-volume.fish"; - lowerVolumeScript = "hypr/lower-volume.fish"; - muteScript = "hypr/mute.fish"; gapsScript = "hypr/gaps.fish"; randomBackgroundScript = "hypr/random-bg.fish"; swapBackgroundScript = "hypr/swap-bg.fish"; @@ -275,12 +272,12 @@ in ]; bindl = [ - ", XF86AudioMute, exec, ~/.config/${muteScript} Volume @DEFAULT_AUDIO_SINK@" - ", XF86AudioRaiseVolume, exec, ~/.config/${raiseVolumeScript}" - ", XF86AudioLowerVolume, exec, ~/.config/${lowerVolumeScript}" - ", XF86AudioMicMute, exec, ~/.config/${muteScript} Microphone @DEFAULT_AUDIO_SOURCE@" - ", XF86MonBrightnessDown, exec, brightnessctl set 5%- && ${vars.notifySend} \"Decreased brightness to\" \"$(brightnessctl get)\"" - ", XF86MonBrightnessUp, exec, brightnessctl set +5% && ${vars.notifySend} \"Increased brightness to\" \"$(brightnessctl get)\"" + ", XF86AudioMute, exec, swayosd-client --output-volume mute-toggle" + ", XF86AudioRaiseVolume, exec, swayosd-client --output-volume raise" + ", XF86AudioLowerVolume, exec, swayosd-client --output-volume lower" + ", XF86AudioMicMute, exec, swayosd-client --input-volume mute-toggle" + ", XF86MonBrightnessDown, exec, swayosd-client --brightness lower" + ", XF86MonBrightnessUp, exec, swayosd-client --brightness raise" ", XF86Display, exec, ~/.config/${monitorScript}" ", XF86WLAN, exec, sleep 0.2 && ${vars.notifySend} \"WiFi\" \"$(nmcli radio wifi)\"" ]; @@ -306,49 +303,6 @@ in ''; }; - xdg.configFile.${raiseVolumeScript} = { - executable = true; - text = /* fish */ '' - #!/usr/bin/env fish - - wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ - - set VOL $(math "$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | choose 1) * 100") - - ${vars.notifySend} "Raised volume to" "$VOL%" - ''; - }; - - xdg.configFile.${lowerVolumeScript} = { - executable = true; - text = /* fish */ '' - #!/usr/bin/env fish - - wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- - - set VOL $(math "$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | choose 1) * 100") - - ${vars.notifySend} "Lowered volume to" "$VOL%" - ''; - }; - - xdg.configFile.${muteScript} = { - executable = true; - text = /* fish */ '' - #!/usr/bin/env fish - - wpctl set-mute "$argv[2]" toggle - - set SINK $(wpctl get-volume "$argv[2]") - - if test -n "$(echo $SINK | choose 2)" - ${vars.notifySend} "$argv[1]" "Muted" - else - ${vars.notifySend} "$argv[1]" "$(math "$(echo $SINK | choose 1) * 100")%" - end - ''; - }; - xdg.configFile.${setBackgroundScript} = { executable = true; text = /* fish */ '' diff --git a/home/ironbar.nix b/home/ironbar.nix index fb8dabed..a4d4abf2 100644 --- a/home/ironbar.nix +++ b/home/ironbar.nix @@ -54,8 +54,8 @@ in { type = "script"; cmd = "~/.config/${volumeScript}"; - on_click_left = "~/.config/hypr/raise-volume.fish"; - on_click_right = "~/.config/hypr/lower-volume.fish"; + on_click_left = "swayosd-client --output-volume raise"; + on_click_right = "swayosd-client --output-volume lower"; mode = "watch"; } { diff --git a/home/swayosd.nix b/home/swayosd.nix new file mode 100644 index 00000000..88bbf110 --- /dev/null +++ b/home/swayosd.nix @@ -0,0 +1,3 @@ +{ + services.swayosd.enable = true; +}