# Tablet mode support for 2-in-1 convertibles (currently wired to the # ThinkPad X1 Yoga Gen 6). # # In tablet mode (screen folded flat behind the keyboard) the display should # follow the device orientation and an on-screen keyboard should appear when a # text field is focused. This module provides that in three pieces: # # 1. The NixOS half (here): grants petere membership of the `input` group so # the user-level daemon can read the tablet-mode evdev switch # (/dev/input/event17, "Intel HID switches", SW_TABLET_MODE), and wires # in the home-manager module (hyprland-tablet.nix) via sharedModules. # # 2. A user-level Python daemon (`hyprland-tablet` daemon) that: # - watches SW_TABLET_MODE via python-evdev; # - parses `monitor-sensor` output for accelerometer orientation # (iio-sensor-proxy, already running on this host); # - applies `transform` to the eDP-1 monitor (and matching per-device # transforms for touch/tablet inputs) via hyprctl; # - starts/stops `wvkbd --auto` so a virtual keyboard shows when a text # input is focused while in tablet mode. # # 3. A `hyprland-tablet` CLI (status / keyboard toggle) used by the # QuickShell bar chip and the SUPER+CTRL+K keybind. # # Why not iio-hyprland? It rotates on every accelerometer reading regardless # of tablet mode; this host's iio-sensor-proxy build has no hinge support, so # orientation must be gated on the SW_TABLET_MODE switch ourselves. { config, lib, pkgs, ... }: let cfg = config.my.hardware.tabletMode; in { options.my.hardware.tabletMode = { enable = lib.mkEnableOption "tablet-mode auto-rotation + on-screen keyboard for 2-in-1 convertibles"; }; config = lib.mkIf cfg.enable { # petere needs to read /dev/input/event17 (root:input 660) for the # SW_TABLET_MODE switch. The Intel HID switch device is unique to this # Yoga, so we match it explicitly and grant it to petere. This works for # the current session immediately -- no re-login needed to pick up a group. users.users.petere.extraGroups = lib.mkBefore [ "input" ]; services.udev.extraRules = '' KERNEL=="event*", SUBSYSTEM=="input", ATTRS{name}=="Intel HID switches", OWNER="petere", MODE="0660", TAG+="uaccess" ''; home-manager.sharedModules = [ ../../home-manager/modules/hyprland-tablet.nix ]; }; }