From a89b885ae9614d6c5abb045cbd90c4e2e89f90b7 Mon Sep 17 00:00:00 2001 From: laalsaas Date: Mon, 1 Jul 2024 00:14:48 +0200 Subject: [PATCH] sway: integrate with systemd see: https://github.com/swaywm/sway/wiki/Systemd-integration --- nixos/modules/programs/wayland/sway.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nixos/modules/programs/wayland/sway.nix b/nixos/modules/programs/wayland/sway.nix index 8d43a3329f41..27c32ce42dc5 100644 --- a/nixos/modules/programs/wayland/sway.nix +++ b/nixos/modules/programs/wayland/sway.nix @@ -123,12 +123,23 @@ in # Import the most important environment variables into the D-Bus and systemd # user environments (e.g. required for screen sharing and Pinentry prompts): exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP + # enable systemd-integration + exec "systemctl --user import-environment {,WAYLAND_}DISPLAY SWAYSOCK; systemctl --user start sway-session.target" + exec swaymsg -t subscribe '["shutdown"]' && systemctl --user stop sway-session.target ''; } // lib.optionalAttrs (cfg.package != null) { "sway/config".source = lib.mkOptionDefault "${cfg.package}/etc/sway/config"; }; }; + systemd.user.targets.sway-session = { + description = "sway compositor session"; + documentation = [ "man:systemd.special(7)" ]; + bindsTo = [ "graphical-session.target" ]; + wants = [ "graphical-session-pre.target" ]; + after = [ "graphical-session-pre.target" ]; + }; + # To make a Sway session available if a display manager like SDDM is enabled: services.displayManager.sessionPackages = lib.optional (cfg.package != null) cfg.package;