diff --git a/hosts/fwbook.nix b/hosts/fwbook.nix index c10ff43..6fa3442 100644 --- a/hosts/fwbook.nix +++ b/hosts/fwbook.nix @@ -39,7 +39,10 @@ in crypto.enable = true; tiler = { enable = true; - niri.enable = true; + niri = { + enable = true; + touchscreen-gestures.enable = true; + }; }; }; }; @@ -231,8 +234,6 @@ in hermes-agent.packages.${pkgs.stdenv.hostPlatform.system}.desktop hermes-agent.packages.${pkgs.stdenv.hostPlatform.system}.default - # My Own - niri-touchscreen-gestures ]); services.usbmuxd.enable = true; services.flatpak.packages = [ diff --git a/modules/nixos/desktop/tiler/ABOUTME.md b/modules/nixos/desktop/tiler/ABOUTME.md index fb6b185..b129baf 100644 --- a/modules/nixos/desktop/tiler/ABOUTME.md +++ b/modules/nixos/desktop/tiler/ABOUTME.md @@ -9,9 +9,10 @@ of Wayland control/capture tools. Each compositor module turns this on automatic ``` tiler/ ├── default.nix # skyg.nixos.desktop.tiler.enable — DMS, keyring, polkit, shared packages -├── niri.nix # skyg.nixos.desktop.tiler.niri — niri compositor (sets tiler.enable) -├── hyprland.nix # skyg.nixos.desktop.tiler.hyprland — Hyprland (sets tiler.enable) -└── swww.nix # skyg.nixos.desktop.tiler.background — swww/waypaper wallpaper tools +├── niri.nix # skyg.nixos.desktop.tiler.niri — niri compositor (sets tiler.enable) +├── niri-touchscreen-gestures.nix # skyg.nixos.desktop.tiler.niri.touchscreen-gestures — touchscreen swipe support +├── hyprland.nix # skyg.nixos.desktop.tiler.hyprland — Hyprland (sets tiler.enable) +└── swww.nix # skyg.nixos.desktop.tiler.background — swww/waypaper wallpaper tools ``` ## Behaviour @@ -27,8 +28,9 @@ tiler/ ## Option Namespace ``` -skyg.nixos.desktop.tiler.enable → default.nix (usually set indirectly) +skyg.nixos.desktop.tiler.enable → default.nix (usually set indirectly) skyg.nixos.desktop.tiler.niri.enable +skyg.nixos.desktop.tiler.niri.touchscreen-gestures.enable # 3/4-finger swipes → niri actions skyg.nixos.desktop.tiler.hyprland.enable skyg.nixos.desktop.tiler.background.enable ``` @@ -38,3 +40,15 @@ skyg.nixos.desktop.tiler.background.enable - Don't set `tiler.enable` directly — enable a compositor and let it flip the shared switch. - Greeter is DMS-managed (`programs.dank-material-shell`); never hand-roll `services.greetd`. - Keyring provides the SSH agent here — keep `programs.ssh.startAgent` off. + +## Touchscreen Gestures (niri only) + +When `skyg.nixos.desktop.tiler.niri.touchscreen-gestures.enable = true`: + +- Installs `niri-touchscreen-gestures` package +- Starts a user systemd service (`niri-touchscreen-gestures.service`) +- Uses built-in defaults: 3-finger swipes for workspace/column navigation, 4-finger for overview +- Can be customized by placing a TOML config at `~/.config/niri/gestures.toml` +- Requires user to be in the `input` group (done automatically by `tiler.enable`) + +See `pkgs/niri-touchscreen-gestures/README.md` for gesture configuration details. diff --git a/modules/nixos/desktop/tiler/default.nix b/modules/nixos/desktop/tiler/default.nix index f100c2d..b7c7b7d 100644 --- a/modules/nixos/desktop/tiler/default.nix +++ b/modules/nixos/desktop/tiler/default.nix @@ -11,6 +11,7 @@ in imports = [ ./hyprland.nix ./niri.nix + ./niri-touchscreen-gestures.nix ./swww.nix ]; options = { diff --git a/modules/nixos/desktop/tiler/niri-touchscreen-gestures.nix b/modules/nixos/desktop/tiler/niri-touchscreen-gestures.nix new file mode 100644 index 0000000..5c8792c --- /dev/null +++ b/modules/nixos/desktop/tiler/niri-touchscreen-gestures.nix @@ -0,0 +1,61 @@ +{ config +, lib +, pkgs +, ... +}: +let + cfg = config.skyg.nixos.desktop.tiler.niri.touchscreen-gestures; +in +{ + options = { + skyg.nixos.desktop.tiler.niri.touchscreen-gestures = { + enable = lib.mkEnableOption "niri touchscreen gesture support"; + }; + }; + + config = lib.mkIf cfg.enable { + assertions = [ + { + assertion = config.skyg.nixos.desktop.tiler.niri.enable; + message = "skyg.nixos.desktop.tiler.niri.touchscreen-gestures: niri must be enabled"; + } + ]; + + # Add the package to the system + environment.systemPackages = with pkgs; [ + niri-touchscreen-gestures + ]; + + # Create a user systemd service that runs the gesture detector + systemd.user.services.niri-touchscreen-gestures = { + description = "Niri touchscreen gesture detector"; + wantedBy = [ "graphical-session.target" ]; + partOf = [ "graphical-session.target" ]; + after = [ "niri.service" "graphical-session.target" ]; + requires = [ "niri.service" ]; + + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.niri-touchscreen-gestures}/bin/niri-touchscreen-gestures"; + Restart = "on-failure"; + RestartSec = 3; + + # Environment for niri socket and logging + Environment = [ + "NIRI_SOCKET=%t/niri/socket" + "RUST_BACKTRACE=1" + ]; + + # Security hardening appropriate for input device access + NoNewPrivileges = true; + PrivateTmp = true; + ProtectSystem = "strict"; + ReadWritePaths = [ "/dev/input" "%t/niri" ]; + + # Allow binding to input devices + CapabilityBoundingSet = [ "CAP_SYS_NICE" ]; + DeviceAllow = [ "/dev/input/event* rw" ]; + }; + }; + }; +} diff --git a/modules/nixos/desktop/tiler/niri.nix b/modules/nixos/desktop/tiler/niri.nix index 6f6bbe2..edf7593 100644 --- a/modules/nixos/desktop/tiler/niri.nix +++ b/modules/nixos/desktop/tiler/niri.nix @@ -8,9 +8,16 @@ let cfg = config.skyg.nixos.desktop.tiler.niri; in { + imports = [ + ./niri-touchscreen-gestures.nix + ]; + options = { skyg.nixos.desktop.tiler.niri = { enable = lib.mkEnableOption "niri"; + touchscreen-gestures = { + enable = lib.mkEnableOption "touchscreen gesture support"; + }; }; }; config = lib.mkIf cfg.enable { @@ -35,5 +42,6 @@ in xdg-desktop-portal-gtk ]; }; + }; }