From a8e3f5887b588d460b253838505651c03ffd1aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Schwarz=C3=A4ugl?= Date: Tue, 25 Mar 2025 02:40:04 +0100 Subject: [PATCH] feat: add udev rule for screensharing --- profiles/nixos/optional/work.nix | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/profiles/nixos/optional/work.nix b/profiles/nixos/optional/work.nix index c011092..3df2d53 100644 --- a/profiles/nixos/optional/work.nix +++ b/profiles/nixos/optional/work.nix @@ -3,6 +3,25 @@ let inherit (config.swarselsystems) mainUser homeDir xdgDir; owner = mainUser; sopsFile = self + /secrets/work/secrets.yaml; + swarselService = name: description: execStart: { + "${name}" = { + enable = true; + inherit description; + serviceConfig = { + ExecStart = execStart; + User = mainUser; + Group = "users"; + Environment = [ + "PATH=/run/current-system/sw/bin:/etc/profiles/per-user/${mainUser}/bin" + "XDG_RUNTIME_DIR=${xdgDir}" + "WAYLAND_DISPLAY=wayland-1" + ]; + Type = "oneshot"; + StandardOutput = "journal"; + StandardError = "journal"; + }; + }; + }; in { sops = { @@ -123,6 +142,7 @@ in }; udev.extraRules = '' + # share screen when dongle detected SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="6860", TAG+="systemd", ENV{SYSTEMD_WANTS}="swarsel-screenshare.service" ''; @@ -145,6 +165,9 @@ in StandardError = "journal"; }; }; + systemd.services = lib.mkMerge [ + (swarselService "swarsel-screenshare" "Start screensharing after HDMI dongle is detected" "${pkgs.screenshare}/bin/screenshare -h") + ]; # cgroups v1 is required for centos7 dockers specialisation = {