mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
xsession: improve initialization script
This adds a `graphical-session-pre` target for things that need to run just before the main session starts. Also adds a loop during shutdown that waits until all deactivating units are gone. Inspired by <https://youtu.be/hq18daxTkLA>.
This commit is contained in:
parent
75bb0c8efb
commit
6ec3026e51
1 changed files with 17 additions and 1 deletions
|
@ -53,6 +53,14 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# For stuff that needs to start just before a graphical session
|
||||
# starts.
|
||||
systemd.user.targets.graphical-session-pre = {
|
||||
Unit = {
|
||||
Description = "Pre-graphical session";
|
||||
};
|
||||
};
|
||||
|
||||
# A basic graphical session target. Apparently this will come
|
||||
# standard in future Systemd versions.
|
||||
systemd.user.targets.graphical-session = {
|
||||
|
@ -73,13 +81,21 @@ in
|
|||
systemctl --user import-environment XAUTHORITY
|
||||
systemctl --user import-environment XDG_DATA_DIRS
|
||||
systemctl --user import-environment XDG_RUNTIME_DIR
|
||||
systemctl --user start graphical-session.target
|
||||
|
||||
systemctl --user restart graphical-session-pre.target
|
||||
systemctl --user restart graphical-session.target
|
||||
|
||||
${cfg.initExtra}
|
||||
|
||||
${cfg.windowManager}
|
||||
|
||||
systemctl --user stop graphical-session.target
|
||||
systemctl --user stop graphical-session-pre.target
|
||||
|
||||
# Wait until the units actually stop.
|
||||
while [[ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]]; do
|
||||
sleep 0.5
|
||||
done
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue