about summary refs log tree commit diff stats
path: root/modules/home.legacy/wms
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-10-18 17:07:46 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-10-18 17:07:46 +0200
commitc52c7f314ccadcc2fcd91e28c8fd1b88f6d5ce0c (patch)
treee8b947710b467b32740598ff574982097836f66c /modules/home.legacy/wms
parentchore(pkgs/yt): 1.2.1 -> 1.3.0 (diff)
downloadnixos-config-c52c7f314ccadcc2fcd91e28c8fd1b88f6d5ce0c.tar.gz
nixos-config-c52c7f314ccadcc2fcd91e28c8fd1b88f6d5ce0c.zip
refactor(modules): Move all system modules to `by-name`
From now on all modules should be added to the new `by-name` directory.
This should help remove the (superficial and utterly useless)
distinction between `home-manager` and `NixOS` modules.
Diffstat (limited to 'modules/home.legacy/wms')
-rw-r--r--modules/home.legacy/wms/default.nix7
-rw-r--r--modules/home.legacy/wms/plasma/default.nix5
-rw-r--r--modules/home.legacy/wms/river/default.nix76
-rwxr-xr-xmodules/home.legacy/wms/river/init.sh80
-rw-r--r--modules/home.legacy/wms/river/res/keys.ron58
-rw-r--r--modules/home.legacy/wms/river/res/moonlander.ron64
-rw-r--r--modules/home.legacy/wms/sway/default.nix16
7 files changed, 306 insertions, 0 deletions
diff --git a/modules/home.legacy/wms/default.nix b/modules/home.legacy/wms/default.nix
new file mode 100644
index 00000000..610ea2f4
--- /dev/null
+++ b/modules/home.legacy/wms/default.nix
@@ -0,0 +1,7 @@
+{config, ...}: {
+  imports = [
+    # ./sway
+    ./river
+    # ./plasma
+  ];
+}
diff --git a/modules/home.legacy/wms/plasma/default.nix b/modules/home.legacy/wms/plasma/default.nix
new file mode 100644
index 00000000..f68ee272
--- /dev/null
+++ b/modules/home.legacy/wms/plasma/default.nix
@@ -0,0 +1,5 @@
+{config, ...}: {
+  services.xserver.enable = true;
+  services.xserver.displayManager.sddm.enable = true;
+  services.xserver.desktopManager.plasma5.enable = true;
+}
diff --git a/modules/home.legacy/wms/river/default.nix b/modules/home.legacy/wms/river/default.nix
new file mode 100644
index 00000000..36a9ca74
--- /dev/null
+++ b/modules/home.legacy/wms/river/default.nix
@@ -0,0 +1,76 @@
+{
+  pkgs,
+  sysLib,
+  river_init_lesser,
+  nixosConfig,
+  system,
+  ...
+}: let
+  inherit (nixosConfig.networking) hostName;
+  mappings =
+    if hostName == "tiamat"
+    then ''
+      err_fail riverctl keyboard-layout 'us-modified'
+      err_fail river_init_lesser ~/.config/river/res/moonlander.ron
+    ''
+    else if hostName == "lahmu" || hostName == "apzu" || hostName == "mammun" || hostName == "isimud"
+    then ''
+      err_fail riverctl keyboard-layout 'dvorak-modified'
+      err_fail river_init_lesser ~/.config/river/res/keys.ron
+    ''
+    else builtins.throw "Host not covered in river mappings";
+  screen_setup =
+    if hostName == "lahmu"
+    then ''
+      err_fail wlr-randr --output Virtual-1 --mode 1920x1080
+    ''
+    else if hostName == "tiamat"
+    then ''
+      err_fail wlr-randr --output DP-2 --pos 2560,0
+      err_fail wlr-randr --output DP-1 --scale 1.5 --pos 0,0
+      err_fail gammastep &
+    ''
+    else if hostName == "apzu" || hostName == "mammun" || hostName == "isimud"
+    then ''
+      err_fail gammastep &
+    ''
+    else builtins.throw "Host not covered in river screen setup";
+  env_vars = "XDG_CURRENT_DESKTOP=river DESKTOP_SESSION=river";
+  init_scr = pkgs.substituteAll {
+    src = ./init.sh;
+    inherit mappings screen_setup env_vars;
+  };
+in {
+  home.sessionVariables = {
+    WM = "river";
+    XDG_CURRENT_DESKTOP = "river";
+    DESKTOP_SESSION = "river";
+  };
+
+  xdg.configFile."river/init".source =
+    sysLib.writeShellScript {
+      name = "river_init";
+      src = init_scr;
+      keepPath = true;
+      dependencies = builtins.attrValues {
+        river_init_lesser = river_init_lesser.packages.${system}.default;
+        inherit
+          (pkgs)
+          dash
+          river
+          glib # gnome lib
+          gammastep
+          wlr-randr
+          yambar
+          mako
+          swaybg
+          swayidle
+          swaylock
+          alacritty
+          ;
+      };
+    }
+    + /bin/river_init;
+
+  xdg.configFile."river/res".source = ./res;
+}
diff --git a/modules/home.legacy/wms/river/init.sh b/modules/home.legacy/wms/river/init.sh
new file mode 100755
index 00000000..06a2e2f4
--- /dev/null
+++ b/modules/home.legacy/wms/river/init.sh
@@ -0,0 +1,80 @@
+#!/usr/bin/env bash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH
+
+err_fail() {
+    if ! "$@"; then
+        warning "\"$*\" failed!\n" >>~/river_log
+        # msg "Executing the safe init!"
+        # exec ~/.config/river/res/safe_init.sh
+    fi
+}
+err_fail rm ~/river_log
+exec 1>>"$HOME"/river_log
+exec 2>>"$HOME"/river_log
+
+#trap err_fail ERR
+
+#Setup of environment variables {{{
+err_fail riverctl spawn "exec dbus-update-activation-environment --systemd SEATD_SOCK DISPLAY WAYLAND_DISPLAY DESKTOP_SESSION=river XDG_CURRENT_DESKTOP=river"
+export @env_vars@
+#}}}
+
+# Setup of mappings {{{
+@mappings@
+# }}}
+
+# Setup of Rules {{{
+err_fail riverctl rule-add -app-id float -title '*' float
+err_fail riverctl rule-add -app-id mpv -title '*' float
+err_fail riverctl rule-add -app-id ModernGL -title '*' float
+err_fail riverctl rule-add -app-id '*' -title 'Manim Slides' float
+err_fail riverctl rule-add -app-id '*' -title 'floating please' float
+
+err_fail riverctl rule-add -app-id '*' -title '*' ssd
+err_fail riverctl rule-add -app-id firefox -title '*' csd # This remove the focus border around Firefox (which is useful because the Firefox is nearly always in its own tag.)
+# }}}
+
+# Set riverctl settings {{{
+# background
+err_fail riverctl background-color 0x002b36
+err_fail riverctl border-color-focused 0x93a1a1
+err_fail riverctl border-color-unfocused 0x586e75
+
+# keyboard repeat rate
+err_fail riverctl set-repeat 50 300
+
+# Cursor
+err_fail riverctl focus-follows-cursor normal
+#riverctl hide-cursor timeout 2000
+err_fail riverctl hide-cursor when-typing enabled
+err_fail riverctl set-cursor-warp on-output-change
+err_fail riverctl xcursor-theme Nordzy-cursors 24
+
+err_fail riverctl input pointer-1133-49970-Logitech_Gaming_Mouse_G502 pointer-accel 0
+err_fail riverctl input pointer-1133-49970-Logitech_Gaming_Mouse_G502 accel-profile none
+
+err_fail riverctl input pointer-12951-6505-ZSA_Technology_Labs_Moonlander_Mark_I pointer-accel 0
+err_fail riverctl input pointer-12951-6505-ZSA_Technology_Labs_Moonlander_Mark_I accel-profile none
+# }}}
+
+# Setup of general apps {{{
+@screen_setup@
+
+err_fail yambar &
+
+err_fail mako &
+err_fail swaybg -i "$WALLPAPER" &
+err_fail swayidle &
+err_fail alacritty &
+# }}}
+
+# Setup of layout [acts as exec!] {{{
+err_fail riverctl default-layout rivertile
+@env_vars@ rivertile -main-ratio 0.5 -view-padding 1 -outer-padding 0
+
+#riverctl default-layout luatile
+#river-luatile
+# }}}
+# vim: ft=sh
diff --git a/modules/home.legacy/wms/river/res/keys.ron b/modules/home.legacy/wms/river/res/keys.ron
new file mode 100644
index 00000000..a2bc0fa1
--- /dev/null
+++ b/modules/home.legacy/wms/river/res/keys.ron
@@ -0,0 +1,58 @@
+#![enable(implicit_some)]
+RiverctlCommandArray(
+    commands: [
+    // Focus change
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "T",                       mods: "Super",          command: "focus-view",          command_args: "next",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "N",                       mods: "Super",          command: "focus-view",          command_args: "previous",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "T",                       mods: "Super+Control",  command: "focus-output",        command_args: "next",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "N",                       mods: "Super+Control",  command: "focus-output",        command_args: "previous",),
+
+    // Standard program
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "Return",                  mods: "Super",          command: "spawn",               command_args: "alacritty",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "q",                       mods: "Super+Shift",    command: "exit",                command_args: None,),
+
+    // Screenshot
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "Print",                   mods: "None",           command: "spawn",               command_args: "screenshot_persistent",),
+
+    // Audio
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "XF86AudioRaiseVolume",    mods: "None",           command: "spawn",               command_args: "pactl set-sink-volume 1 +5%",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal", "locked"], key: "XF86AudioLowerVolume",    mods: "None",           command: "spawn",               command_args: "pactl set-sink-volume 1 -5%",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal", "locked"], key: "XF86AudioMute",           mods: "None",           command: "spawn",               command_args: "mpc toggle",),
+
+    // Launcher
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "R",                       mods: "Super",          command: "spawn",               command_args: "rofi -show combi -modes combi -combi-modes 'window,drun,run' -show-icons",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "F1",                      mods: "Super",          command: "spawn",               command_args: "neorg dmenu",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "F2",                      mods: "Super",          command: "spawn",               command_args: "keepassxc",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "F3",                      mods: "Super",          command: "spawn",               command_args: "signal-desktop",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "F4",                      mods: "Super",          command: "spawn",               command_args: "steam",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "L",                       mods: "Super",          command: "spawn",               command_args: "lock",),
+
+    // Client
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "f",                       mods: "Super",          command: "toggle-fullscreen",   command_args: None,),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "c",                       mods: "Super+Shift",    command: "close",               command_args: None,),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "space",                   mods: "Super+Control",  command: "toggle-float",        command_args: None,),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "Return",                  mods: "Super+Control",  command: "zoom",                command_args: None,),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "o",                       mods: "Super",          command: "send-to-output",      command_args: "next",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "T",                       mods: "Super+Shift",    command: "swap",                command_args: "next",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "N",                       mods: "Super+Shift",    command: "swap",                command_args: "previous",),
+
+    // Toggle all tags
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "0",                       mods: "Super",          command: "set-focused-tags",    command_args: "4294967295"),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "0",                       mods: "Super+Shift",    command: "set-view-tags",       command_args: "4294967295"),
+
+    // Mouse
+    RiverctlCommand( map_mode: MapMouse,    mode: ["normal"],           key: "BTN_LEFT",                mods: "Super",          command: "move-view",           command_args: None,),
+    RiverctlCommand( map_mode: MapMouse,    mode: ["normal"],           key: "BTN_RIGHT",               mods: "Super",          command: "resize-view",         command_args: None,),
+
+    ],
+    // Set these mappings for the tags 0-8 with key [1-9]
+    tags_number: 9,
+    tag_commands: [
+    RiverctlTagCommand( map_mode: Map, mode: ["normal"], mods: "Super",                 command: "set-focused-tags",),
+    RiverctlTagCommand( map_mode: Map, mode: ["normal"], mods: "Super+Shift",           command: "set-view-tags",),
+    RiverctlTagCommand( map_mode: Map, mode: ["normal"], mods: "Super+Control",         command: "toggle-focused-tags",),
+    RiverctlTagCommand( map_mode: Map, mode: ["normal"], mods: "Super+Shift+Control",   command: "toggle-view-tags",),
+    ],
+)
+
+// vim: nolinebreak nowrap textwidth=0
diff --git a/modules/home.legacy/wms/river/res/moonlander.ron b/modules/home.legacy/wms/river/res/moonlander.ron
new file mode 100644
index 00000000..77ffa5c4
--- /dev/null
+++ b/modules/home.legacy/wms/river/res/moonlander.ron
@@ -0,0 +1,64 @@
+#![enable(implicit_some)]
+RiverctlCommandArray(
+    // TODO: add toggle-focus mapping
+    commands: [
+    // Movement
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "A", mods: "Alt+Control+Super+Shift", command: "exit",                 command_args: None,),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "B", mods: "Alt+Control+Super+Shift", command: "close",                command_args: None,),
+
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "C", mods: "Alt+Control+Super+Shift", command: "focus-view",           command_args: "previous",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "D", mods: "Alt+Control+Super+Shift", command: "focus-view",           command_args: "next",),
+
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "E", mods: "Alt+Control+Super+Shift", command: "swap",                 command_args: "previous",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "F", mods: "Alt+Control+Super+Shift", command: "swap",                 command_args: "next",),
+
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "G", mods: "Alt+Control+Super+Shift", command: "zoom",                 command_args: None,),
+
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "H", mods: "Alt+Control+Super+Shift", command: "toggle-fullscreen",    command_args: None,),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "I", mods: "Alt+Control+Super+Shift", command: "toggle-float",         command_args: None,),
+
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "J", mods: "Alt+Control+Super+Shift", command: "send-to-output",       command_args: "next",),
+
+
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "K", mods: "Alt+Control+Super+Shift", command: "spawn",                command_args: "alacritty",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "L", mods: "Alt+Control+Super+Shift", command: "spawn",                command_args: "screenshot_persistent",),
+
+    // Audio
+    // RiverctlCommand( map_mode: Map,         mode: ["normal", "locked"], key: "M", mods: "Alt+Control+Super+Shift", command: "spawn",                command_args: "video-pause toggle",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal", "locked"], key: "N", mods: "Alt+Control+Super+Shift", command: "spawn",                command_args: "mpc toggle",),
+
+    // Launcher
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "O", mods: "Alt+Control+Super+Shift", command: "spawn",                command_args: "rofi -show combi -modes combi -combi-modes 'window,drun,run' -show-icons",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "P", mods: "Alt+Control+Super+Shift", command: "spawn",                command_args: "neorg dmenu",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "Q", mods: "Alt+Control+Super+Shift", command: "spawn",                command_args: "keepassxc",),
+    // RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "R", mods: "Alt+Control+Super+Shift", command: "spawn",                command_args: "nheko",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "S", mods: "Alt+Control+Super+Shift", command: "spawn",                command_args: "signal-desktop",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "T", mods: "Alt+Control+Super+Shift", command: "spawn",                command_args: "lock",),
+
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "U", mods: "Alt+Control+Super+Shift", command: "focus-output",         command_args: "next",),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "V", mods: "Alt+Control+Super+Shift", command: "focus-previous-tags",  command_args: None,),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "W", mods: "Alt+Control+Super+Shift", command: "send-to-previous-tags",command_args: None,),
+    //RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "X", mods: "Alt+Control+Super+Shift", command: "spawn",               command_args: "bemenu-run",),
+    //RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "Y", mods: "Alt+Control+Super+Shift", command: "spawn",               command_args: "bemenu-run",),
+    //RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "Z", mods: "Alt+Control+Super+Shift", command: "spawn",               command_args: "bemenu-run",),
+
+
+    // Toggle all tags
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "0", mods: "Alt+Control+Super+Shift", command: "set-focused-tags",    command_args: "4294967295"),
+    RiverctlCommand( map_mode: Map,         mode: ["normal"],           key: "0", mods: "Alt+Control+Shift",       command: "set-view-tags",       command_args: "4294967295"),
+
+    // Mouse
+    RiverctlCommand( map_mode: MapMouse,    mode: ["normal"],           key: "BTN_LEFT",                mods: "Super",          command: "move-view",           command_args: None,),
+    RiverctlCommand( map_mode: MapMouse,    mode: ["normal"],           key: "BTN_RIGHT",               mods: "Super",          command: "resize-view",         command_args: None,),
+    ],
+
+    // Set these mappings for the tags 0-8 with key [1-9]
+    tags_number: 9,
+    tag_commands: [
+        RiverctlTagCommand( map_mode: Map, mode: ["normal"], mods: "Alt+Control+Super+Shift", command: "set-focused-tags",),
+        RiverctlTagCommand( map_mode: Map, mode: ["normal"], mods: "Alt+Control+Shift",       command: "set-view-tags",),
+        // TODO: RiverctlTagCommand( map_mode: Map, mode: ["normal"], mods: "Super+Control",         command: "toggle-focused-tags",),
+        // TODO: RiverctlTagCommand( map_mode: Map, mode: ["normal"], mods: "Super+Shift+Control",   command: "toggle-view-tags",),
+    ],
+)
+// vim: nolinebreak nowrap textwidth=0
diff --git a/modules/home.legacy/wms/sway/default.nix b/modules/home.legacy/wms/sway/default.nix
new file mode 100644
index 00000000..bb3ddb49
--- /dev/null
+++ b/modules/home.legacy/wms/sway/default.nix
@@ -0,0 +1,16 @@
+# also requires:
+# security.polkit.enable = true;
+{lib, ...}: {
+  wayland.windowManager.sway = {
+    enable = true;
+    config = {
+      modifier = "Mod4";
+      # Use kitty as default terminal
+      terminal = "kitty";
+      startup = [
+        # Launch Firefox on start
+        {command = "firefox";}
+      ];
+    };
+  };
+}