NixOS-Config/modules/home/wms/niri/hotkeys/default.nix

158 lines
7.4 KiB
Nix

{ pkgs, config, ... }:
{
config.home.niri.settings.hotkeys = let
primeMod = "Mod";
secMod = "Alt";
resizeAmount = "5";
in pkgs.writeText "hotkeys" ''
binds {
//// Launchers
// Browser
${primeMod}+F1 { spawn "sh" "-c" "librewolf -p Main --name MainBrowser | notify-send \"Main Browser\""; }
${primeMod}+F2 { spawn "sh" "-c" "librewolf -p Alt --name AltBrowser | notify-send \"Alternate Browser\""; }
${primeMod}+F3 { spawn "sh" "-c" "librewolf -p Misc --name MiscBrowser | notify-send \"Miscellaneous Browser\""; }
// Virtual machines
${primeMod}+F4 { spawn "sh" "-c" "virt-manager | notify-send \"Virtual Machines\""; }
${primeMod}+F5 { spawn "sh" "-c" "looking-glass-client input:rawMouse=yes | notify-send \"Looking Glass\""; }
// Prime + key
${primeMod}+s { spawn "sh" "-c" "rofi -show run -p Command"; }
${primeMod}+c { spawn "sh" "-c" "clipman pick -t rofi"; }
${primeMod}+x { spawn "sh" "-c" "rofiscripts --power"; }
${primeMod}+b { spawn "sh" "-c" "pkill -USR1 waybar"; }
${primeMod}+Return { spawn "sh" "-c" "foot"; }
// Prime + shift + key
${primeMod}+Shift+s { spawn "sh" "-c" "rofi -show drun -modi drun -drun-display-format {name} -show-icons -disable-history"; }
${primeMod}+Shift+t { spawn "sh" "-c" "pcmanfm"; }
${primeMod}+Shift+e { spawn "sh" "-c" "bemoji -n -P 0"; }
${primeMod}+Shift+b { spawn "sh" "-c" "rofi-bluetooth"; }
${primeMod}+Shift+Return { spawn "sh" "-c" "foot ranger"; }
// Prime + ctrl + key
${primeMod}+Ctrl+s { spawn "sh" "-c" "rofiscripts --scratchpads"; }
${primeMod}+Ctrl+c { spawn "sh" "-c" "wlpicker && notify-send \"Color copied to clipboard\""; }
//// Media
// Volume
${secMod}+j { spawn "sh" "-c" "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"; }
${secMod}+k { spawn "sh" "-c" "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+"; }
// MPD
${primeMod}+Backslash { spawn "sh" "-c" "mpc toggle"; }
${secMod}+Shift+h { spawn "sh" "-c" "mpc prev"; }
${secMod}+Shift+j { spawn "sh" "-c" "mpc volume -3"; }
${secMod}+Shift+k { spawn "sh" "-c" "mpc volume +3"; }
${secMod}+Shift+l { spawn "sh" "-c" "mpc next"; }
//// Miscellaneous
// Notifications
${primeMod}+n { spawn "sh" "-c" "makotoggle"; }
${primeMod}+Shift+n { spawn "sh" "-c" "makoctl restore"; }
${primeMod}+Ctrl+n { spawn "sh" "-c" "makoctl dismiss -a"; }
// Screenshots
${secMod}+F { screenshot; }
${secMod}+Shift+F { screenshot-screen; }
${secMod}+Ctrl+F { screenshot-window; }
// Display and keyboard brightness
${primeMod}+equal { spawn "sh" "-c" "light -A 5"; }
${primeMod}+minus { spawn "sh" "-c" "light -U 5"; }
${primeMod}+Shift+equal { spawn "sh" "-c" "light -A 1"; }
${primeMod}+Shift+minus { spawn "sh" "-c" "light -U 1"; }
XF86KbdBrightnessUp { spawn "sh" "-c" "light -s sysfs/leds/smc::kbd_backlight -A 5"; }
XF86KbdBrightnessDown { spawn "sh" "-c" "light -s sysfs/leds/smc::kbd_backlight -U 5"; }
//// Window manager
${primeMod}+q { close-window; }
// Switch to workspaces
${primeMod}+grave { focus-workspace "${config.ws.w0}"; }
${primeMod}+1 { focus-workspace "${config.ws.w1}"; }
${primeMod}+2 { focus-workspace "${config.ws.w2}"; }
${primeMod}+3 { focus-workspace "${config.ws.w3}"; }
${primeMod}+4 { focus-workspace "${config.ws.w4}"; }
${primeMod}+5 { focus-workspace "${config.ws.w5}"; }
${primeMod}+6 { focus-workspace "${config.ws.w6}"; }
${primeMod}+7 { focus-workspace "${config.ws.w7}"; }
${primeMod}+8 { focus-workspace "${config.ws.w8}"; }
${primeMod}+9 { focus-workspace "${config.ws.w9}"; }
// Switch to alternate workspaces
${secMod}+F1 { focus-workspace "${config.ws.w1a}"; }
${secMod}+F2 { focus-workspace "${config.ws.w2a}"; }
${secMod}+F3 { focus-workspace "${config.ws.w3a}"; }
${secMod}+F4 { focus-workspace "${config.ws.w4a}"; }
${secMod}+F5 { focus-workspace "${config.ws.w5a}"; }
${secMod}+F6 { focus-workspace "${config.ws.w6a}"; }
${secMod}+F7 { focus-workspace "${config.ws.w7a}"; }
${secMod}+F8 { focus-workspace "${config.ws.w8a}"; }
${secMod}+F9 { focus-workspace "${config.ws.w9a}"; }
// Move window to and focus workspace
${primeMod}+Shift+grave { move-window-to-workspace "${config.ws.w0}"; }
${primeMod}+Shift+1 { move-window-to-workspace "${config.ws.w1}"; }
${primeMod}+Shift+2 { move-window-to-workspace "${config.ws.w2}"; }
${primeMod}+Shift+3 { move-window-to-workspace "${config.ws.w3}"; }
${primeMod}+Shift+4 { move-window-to-workspace "${config.ws.w4}"; }
${primeMod}+Shift+5 { move-window-to-workspace "${config.ws.w5}"; }
${primeMod}+Shift+6 { move-window-to-workspace "${config.ws.w6}"; }
${primeMod}+Shift+7 { move-window-to-workspace "${config.ws.w7}"; }
${primeMod}+Shift+8 { move-window-to-workspace "${config.ws.w8}"; }
${primeMod}+Shift+9 { move-window-to-workspace "${config.ws.w9}"; }
// Move window to and focus workspace
${secMod}+Shift+F1 { move-window-to-workspace "${config.ws.w1a}"; }
${secMod}+Shift+F2 { move-window-to-workspace "${config.ws.w2a}"; }
${secMod}+Shift+F3 { move-window-to-workspace "${config.ws.w3a}"; }
${secMod}+Shift+F4 { move-window-to-workspace "${config.ws.w4a}"; }
${secMod}+Shift+F5 { move-window-to-workspace "${config.ws.w5a}"; }
${secMod}+Shift+F6 { move-window-to-workspace "${config.ws.w6a}"; }
${secMod}+Shift+F7 { move-window-to-workspace "${config.ws.w7a}"; }
${secMod}+Shift+F8 { move-window-to-workspace "${config.ws.w8a}"; }
${secMod}+Shift+F9 { move-window-to-workspace "${config.ws.w9a}"; }
// Change focused window
${primeMod}+h { focus-column-or-monitor-left; }
${primeMod}+j { focus-window-down; }
${primeMod}+k { focus-window-up; }
${primeMod}+l { focus-column-or-monitor-right; }
// Move focused window
${primeMod}+Shift+h { move-column-left-or-to-monitor-left; }
${primeMod}+Shift+j { move-window-down; }
${primeMod}+Shift+k { move-window-up; }
${primeMod}+Shift+l { move-column-right-or-to-monitor-right; }
// Resize window
${primeMod}+${secMod}+h { set-column-width "-${resizeAmount}%"; }
${primeMod}+${secMod}+j { set-window-height "-${resizeAmount}%"; }
${primeMod}+${secMod}+k { set-window-height "+${resizeAmount}%"; }
${primeMod}+${secMod}+l { set-column-width "+${resizeAmount}%"; }
// There are also commands that consume or expel a single window to the side.
${primeMod}+Ctrl+h { consume-or-expel-window-left; }
${primeMod}+Ctrl+l { consume-or-expel-window-right; }
// Toggle fullscreen
${primeMod}+f { maximize-column; }
${primeMod}+Shift+f { fullscreen-window; }
// Column functions
${primeMod}+r { switch-preset-column-width; }
${primeMod}+Shift+r { reset-window-height; }
${primeMod}+Shift+c { center-column; }
// Move these into scratchpads if or when they get supported
${primeMod}+Shift+Backslash { spawn "sh" "-c" "foot btop"; }
${primeMod}+Shift+m { spawn "sh" "-c" "foot ncmpcpp"; }
${primeMod}+Shift+v { spawn "sh" "-c" "foot pulsemixer"; }
}
'';
}