Modules/Hyprland: Improve keybinding help by truncating /nix/store and /home/christoph paths
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
mylib,
|
||||
pkgs,
|
||||
nixosConfig,
|
||||
username,
|
||||
...
|
||||
}: let
|
||||
inherit (config.modules) hyprland color;
|
||||
@ -168,27 +169,34 @@ in {
|
||||
|
||||
file = {
|
||||
".config/hypr/keybindings.info".text = let
|
||||
fixupNoMod = key: ''${builtins.replaceStrings
|
||||
["<-"]
|
||||
["<"]
|
||||
key}'';
|
||||
fixupHomeDir = key:
|
||||
builtins.replaceStrings ["/home/${username}"] ["~"] key;
|
||||
|
||||
mkBindHelpKey = key: ''${builtins.replaceStrings
|
||||
["$mainMod" " " ","]
|
||||
["${hyprland.keybindings.main-mod}" "-" ""]
|
||||
key}'';
|
||||
fixupNixStore = key: let
|
||||
# The pattern has to match the entire string, otherwise it won't work
|
||||
matches = builtins.match ".*/nix/store/(.*)/.*" key;
|
||||
in
|
||||
if (matches == null)
|
||||
then key
|
||||
else builtins.replaceStrings matches ["..."] key;
|
||||
|
||||
mkBindHelpAction = action: ''${builtins.replaceStrings
|
||||
[","]
|
||||
[""]
|
||||
action}'';
|
||||
fixupNoMod = key:
|
||||
builtins.replaceStrings ["<-"] ["<"] key;
|
||||
|
||||
mkBindHelpKey = key:
|
||||
builtins.replaceStrings ["$mainMod" " " ","] ["${hyprland.keybindings.main-mod}" "-" ""] key;
|
||||
|
||||
mkBindHelpAction = action:
|
||||
builtins.replaceStrings [","] [""] action;
|
||||
|
||||
mkBindHelp = key: action: "<${mkBindHelpKey key}>: ${mkBindHelpAction action}";
|
||||
|
||||
mkBindsHelp = key: actions:
|
||||
actions
|
||||
|> builtins.map (mkBindHelp key)
|
||||
|> builtins.map fixupNoMod;
|
||||
|> builtins.map fixupNoMod
|
||||
|> builtins.map fixupNixStore
|
||||
|> builtins.map fixupHomeDir;
|
||||
in
|
||||
(hyprland.keybindings.bindings // always-bind)
|
||||
|> builtins.mapAttrs mkBindsHelp
|
||||
|
@ -134,17 +134,17 @@ in {
|
||||
|
||||
modules.hyprland.keybindings = let
|
||||
vpn-menu =
|
||||
pkgs.writeScript
|
||||
pkgs.writeScriptBin
|
||||
"rofi-menu-vpn"
|
||||
(builtins.readFile ./menus/vpn.fish);
|
||||
|
||||
keybinds-menu =
|
||||
pkgs.writeScript
|
||||
pkgs.writeScriptBin
|
||||
"rofi-menu-keybinds"
|
||||
(builtins.readFile ./menus/keybinds.fish);
|
||||
|
||||
lectures-menu =
|
||||
pkgs.writeScript
|
||||
pkgs.writeScriptBin
|
||||
"rofi-menu-lectures"
|
||||
(builtins.readFile ./menus/lectures.fish);
|
||||
|
||||
@ -182,13 +182,13 @@ in {
|
||||
in {
|
||||
bindings = lib.mergeAttrsList [
|
||||
{
|
||||
"$mainMod, escape" = ["exec, \"${power-menu}\""];
|
||||
"$mainMod, m" = ["exec, \"${keybinds-menu}\""];
|
||||
"$mainMod, w" = ["exec, \"${wallpaper-menu}\""];
|
||||
"$mainMod, escape" = ["exec, \"${power-menu}/bin/rofi-menu-power\""];
|
||||
"$mainMod, m" = ["exec, \"${keybinds-menu}/bin/rofi-menu-keybinds\""];
|
||||
"$mainMod, w" = ["exec, \"${wallpaper-menu}/bin/rofi-menu-wall\""];
|
||||
# "$mainMod, o" = ["exec, \"${lectures-menu}\""];
|
||||
}
|
||||
(lib.optionalAttrs (!nixosConfig.modules.network.useNetworkManager) {
|
||||
"$mainMod, U" = ["exec, \"${vpn-menu}\""];
|
||||
"$mainMod, U" = ["exec, \"${vpn-menu}/rofi-menu-vpn\""];
|
||||
})
|
||||
];
|
||||
};
|
||||
|
@ -22,7 +22,7 @@
|
||||
|> builtins.concatStringsSep "\n";
|
||||
in
|
||||
prompt: attrs:
|
||||
pkgs.writeScript "rofi-menu-${prompt}" ''
|
||||
pkgs.writeScriptBin "rofi-menu-${prompt}" ''
|
||||
#! ${pkgs.fish}/bin/fish
|
||||
|
||||
# OPTIONS contains all possible values Rofi will display
|
||||
|
Reference in New Issue
Block a user