Skip to content

Commit

Permalink
feat: niri workspace keybinds
Browse files Browse the repository at this point in the history
  • Loading branch information
sioodmy committed May 30, 2024
1 parent 336688b commit bc1af01
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 77 deletions.
92 changes: 92 additions & 0 deletions home/rice/niri/binds.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
config,
pkgs,
lib,
...
}: {
programs.niri.settings.binds = with config.lib.niri.actions; let
sh = spawn "sh" "-c";
in
{
"Mod+Return" = {
action = spawn "${pkgs.foot}/bin/foot";
cooldown-ms = 500;
};
"Mod+Space".action = spawn "${pkgs.fuzzel}/bin/fuzzel";
"Mod+V".action = sh "${pkgs.cliphist}/bin/cliphist list | fuzzel --dmenu | cliphist decode | wl-copy";
"Mod+Shift+Period".action = spawn "emoji";
"Mod+Shift+L".action = sh "niri msg action power-off-monitors; gtklock";

"XF86AudioRaiseVolume".action = spawn "pamixer" "-i" "5";
"XF86AudioLowerVolume".action = spawn "pamixer" "-d" "5";
"XF86AudioMute".action = spawn "pamixer" "-t";
"XF86AudioMicMute".action = spawn "micmute";

"XF86Bluetooth".action = spawn "bcn";

"XF86MonBrightnessUp".action = spawn "brightnessctl" "set" "+5%";
"XF86MonBrightnessDown".action = spawn "brightnessctl" "set" "5%-";

"Mod+Period".action = expel-window-from-column;
"Mod+Comma".action = consume-window-into-column;

"Mod+WheelScrollDown".action = focus-workspace-down;
"Mod+WheelScrollDown".cooldown-ms = 500;
"Mod+WheelScrollUp".action = focus-workspace-up;
"Mod+WheelScrollUp".cooldown-ms = 500;
"Mod+WheelScrollRight".action = focus-column-right;
"Mod+WheelScrollLeft".action = focus-column-left;

"Mod+H".action = focus-column-left;
"Mod+L".action = focus-column-right;
"Mod+J".action = focus-workspace-down;
"Mod+K".action = focus-workspace-up;
"Mod+Left".action = focus-column-left;
"Mod+Right".action = focus-column-right;
"Mod+Down".action = focus-window-down;
"Mod+Up".action = focus-window-up;

"Mod+Print".action = screenshot-window;
"Mod+Shift+Print".action = screenshot-screen;
"Mod+Shift+S".action = screenshot;

"Mod+Ctrl+H".action = move-column-left;
"Mod+Ctrl+J".action = move-window-down;
"Mod+Ctrl+K".action = move-window-up;
"Mod+Ctrl+L".action = move-column-right;

"Mod+U".action = move-workspace-down;
"Mod+I".action = move-workspace-up;

"Mod+Minus".action = set-column-width "-10%";
"Mod+Equal".action = set-column-width "+10%";
"Mod+Shift+Minus".action = set-window-height "-10%";
"Mod+Shift+Equal".action = set-window-height "+10%";

"Mod+Shift+J".action = focus-monitor-down;
"Mod+Shift+K".action = focus-monitor-up;

"Mod+Shift+Ctrl+H".action = move-column-to-monitor-left;
"Mod+Shift+Ctrl+J".action = move-column-to-monitor-down;
"Mod+Shift+Ctrl+K".action = move-column-to-monitor-up;
"Mod+Shift+Ctrl+L".action = move-column-to-monitor-right;

"Mod+R".action = switch-preset-column-width;
"Mod+F".action = maximize-column;
"Mod+Shift+F".action = fullscreen-window;
"Mod+C".action = center-column;

"Mod+Q".action = close-window;

"Mod+Shift+P".action = power-off-monitors;
}
// (lib.attrsets.mergeAttrsList (
map (x: let
xStr = builtins.toString x;
in {
"Mod+${xStr}".action = focus-workspace x;
"Mod+Shift+${xStr}".action = move-column-to-workspace x;
})
(builtins.genList (x: x + 1) 9)
));
}
77 changes: 1 addition & 76 deletions home/rice/niri/config.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
pkgs,
theme,
config,
...
}:
with theme.colors; {
imports = [ ./binds.nix ];
programs.niri.settings = {
spawn-at-startup = [
{
Expand Down Expand Up @@ -103,80 +102,6 @@ with theme.colors; {
}
];

binds = with config.lib.niri.actions; let
sh = spawn "sh" "-c";
in {
"Mod+Return" = {
action = spawn "${pkgs.foot}/bin/foot";
cooldown-ms = 500;
};
"Mod+Space".action = spawn "${pkgs.fuzzel}/bin/fuzzel";
"Mod+V".action = sh "${pkgs.cliphist}/bin/cliphist list | fuzzel --dmenu | cliphist decode | wl-copy";
"Mod+Shift+Period".action = spawn "emoji";
"Mod+Shift+L".action = sh "niri msg action power-off-monitors; gtklock";

"XF86AudioRaiseVolume".action = spawn "pamixer" "-i" "5";
"XF86AudioLowerVolume".action = spawn "pamixer" "-d" "5";
"XF86AudioMute".action = spawn "pamixer" "-t";
"XF86AudioMicMute".action = spawn "micmute";

"XF86Bluetooth".action = spawn "bcn";

"XF86MonBrightnessUp".action = spawn "brightnessctl" "set" "+5%";
"XF86MonBrightnessDown".action = spawn "brightnessctl" "set" "5%-";

"Super+WheelScrollDown".action = focus-workspace-down;
"Super+WheelScrollDown".cooldown-ms = 500;
"Super+WheelScrollUp".action = focus-workspace-up;
"Super+WheelScrollUp".cooldown-ms = 500;
"Super+WheelScrollRight".action = focus-column-right;
"Super+WheelScrollLeft".action = focus-column-left;

"Super+H".action = focus-column-left;
"Super+L".action = focus-column-right;
"Super+J".action = focus-workspace-down;
"Super+K".action = focus-workspace-up;
"Super+Left".action = focus-column-left;
"Super+Right".action = focus-column-right;
"Super+Down".action = focus-window-down;
"Super+Up".action = focus-window-up;

"Super+Print".action = screenshot-window;
"Super+Shift+Print".action = screenshot-screen;
"Super+Shift+S".action = screenshot;

"Super+Ctrl+H".action = move-column-left;
"Super+Ctrl+J".action = move-window-down;
"Super+Ctrl+K".action = move-window-up;
"Super+Ctrl+L".action = move-column-right;

"Super+U".action = move-workspace-down;
"Super+I".action = move-workspace-up;

"Super+Minus".action = set-column-width "-10%";
"Super+Equal".action = set-column-width "+10%";
"Super+Shift+Minus".action = set-window-height "-10%";
"Super+Shift+Equal".action = set-window-height "+10%";

"Super+Shift+H".action = focus-monitor-left;
"Super+Shift+J".action = focus-monitor-down;
"Super+Shift+K".action = focus-monitor-up;
"Super+Shift+L".action = focus-monitor-right;

"Super+Shift+Ctrl+H".action = move-column-to-monitor-left;
"Super+Shift+Ctrl+J".action = move-column-to-monitor-down;
"Super+Shift+Ctrl+K".action = move-column-to-monitor-up;
"Super+Shift+Ctrl+L".action = move-column-to-monitor-right;

"Super+R".action = switch-preset-column-width;
"Super+F".action = maximize-column;
"Super+Shift+F".action = fullscreen-window;
"Super+C".action = center-column;

"Mod+Q".action = close-window;

"Mod+Shift+P".action = power-off-monitors;
};

prefer-no-csd = true;
hotkey-overlay.skip-at-startup = true;
Expand Down
2 changes: 1 addition & 1 deletion home/rice/waybar/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ in {
format-icons = ["󰂃" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹"];
};
network = {
format-wifi = "󰤨 {essid} {signalStrength}";
format-wifi = "󰤨 {essid} {signalStrength}%";
format-ethernet = "󰈀";
format-alt = "󰤨";
format-disconnected = "󰤭";
Expand Down

0 comments on commit bc1af01

Please sign in to comment.