diff --git a/modules/xsession.nix b/modules/xsession.nix index e0dff4552..7f0991f1b 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -60,19 +60,12 @@ in }; }; - # For stuff that needs to start just before a graphical session - # starts. - systemd.user.targets.graphical-session-pre = { + # A basic graphical session target for Home Manager. + systemd.user.targets.he-graphical-session = { Unit = { - Description = "Pre-graphical session"; - }; - }; - - # A basic graphical session target. Apparently this will come - # standard in future Systemd versions. - systemd.user.targets.graphical-session = { - Unit = { - Description = "Graphical session"; + Description = "Home Manager X session"; + Requires = [ "graphical-session-pre.target" ]; + BindsTo = [ "graphical-session.target" ]; }; }; @@ -83,6 +76,9 @@ in . "$HOME/.profile" fi + # If there are any running services from a previous session. + systemctl --user stop graphical-session.target graphical-session-pre.target + systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS systemctl --user import-environment DISPLAY systemctl --user import-environment SSH_AUTH_SOCK @@ -90,8 +86,7 @@ in systemctl --user import-environment XDG_DATA_DIRS systemctl --user import-environment XDG_RUNTIME_DIR - systemctl --user restart graphical-session-pre.target - systemctl --user restart graphical-session.target + systemctl --user start he-graphical-session.target ${cfg.initExtra}