system/modules/home-manager/configs/window-manager/river/default.nix

95 lines
2.4 KiB
Nix
Raw Normal View History

2024-04-23 18:17:06 +03:00
{ config, pkgs, lib, ... }:
let
cfg = config.local.window-manager.river;
pow = n: exp:
if exp == 1 then n
else if exp == 0 then 1
else n * pow n (exp - 1);
tile-cmd = c: ''send-layout-cmd rivertile "${c}"'';
in
{
options.local.window-manager.river = with lib; {
enable = mkEnableOption "river window manager";
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs.unstable; [
wl-clipboard
dmenu-wayland
];
wayland.windowManager.river = {
enable = true;
package = pkgs.unstable.river;
systemd.enable = true;
xwayland.enable = true;
settings = {
background-color = "0x002b36";
border-color-focused = "0x93a1a1";
border-color-unfocused = "0x586e75";
set-repeat = "50 300";
map.normal = lib.mkMerge (lib.flatten [
{
"Alt+Shift Return" = "spawn foot";
"Alt P" = "spawn dmenu-wl_run";
"Alt Space" = "toggle-fullscreen";
"Super+Shift C" = "close";
# system
"Super L" = "spawn waylock";
"Super+Shift Q" = "exit";
}
(lib.flip lib.mapAttrsToList { K = "previous"; J = "next"; } (k: d:
{
# focus window
"Alt ${k}" = "focus-view ${d}";
# swap windows
"Alt+Shift ${k}" = "swap ${d}";
}
))
# decrease/increase the main ration
{
"Alt H" = tile-cmd "main-ratio -0.01";
"Alt L" = tile-cmd "main-ratio +0.01";
"Alt Comma" = tile-cmd "main-count +1";
"Alt Period" = tile-cmd "main-count -1";
}
(lib.flip map [ 1 2 3 4 5 6 7 8 9 ] (i:
let wid = i - 1; in
let wtag = pow 2 wid; in
{
"Alt ${toString i}" = "set-focused-tags ${toString wtag}";
# set-view-tags ${wtag}
# toggle-focused-tags ${wtag}
# toggle-view-tags ${wtag}
}
))
]);
};
extraConfig = (
let kb = config.home.keyboard; in ''
riverctl keyboard-layout \
-model ${kb.model} \
-variant ${kb.variant} \
-options ${lib.head kb.options} \
${kb.layout}
riverctl default-layout rivertile
rivertile -view-padding 6 -outer-padding 6 &
''
);
};
};
}