From fe2d77e66d42f389a03444e95e8636d95e99340c Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Mon, 26 Sep 2022 16:02:29 +0200 Subject: [PATCH] more river wm things --- home/capibara.nix | 1 + home/desktop-river/default.nix | 12 ++++ home/desktop-river/init.nix | 115 +++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 home/desktop-river/default.nix create mode 100644 home/desktop-river/init.nix diff --git a/home/capibara.nix b/home/capibara.nix index 5b91da2..af54d40 100644 --- a/home/capibara.nix +++ b/home/capibara.nix @@ -4,4 +4,5 @@ imports = # [ ./nixos-common.nix ./desktop-sway ./alacritty/capibara.nix ./theming ]; [ ./nixos-common.nix ./desktop-xmonad/capibara.nix ./alacritty/capibara.nix ./theming ]; + # [ ./nixos-common.nix ./desktop-river ./alacritty/capibara.nix ./theming ]; } diff --git a/home/desktop-river/default.nix b/home/desktop-river/default.nix new file mode 100644 index 0000000..d7996cc --- /dev/null +++ b/home/desktop-river/default.nix @@ -0,0 +1,12 @@ +{ config, pkgs, ... }: + +{ + imports = [ ./init.nix ]; + + home.packages = with pkgs; [ river foot ]; + + programs.zsh.loginExtra = '' + [[ -z "''${DISPLAY}" ]] && [[ "$(tty)" = "/dev/tty1" ]] && \ + exec ${pkgs.river}/bin/river + ''; +} diff --git a/home/desktop-river/init.nix b/home/desktop-river/init.nix new file mode 100644 index 0000000..36b7bd4 --- /dev/null +++ b/home/desktop-river/init.nix @@ -0,0 +1,115 @@ +{ config, pkgs, ... }: + +let + shell = "${pkgs.dash}/bin/dash"; + riverctl = "${pkgs.river}/bin/riverctl"; + rivertile = "${pkgs.river}/bin/rivertile"; + foot = "${pkgs.foot}/bin/foot"; + seq = "${pkgs.coreutils}/bin/seq"; +in { + home.file.river_init = { + executable = true; + target = "${config.xdg.configHome}/river/init"; + text = '' + + # start an instance of foot + ${riverctl} map normal Super Return spawn ${foot} + + # close the focused view + ${riverctl} map normal Super+Shift C close + + # exit river + ${riverctl} map normal Super+Shift Escape exit + + # focus next/previous + ${riverctl} map normal Super J focus-view next + ${riverctl} map normal Super K focus-view previous + + # swap next/previous + ${riverctl} map normal Super+Shift J swap next + ${riverctl} map normal Super+Shift K swap previous + + # bump focused view to the top of the stack layout + ${riverctl} map normal Super+Shift Return zoom + + # increase/decrease the main ratio of rivertile + ${riverctl} map normal Super H send-layout-cmd ${rivertile} "main-ratio -0.05" + ${riverctl} map normal Super L send-layout-cmd ${rivertile} "main-ratio +0.05" + + # increase/decrease the main count of rivertile + ${riverctl} map normal Super+Shift H send-layout-cmd ${rivertile} "main-count +1" + ${riverctl} map normal Super+Shift L send-layout-cmd ${rivertile} "main-count -1" + + # move views + ${riverctl} map normal Super+Alt H move left 100 + ${riverctl} map normal Super+Alt J move down 100 + ${riverctl} map normal Super+Alt K move up 100 + ${riverctl} map normal Super+Alt L move right 100 + + # snap views to screen edges + ${riverctl} map normal Super+Alt+Control H snap left + ${riverctl} map normal Super+Alt+Control J snap down + ${riverctl} map normal Super+Alt+Control K snap up + ${riverctl} map normal Super+Alt+Control L snap right + + # resize views + ${riverctl} map normal Super+Alt+Shift H resize horizontal -100 + ${riverctl} map normal Super+Alt+Shift J resize vertical 100 + ${riverctl} map normal Super+Alt+Shift K resize vertical -100 + ${riverctl} map normal Super+Alt+Shift L resize horizontal 100 + + # move/resize with mouse + ${riverctl} map-pointer normal Super BTN_LEFT move-view + ${riverctl} map-pointer normal Super BTN_RIGHT resize-view + + ${rivertile} -view-padding 6 -outer-padding 6 + + for i in $(${seq} 1 9); do + tags=$((1 << ($i - 1))) + + # focus tag [0-8] + ${riverctl} map normal Super $i set-focused-tags $tags + + # tag focused view with tag [0-8] + ${riverctl} map normal Super+Shift $i set-view-tags $tags + + # toggle focus of tag [0-8] + ${riverctl} map normal Super+Control $i toggle-focused-tags $tags + + # toggle tag [0-8] of focused view + ${riverctl} map normal Super+Shift+Control $i toggle-view-tags $tags + done + + all_tags=$(((1 << 32) - 1)) + # focus all tags + ${riverctl} map normal Super 0 set-focused-tags $all_tags + # tag focused view with all tags + ${riverctl} map normal Super+Shift 0 set-view-tags $all_tags + + # toggle float + ${riverctl} map normal Super T toggle-float + + # toggle fullscreen + ${riverctl} map normal Super M toggle-fullscreen + + # Super+{Up,Right,Down,Left} to change layout orientation + ${riverctl} map normal Super Up send-layout-cmd ${rivertile} "main-location top" + ${riverctl} map normal Super Right send-layout-cmd ${rivertile} "main-location right" + ${riverctl} map normal Super Down send-layout-cmd ${rivertile} "main-location bottom" + ${riverctl} map normal Super Left send-layout-cmd ${rivertile} "main-location left" + + # Declare a passthrough mode. This mode has only a single mapping to return to + # normal mode. This makes it useful for testing a nested wayland compositor + ${riverctl} declare-mode passthrough + + # Super+F11 to enter passthrough mode + ${riverctl} map normal Super F11 enter-mode passthrough + + # Super+F11 to return to normal mode + ${riverctl} map passthrough Super F11 enter-mode normal + + ${riverctl} default-layout rivertile + ${rivertile} -view-padding 6 -outer-padding 6 + ''; + }; +}