{ pkgs, config, lib, ... }: with lib; let cfg = config.eboskma.programs.river; mod = "Mod4"; lockcmd = "${pkgs.swaylock}/bin/swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --image ${cfg.wallpaper} --scaling fill"; rofiPower = pkgs.writeShellScriptBin "rofi-power" ( builtins.replaceStrings [ "{WALLPAPER}" ] [ (builtins.toString cfg.wallpaper) ] ( builtins.readFile ./powermenu.sh ) ); menu = "${config.programs.anyrun.package}/bin/anyrun"; directions = { left = "n"; down = "e"; up = "i"; right = "o"; }; catppuccin = { rosewater = "0xf5e0dc"; flamingo = "0xf2cdcd"; pink = "0xf5c2e7"; mauve = "0xcba6f7"; red = "0xf38ba8"; maroon = "0xeba0ac"; peach = "0xfab387"; yellow = "0xf9e2af"; green = "0xa6e3a1"; teal = "0x94e2d5"; sky = "0x89dceb"; sapphire = "0x74c7ec"; blue = "0x89b4fa"; lavender = "0xb4befe"; text = "0xcdd6f4"; subtext1 = "0xbac2de"; subtext0 = "0xa6adc8"; overlay2 = "0x9399b2"; overlay1 = "0x7f849c"; overlay0 = "0x6c7086"; surface2 = "0x585b70"; surface1 = "0x45475a"; surface0 = "0x313244"; base = "0x1e1e2e"; mantle = "0x181825"; crust = "0x11111b"; }; bit = b: (foldl (x: _: x * 2) 1 (builtins.genList (n: n + 1) b)); tags = map (num: { value = bit num; index = toString (num + 1); }) (builtins.genList (n: n) 9); in { options.eboskma.programs.river = { enable = mkEnableOption "river"; package = mkPackageOption pkgs "river" { }; wallpaper = mkOption { description = "Desired wallpaper"; type = types.path; }; }; config = mkIf cfg.enable { wayland.windowManager.river = { enable = true; settings = { declare-mode = [ "normal" "locked" "passthrough" ]; input = { pointer-1390-268-ELECOM_TrackBall_Mouse_HUGE_TrackBall = { accel-profile = "adaptive"; natural-scroll = "enabled"; }; }; hide-cursor = "when-typing enabled"; set-cursor-warp = "on-output-change"; keyboard-layout-file = toString ./keyboard-layout; map = { normal = { "${mod} Return" = "spawn ${pkgs.foot}/bin/foot"; "${mod}+Shift q" = "close"; "${mod} s" = "spawn ${menu}"; "${mod} ${directions.left}" = "focus-view left"; "${mod} ${directions.right}" = "focus-view right"; "${mod} ${directions.up}" = "focus-view up"; "${mod} ${directions.down}" = "focus-view down"; "${mod}+Shift ${directions.left}" = "move left"; "${mod}+Shift ${directions.right}" = "move right"; "${mod}+Shift ${directions.up}" = "move up"; "${mod}+Shift ${directions.down}" = "move down"; "${mod}+Control ${directions.left}" = "snap left"; "${mod}+Control ${directions.right}" = "snap right"; "${mod}+Control ${directions.up}" = "snap up"; "${mod}+Control ${directions.down}" = "snap down"; "${mod} a" = "zoom"; "${mod}+Shift Space" = "toggle-float"; "${mod} t" = "toggle-fullscreen"; # Scratchpad "${mod}+Shift minus" = "toggle-view-tags ${toString (bit 20)}"; "${mod} minus" = "toggle-focused-tags ${toString (bit 20)}"; "${mod} Print" = "spawn '${pkgs.grim}/bin/grim'"; "${mod} l" = "spawn '${lockcmd}'"; # Enable passthrough mode "${mod} Pause" = "enter-mode passthrough"; "None XF86AudioRaiseVolume" = "spawn '${pkgs.pamedia}/bin/pamedia up'"; "None XF86AudioLowerVolume" = "spawn '${pkgs.pamedia}/bin/pamedia down'"; "None XF86AudioMute" = "spawn '${pkgs.pamedia}/bin/pamedia mute'"; "None XF86Calculator" = "spawn ${pkgs.gnome.gnome-calculator}/bin/gnome-calculator"; "${mod} c" = mkIf config.eboskma.programs.emacs.enable "spawn '${config.eboskma.programs.emacs.package}/bin/emacsclient -c'"; "${mod} d" = "spawn '${pkgs.swaynotificationcenter}/bin/swaync-client --toggle-panel --skip-wait'"; "${mod}+Shift d" = "spawn '${pkgs.swaynotificationcenter}/bin/swaync-client --toggle-dnd --skip-wait'"; "${mod}+Shift f" = "spawn ${rofiPower}/bin/rofi-power"; "${mod}+Shift+Alt ${directions.left}" = "send-layout-cmd rivertile 'main-ratio -0.05'"; "${mod}+Shift+Alt ${directions.right}" = "send-layout-cmd rivertile 'main-ratio +0.05'"; "${mod}+Shift+Control ${directions.left}" = "send-layout-cmd rivertile 'main-location left'"; "${mod}+Shift+Control ${directions.right}" = "send-layout-cmd rivertile 'main-location right'"; "${mod}+Shift+Control ${directions.up}" = "send-layout-cmd rivertile 'main-location top'"; "${mod}+Shift+Control ${directions.down}" = "send-layout-cmd rivertile 'main-location bottom'"; } // builtins.listToAttrs ( map (tag: { name = "${mod} ${toString tag.index}"; value = "set-focused-tags ${toString tag.value}"; }) tags ) // builtins.listToAttrs ( map (tag: { name = "${mod}+Control ${toString tag.index}"; value = "toggle-view-tags ${toString tag.value}"; }) tags ) // builtins.listToAttrs ( map (tag: { name = "${mod}+Shift ${toString tag.index}"; value = "set-view-tags ${toString tag.value}"; }) tags ); passthrough = { "${mod} Pause" = "enter-mode normal"; }; }; map-pointer = { normal = { "${mod} BTN_LEFT" = "move-view"; "${mod} BTN_RIGHT" = "resize-view"; }; }; spawn-tagmask = toString (builtins.bitXor ((bit 32) - 1) (bit 20)); spawn = [ # "'${ewwDaemon} --restart open bar-home'" "'${pkgs.swaybg}/bin/swaybg --image ${cfg.wallpaper} --mode fill'" ]; rule-add = { "-app-id" = { "org.gnome.Calculator" = "float"; }; }; default-layout = "rivertile"; border-width = 1; border-color-focused = catppuccin.lavender; border-color-unfocused = catppuccin.overlay0; border-color-urgent = catppuccin.peach; # target title bg text indicator border # client.focused $lavender $base $text $rosewater $lavender # client.focused_inactive $overlay0 $base $text $rosewater $overlay0 # client.unfocused $overlay0 $base $text $rosewater $overlay0 # client.urgent $peach $base $peach $overlay0 $peach # client.placeholder $overlay0 $base $text $overlay0 $overlay0 # client.background $base }; extraConfig = '' ${cfg.package}/bin/rivertile -view-padding 10 -outer-padding 5 & ''; }; }; }