16 lines
558 B
Nix
16 lines
558 B
Nix
{ pkgs, ... }:
|
|
|
|
let
|
|
script = pkgs.writeShellScript "kvm-switch-enable-screen" ''
|
|
${pkgs.findutils}/bin/find /run/user/ -maxdepth 2 -type s -name 'sway-ipc.*.sock' | while read socket; do
|
|
user=$(stat -c '%U' "$socket")
|
|
[ "$user" = "UNKNOWN" ] && continue
|
|
/run/wrappers/bin/sudo -u $user SWAYSOCK="$socket" /etc/profiles/per-user/$user/bin/swaymsg "output * dpms on"
|
|
done
|
|
'';
|
|
in
|
|
{
|
|
services.udev.extraRules = ''
|
|
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0bda", ATTR{idProduct}=="5411", RUN+="${script}"
|
|
'';
|
|
}
|