From 1d5acc09c6ec41b3aca60a2f58e76af2c4971c80 Mon Sep 17 00:00:00 2001 From: alexion Date: Sun, 11 Oct 2026 21:22:38 -0400 Subject: [PATCH] refactor(audio): simplify media controls --- .../nixos/modules/desktop/utilities/audio.nix | 57 +++++++------------ 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/configs/nixos/modules/desktop/utilities/audio.nix b/configs/nixos/modules/desktop/utilities/audio.nix index d34ef91..9444772 100644 --- a/configs/nixos/modules/desktop/utilities/audio.nix +++ b/configs/nixos/modules/desktop/utilities/audio.nix @@ -6,37 +6,33 @@ ... }: # PipeWire as the desktop audio server. +let + mediaKey = keys: command: { + inherit keys; + locked = true; + action = { + kind = "exec"; + command = "${lib.getExe pkgs.playerctl} ${command}"; + }; + }; +in { options.modules.desktop.utilities.audio.enable = lib.mkEnableOption "the PipeWire audio server"; config = lib.mkIf config.modules.desktop.utilities.audio.enable { + # Realtime scheduling for the audio threads, so playback survives load. + security.rtkit.enable = true; + + services.pipewire = { + enable = true; + alsa.enable = true; + pulse.enable = true; + }; + registry.keybind.${config.networking.hostName} = { - media-play = { - keys = "XF86AudioPlay"; - locked = true; - action = { - kind = "exec"; - command = "${lib.getExe pkgs.playerctl} play-pause"; - }; - }; - - media-next = { - keys = "XF86AudioNext"; - locked = true; - action = { - kind = "exec"; - command = "${lib.getExe pkgs.playerctl} next"; - }; - }; - - media-previous = { - keys = "XF86AudioPrev"; - locked = true; - action = { - kind = "exec"; - command = "${lib.getExe pkgs.playerctl} previous"; - }; - }; + media-play = mediaKey "XF86AudioPlay" "play-pause"; + media-next = mediaKey "XF86AudioNext" "next"; + media-previous = mediaKey "XF86AudioPrev" "previous"; }; registry.waybar.${config.networking.hostName} = { @@ -66,14 +62,5 @@ }; }; }; - - # Realtime scheduling for the audio threads, so playback survives load. - security.rtkit.enable = true; - - services.pipewire = { - enable = true; - alsa.enable = true; - pulse.enable = true; - }; }; }