programs.wlr-which-key: init

wlr-which-key is a keymap manager for wlroots-based compositors,
inspired by which-key.nvim.

closes #4396
This commit is contained in:
Minijackson 2024-07-27 22:19:16 +02:00
parent 6e090576c4
commit bd69fcfd47
No known key found for this signature in database
GPG key ID: FEA888C9F5D64F62
8 changed files with 312 additions and 0 deletions

View file

@ -1703,6 +1703,19 @@ in {
one place. See https://github.com/glanceapp/glance for more. one place. See https://github.com/glanceapp/glance for more.
''; '';
} }
{
time = "2024-07-27T20:17:19+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'programs.wlr-which-key'.
wlr-which-key is a keymap manager for wlroots-based compositors,
inspired by which-key.nvim.
See https://github.com/MaxVerevkin/wlr-which-key for more.
'';
}
]; ];
}; };
} }

View file

@ -250,6 +250,7 @@ let
./programs/waybar.nix ./programs/waybar.nix
./programs/wezterm.nix ./programs/wezterm.nix
./programs/wlogout.nix ./programs/wlogout.nix
./programs/wlr-which-key.nix
./programs/wofi.nix ./programs/wofi.nix
./programs/wpaperd.nix ./programs/wpaperd.nix
./programs/xmobar.nix ./programs/xmobar.nix

View file

@ -0,0 +1,88 @@
{ config, lib, pkgs, ... }:
let
cfg = config.programs.wlr-which-key;
yamlFormat = pkgs.formats.yaml { };
in {
meta.maintainers = with lib.maintainers; [ LilleAila mightyiam minijackson ];
options.programs.wlr-which-key = {
enable = lib.mkEnableOption "wlr-which-key configuration";
commonSettings = lib.mkOption {
type = lib.types.submodule { freeformType = yamlFormat.type; };
default = { };
example = {
anchor = "center";
background = "#282828d0";
border = "#8ec07c";
color = "#fbf1c7";
};
description = ''
Settings to be applied to every configuration under the `configs` option.
'';
};
configs = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {
freeformType = yamlFormat.type;
options.menu = lib.mkOption {
description = "The various menus to display";
type = lib.types.attrs;
};
config = cfg.commonSettings;
});
default = { };
example.config = {
anchor = "center";
menu = {
p = {
desc = "Power";
submenu = {
o = {
cmd = "poweroff";
desc = "Off";
};
r = {
cmd = "reboot";
desc = "Reboot";
};
s = {
cmd = "systemctl suspend";
desc = "Sleep";
};
};
};
};
};
description = ''
Various configurations for wlr-which-key.
Each configuration `configs.''${name}` is installed into
`~/.config/wlr-which-key/''${name}.yaml`.
This enables you to run: `wlr-which-key ''${name}`
The default configuration is named 'config'.
For more information on available options, see:
<https://github.com/MaxVerevkin/wlr-which-key/>
'';
};
};
config = lib.mkIf cfg.enable {
home.packages = [ pkgs.wlr-which-key ];
xdg.configFile = lib.mapAttrs' (name: value:
lib.nameValuePair "wlr-which-key/${name}.yaml" {
source = yamlFormat.generate "wlr-which-key-${name}.yaml" value;
}) cfg.configs;
};
}

View file

@ -157,6 +157,7 @@ in import nmtSrc {
./modules/programs/vscode ./modules/programs/vscode
./modules/programs/watson ./modules/programs/watson
./modules/programs/wezterm ./modules/programs/wezterm
./modules/programs/wlr-which-key
./modules/programs/yazi ./modules/programs/yazi
./modules/programs/zellij ./modules/programs/zellij
./modules/programs/zk ./modules/programs/zk

View file

@ -0,0 +1 @@
{ wlr-which-key = ./wlr-which-key.nix; }

View file

@ -0,0 +1,68 @@
anchor: center
background: '#282828d0'
border: '#8ec07c'
border_width: 2
color: '#fbf1c7'
corner_r: 10
font: JetBrainsMono Nerd Font 12
margin_bottom: 0
margin_left: 0
margin_right: 0
margin_top: 0
menu:
l:
desc: Laptop Screen
submenu:
s:
desc: Scale
submenu:
'1':
cmd: wlr-randr --output eDP-1 --scale 1
desc: Set Scale to 1.0
'2':
cmd: wlr-randr --output eDP-1 --scale 1.1
desc: Set Scale to 1.1
'3':
cmd: wlr-randr --output eDP-1 --scale 1.2
desc: Set Scale to 1.2
'4':
cmd: wlr-randr --output eDP-1 --scale 1.3
desc: Set Scale to 1.3
t:
cmd: toggle-laptop-display.sh
desc: Toggle On/Off
p:
desc: Power
submenu:
o:
cmd: poweroff
desc: 'Off'
r:
cmd: reboot
desc: Reboot
s:
cmd: systemctl suspend
desc: Sleep
t:
desc: Theme
submenu:
d:
cmd: dark-theme on
desc: Dark
l:
cmd: dark-theme off
desc: Light
t:
cmd: dark-theme toggle
desc: Toggle
w:
desc: WiFi
submenu:
c:
cmd: kitty --class nmtui-connect nmtui-connect
desc: Connections
t:
cmd: wifi_toggle.sh
desc: Toggle
padding: 15
separator: ' ➜ '

View file

@ -0,0 +1,17 @@
anchor: center
background: '#282828d0'
border: '#8ec07c'
border_width: 2
color: '#fbf1c7'
corner_r: 10
font: JetBrainsMono Nerd Font 12
margin_bottom: 0
margin_left: 0
margin_right: 0
margin_top: 0
menu:
a:
cmd: echo aaah
desc: Say aaah
padding: 15
separator: ' ➜ '

View file

@ -0,0 +1,123 @@
{
programs.wlr-which-key = {
enable = true;
commonSettings = {
anchor = "center";
background = "#282828d0";
border = "#8ec07c";
border_width = 2;
color = "#fbf1c7";
corner_r = 10;
font = "JetBrainsMono Nerd Font 12";
margin_bottom = 0;
margin_left = 0;
margin_right = 0;
margin_top = 0;
padding = 15;
separator = " ";
};
# Example config in the README
configs.config = {
menu = {
l = {
desc = "Laptop Screen";
submenu = {
s = {
desc = "Scale";
submenu = {
"1" = {
cmd = "wlr-randr --output eDP-1 --scale 1";
desc = "Set Scale to 1.0";
};
"2" = {
cmd = "wlr-randr --output eDP-1 --scale 1.1";
desc = "Set Scale to 1.1";
};
"3" = {
cmd = "wlr-randr --output eDP-1 --scale 1.2";
desc = "Set Scale to 1.2";
};
"4" = {
cmd = "wlr-randr --output eDP-1 --scale 1.3";
desc = "Set Scale to 1.3";
};
};
};
t = {
cmd = "toggle-laptop-display.sh";
desc = "Toggle On/Off";
};
};
};
p = {
desc = "Power";
submenu = {
o = {
cmd = "poweroff";
desc = "Off";
};
r = {
cmd = "reboot";
desc = "Reboot";
};
s = {
cmd = "systemctl suspend";
desc = "Sleep";
};
};
};
t = {
desc = "Theme";
submenu = {
d = {
cmd = "dark-theme on";
desc = "Dark";
};
l = {
cmd = "dark-theme off";
desc = "Light";
};
t = {
cmd = "dark-theme toggle";
desc = "Toggle";
};
};
};
w = {
desc = "WiFi";
submenu = {
c = {
cmd = "kitty --class nmtui-connect nmtui-connect";
desc = "Connections";
};
t = {
cmd = "wifi_toggle.sh";
desc = "Toggle";
};
};
};
};
};
configs.other.menu.a = {
cmd = "echo aaah";
desc = "Say aaah";
};
};
test.stubs.wlr-which-key = { };
nmt.script = ''
assertFileExists home-files/.config/wlr-which-key/config.yaml
assertFileContent home-files/.config/wlr-which-key/config.yaml ${
./expected-config.yaml
}
assertFileExists home-files/.config/wlr-which-key/other.yaml
assertFileContent home-files/.config/wlr-which-key/other.yaml ${
./expected-other.yaml
}
'';
}