mirror of
https://github.com/nix-community/home-manager
synced 2024-11-10 07:04:17 +00:00
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:
parent
6e090576c4
commit
bd69fcfd47
8 changed files with 312 additions and 0 deletions
|
@ -1703,6 +1703,19 @@ in {
|
|||
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.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -250,6 +250,7 @@ let
|
|||
./programs/waybar.nix
|
||||
./programs/wezterm.nix
|
||||
./programs/wlogout.nix
|
||||
./programs/wlr-which-key.nix
|
||||
./programs/wofi.nix
|
||||
./programs/wpaperd.nix
|
||||
./programs/xmobar.nix
|
||||
|
|
88
modules/programs/wlr-which-key.nix
Normal file
88
modules/programs/wlr-which-key.nix
Normal 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;
|
||||
};
|
||||
}
|
|
@ -157,6 +157,7 @@ in import nmtSrc {
|
|||
./modules/programs/vscode
|
||||
./modules/programs/watson
|
||||
./modules/programs/wezterm
|
||||
./modules/programs/wlr-which-key
|
||||
./modules/programs/yazi
|
||||
./modules/programs/zellij
|
||||
./modules/programs/zk
|
||||
|
|
1
tests/modules/programs/wlr-which-key/default.nix
Normal file
1
tests/modules/programs/wlr-which-key/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ wlr-which-key = ./wlr-which-key.nix; }
|
68
tests/modules/programs/wlr-which-key/expected-config.yaml
Normal file
68
tests/modules/programs/wlr-which-key/expected-config.yaml
Normal 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: ' ➜ '
|
17
tests/modules/programs/wlr-which-key/expected-other.yaml
Normal file
17
tests/modules/programs/wlr-which-key/expected-other.yaml
Normal 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: ' ➜ '
|
123
tests/modules/programs/wlr-which-key/wlr-which-key.nix
Normal file
123
tests/modules/programs/wlr-which-key/wlr-which-key.nix
Normal 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
|
||||
}
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue