mirror of
https://github.com/theupriser/steamify-cachyos.git
synced 2026-10-15 21:15:24 +02:00
Restart GNOME logs in to GNOME, not the account's default session (gaming mode after the conversion); the default is put back afterwards
Sync git.upriser.nl mirror / sync (push) Skipped
Sync git.upriser.nl mirror / sync (push) Skipped
This commit is contained in:
1 parent
4b601bb196
commit
49fba4af82
4 files changed
+42
-3
No files matched your search
@@ -6,11 +6,36 @@
|
||||
# ("A graphical session is already running!"): so the user is ended first,
|
||||
# then GDM restarted. That work runs in its own transient unit, because
|
||||
# ending the user kills this process too.
|
||||
#
|
||||
# An optional session id as the argument ("gnome"): that session is logged in
|
||||
# for this time only. The session in AccountsService (what the next boot goes
|
||||
# to: gaming mode after the SteamOS conversion) is put back once the new
|
||||
# session is up.
|
||||
if [[ "$1" != --work ]]; then
|
||||
[[ -n "${SUDO_USER:-}" ]] || exit 1
|
||||
exec systemd-run --no-block --collect --unit=steamify-gdm-relogin "$0" --work "$SUDO_USER"
|
||||
exec systemd-run --no-block --collect --unit=steamify-gdm-relogin "$0" --work "$SUDO_USER" "${1:-}"
|
||||
fi
|
||||
USER_NAME="$2"
|
||||
SESSION="$3"
|
||||
ACCOUNT="/var/lib/AccountsService/users/$USER_NAME"
|
||||
|
||||
# Session= and XSession= of the user, as GDM reads them at the next login.
|
||||
get_session() { sed -n "s/^$1=//p" "$ACCOUNT" 2>/dev/null | head -1; }
|
||||
set_session() {
|
||||
local key
|
||||
touch "$ACCOUNT"
|
||||
grep -q '^\[User\]' "$ACCOUNT" || echo "[User]" >> "$ACCOUNT"
|
||||
for key in Session XSession; do
|
||||
if grep -q "^$key=" "$ACCOUNT"; then sed -i "s|^$key=.*|$key=$1|" "$ACCOUNT"
|
||||
else sed -i "/^\[User\]/a $key=$1" "$ACCOUNT"; fi
|
||||
done
|
||||
systemctl restart accounts-daemon 2>/dev/null || true
|
||||
}
|
||||
if [[ -n "$SESSION" ]]; then
|
||||
OLD_SESSION="$(get_session Session)"; OLD_XSESSION="$(get_session XSession)"
|
||||
set_session "${SESSION%.desktop}"
|
||||
fi
|
||||
|
||||
# GDM is stopped first, so its login screen doesn't show while the old user
|
||||
# manager shuts down; a new login right away fails ("A graphical session is
|
||||
# already running!", or the session dies at once), so wait until it is gone.
|
||||
@@ -20,3 +45,14 @@ loginctl terminate-user "$USER_NAME"
|
||||
USER_RUNTIME="/run/user/$(id -u "$USER_NAME")"
|
||||
for _ in $(seq 120); do [[ -d "$USER_RUNTIME" ]] || break; sleep 0.25; done
|
||||
systemctl start gdm.service
|
||||
|
||||
if [[ -n "$SESSION" ]]; then
|
||||
# The new session has read what it logs in to once its user manager runs; then the next boot's session goes back.
|
||||
for _ in $(seq 120); do [[ -d "$USER_RUNTIME" ]] && break; sleep 0.25; done
|
||||
sleep 8
|
||||
if [[ -n "$OLD_SESSION" ]]; then
|
||||
sed -i "s|^Session=.*|Session=$OLD_SESSION|" "$ACCOUNT"
|
||||
if [[ -n "$OLD_XSESSION" ]]; then sed -i "s|^XSession=.*|XSession=$OLD_XSESSION|" "$ACCOUNT"; fi
|
||||
systemctl restart accounts-daemon 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
Reference in new issue
Block a user