diff --git a/config/rofi/menus/keybinds.fish b/config/rofi/menus/keybinds.fish index 553597ac..354c5551 100755 --- a/config/rofi/menus/keybinds.fish +++ b/config/rofi/menus/keybinds.fish @@ -1,3 +1,3 @@ #!/usr/bin/env fish -grep -E "^bind =" ~/NixFlake/config/hyprland/hyprland.conf | sd "bind = " "" | rofi -dmenu -p " keys " -i \ No newline at end of file +cat ~/.config/hypr/keybindings.info | rofi -dmenu -p " keys " -i diff --git a/home/modules/hyprland/default.nix b/home/modules/hyprland/default.nix index 9951c337..4ebcb382 100644 --- a/home/modules/hyprland/default.nix +++ b/home/modules/hyprland/default.nix @@ -33,6 +33,12 @@ mkBind = key: action: "${key}, ${action}"; mkBinds = key: actions: builtins.map (mkBind key) actions; + # These functions are used to generate the keybindings.info file for Rofi + mkBindHelpKey = key: ''${builtins.replaceStrings ["$mainMod " ", "] ["${cfg.keybindings.main-mod}-" "-"] key}''; + mkBindHelpAction = action: ''${builtins.replaceStrings [","] [""] action}''; + mkBindHelp = key: action: "<${mkBindHelpKey key}>: ${mkBindHelpAction action}"; + mkBindsHelp = key: actions: builtins.map (mkBindHelp key) actions; + mkWallpaper = monitor: "${monitor}, ${config.home.homeDirectory}/NixFlake/wallpapers/${cfg.theme}.png"; mkDelayedStart = str: "hyprctl dispatch exec \"sleep 5s && ${str}\""; @@ -164,6 +170,15 @@ in { libsForQt5.qtwayland kdePackages.qtwayland ]; + + file = { + ".config/hypr/keybindings.info".text = lib.pipe (lib.mergeAttrs cfg.keybindings.bindings always-bind) [ + (builtins.mapAttrs mkBindsHelp) + builtins.attrValues + builtins.concatLists + (builtins.concatStringsSep "\n") + ]; + }; }; programs = {