From acf8d4e985d1e31374a8d39239bd94cbf4fbde9f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 26 Jun 2017 18:26:54 +0200 Subject: [PATCH] xsession: use systemd graphical targets The systemd targets don't allow direct startup so we create our own target for graphical sessions managed by Home Environment. --- modules/xsession.nix | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) 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}