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