From e212225ff23c6fe49ccea46a94520f3d1154fdd4 Mon Sep 17 00:00:00 2001 From: NullBite Date: Sun, 12 May 2024 10:57:38 -0400 Subject: [PATCH] home/wm: add keybind helper --- home/common/default.nix | 2 +- home/common/{wm.nix => wm/default.nix} | 0 home/common/wm/keybinds.nix | 47 ++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) rename home/common/{wm.nix => wm/default.nix} (100%) create mode 100644 home/common/wm/keybinds.nix diff --git a/home/common/default.nix b/home/common/default.nix index f16e801..29f2932 100644 --- a/home/common/default.nix +++ b/home/common/default.nix @@ -1,7 +1,7 @@ {...}: { imports = [ - ./wm.nix + ./wm ./nodm.nix ./nix.nix ]; diff --git a/home/common/wm.nix b/home/common/wm/default.nix similarity index 100% rename from home/common/wm.nix rename to home/common/wm/default.nix diff --git a/home/common/wm/keybinds.nix b/home/common/wm/keybinds.nix new file mode 100644 index 0000000..f91b379 --- /dev/null +++ b/home/common/wm/keybinds.nix @@ -0,0 +1,47 @@ +{ pkgs, config, lib, outputs, ... }: +let + df = lib.mkDefault; + mkxf = with lib; mapAttrs' (name: value: nameValuePair ("XF86" + name) (value)); + + # not rewriting this rn + keysetting = "${outputs.packages.${pkgs.system}.wm-helpers}/bin/keysetting"; +in +{ + options.nixfiles.common.wm = { + keybinds = lib.mkOption { + description = '' + Attribute set containing wm-independent XF86 keysyms and associated + commands (without the XF86 prefix) + ''; + type = with lib.types; attrsOf str; + default = {}; + example = { + XF86AudioPlay = "playerctl play-pause"; + }; + }; + + finalKeybinds = lib.mkOption { + description = "Keysyms with XF86 prefix"; + type = with lib.types; attrsOf str; + default = mkxf config.nixfiles.common.wm.keybinds; + readOnly = true; + }; + }; + config = { + nixfiles.common.wm.keybinds = { + AudioRaiseVolume = df "${keysetting} volumeup"; + AudioLowerVolume = df "${keysetting} volumedown"; + AudioMute = df "${keysetting} mute"; + AudioMicMute = df "${keysetting} micmute"; + + KbdBrightnessDown = df "${keysetting} keydown"; + KbdBrightnessUp = df "${keysetting} keyup"; + MonBrightnessDown = df "${keysetting} mondown"; + MonBrightnessUp = df "${keysetting} monup"; + + AudioPlay = df "playerctl play-pause"; + AudioPrev = df "playerctl previous"; + AudioNext = df "playerctl next"; + }; + }; +}