xsession: cleanup systemd variables (#3636)

This commit is contained in:
arcnmx 2023-05-07 14:59:56 -07:00 committed by GitHub
parent e34fbe1801
commit 78ceec68f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View File

@ -78,6 +78,7 @@ in {
importedVariables = mkOption {
type = types.listOf (types.strMatching "[a-zA-Z_][a-zA-Z0-9_]*");
apply = unique;
example = [ "GDK_PIXBUF_ICON_LOADER" ];
visible = false;
description = ''
@ -184,7 +185,7 @@ in {
${optionalString (cfg.importedVariables != [ ])
("systemctl --user import-environment "
+ toString (unique cfg.importedVariables))}
+ escapeShellArgs cfg.importedVariables)}
${cfg.profileExtra}
@ -212,6 +213,10 @@ in {
while [ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]; do
sleep 0.5
done
${optionalString (cfg.importedVariables != [ ])
("systemctl --user unset-environment "
+ escapeShellArgs cfg.importedVariables)}
'';
};
};

View File

@ -9,7 +9,7 @@ fi
# script starts up graphical-session.target.
systemctl --user stop graphical-session.target graphical-session-pre.target
systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS DISPLAY SSH_AUTH_SOCK XAUTHORITY XDG_DATA_DIRS XDG_RUNTIME_DIR XDG_SESSION_ID EXTRA_IMPORTED_VARIABLE
systemctl --user import-environment 'DBUS_SESSION_BUS_ADDRESS' 'DISPLAY' 'SSH_AUTH_SOCK' 'XAUTHORITY' 'XDG_DATA_DIRS' 'XDG_RUNTIME_DIR' 'XDG_SESSION_ID' 'EXTRA_IMPORTED_VARIABLE'
profile extra commands

View File

@ -16,3 +16,5 @@ systemctl --user stop graphical-session-pre.target
while [ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]; do
sleep 0.5
done
systemctl --user unset-environment 'DBUS_SESSION_BUS_ADDRESS' 'DISPLAY' 'SSH_AUTH_SOCK' 'XAUTHORITY' 'XDG_DATA_DIRS' 'XDG_RUNTIME_DIR' 'XDG_SESSION_ID' 'EXTRA_IMPORTED_VARIABLE'