mirror of
https://github.com/theupriser/steamify-cachyos.git
synced 2026-10-14 15:44:47 +02:00
GNOME prototype: detect GNOME/GDM, GDM autologin and session switching
This commit is contained in:
1 parent
7926e8b9ac
commit
5dfc916b97
14 files changed
+270
-17
No files matched your search
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
# Log the autologin user in again, into the session steam-set-session picked
|
||||
# (Steamify prototype, GDM). Run as root through sudo, from inside the session
|
||||
# that is being left. GDM logs in by itself only when the daemon starts, and
|
||||
# a new session refuses to start while the old user manager still runs
|
||||
# ("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.
|
||||
if [[ "$1" != --work ]]; then
|
||||
[[ -n "${SUDO_USER:-}" ]] || exit 1
|
||||
exec systemd-run --no-block --collect --unit=steamify-gdm-relogin "$0" --work "$SUDO_USER"
|
||||
fi
|
||||
USER_NAME="$2"
|
||||
# No waiting for the old user manager to go: systemd starts the new login
|
||||
# after it, and waiting only keeps GDM's login screen up in the meantime.
|
||||
loginctl terminate-user "$USER_NAME"
|
||||
systemctl restart gdm.service
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# steamos-session-select for GDM (Steamify prototype): CachyOS's own ends the
|
||||
# session with a KDE-only D-Bus call. GDM logs in by itself only when it
|
||||
# starts, so after the new session is set the user is ended and GDM restarted
|
||||
# (patches/steamify-gdm-relogin.sh): it then logs the autologin user straight into it.
|
||||
set -e
|
||||
|
||||
DM_ID="$(systemctl show -p Id --value display-manager)"
|
||||
DM_ID="${DM_ID%.service}"
|
||||
DESKTOP_SESSION=@DESKTOP_SESSION@
|
||||
|
||||
relogin() {
|
||||
# Out of the running session into the one that was set.
|
||||
case "$DM_ID" in
|
||||
gdm) sudo -n /usr/local/libexec/steamify-gdm-relogin ;;
|
||||
*) qdbus6 org.kde.Shutdown /Shutdown org.kde.Shutdown.logout ;;
|
||||
esac
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
persistent)
|
||||
systemctl --user mask cachyos-gamescope-autologin.service
|
||||
pkexec /usr/lib/steamos/steam-set-session "$DESKTOP_SESSION" ;;
|
||||
oneshot)
|
||||
systemctl --user unmask cachyos-gamescope-autologin.service
|
||||
pkexec /usr/lib/steamos/steam-set-session gamescope-session.desktop ;;
|
||||
gamescope)
|
||||
pkexec /usr/lib/steamos/steam-set-session gamescope-session.desktop
|
||||
relogin ;;
|
||||
desktop|plasma|gnome)
|
||||
pkexec /usr/lib/steamos/steam-set-session "$DESKTOP_SESSION"
|
||||
steam -shutdown || true
|
||||
systemctl --user stop gamescope-session.target || true
|
||||
# Under GDM nothing logs in again by itself after the session ends.
|
||||
[[ "$DM_ID" == gdm ]] && relogin ;;
|
||||
*)
|
||||
[[ -n "$1" ]] && echo -e "Unknown session '$1'\n"
|
||||
echo "Usage: $(basename "$0") persistent|oneshot|gamescope|desktop"
|
||||
exit 1 ;;
|
||||
esac
|
||||
|
||||
if [[ -e /dev/input/.hidden ]]; then
|
||||
pkexec mv /dev/input/.hidden/* /dev/input
|
||||
pkexec rm -r /dev/input/.hidden
|
||||
fi
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
# steam-set-session with GDM support (Steamify prototype). CachyOS's own only
|
||||
# knows plasma-login-manager and SDDM and quietly does nothing on GDM. GDM
|
||||
# has no autologin fragment: it takes the user's session from
|
||||
# AccountsService, so that is where the session goes.
|
||||
set -e
|
||||
|
||||
DM_ID="$(systemctl show -p Id --value display-manager)"
|
||||
DM_ID="${DM_ID%.service}"
|
||||
SESSION="${1:-gamescope-session.desktop}"
|
||||
|
||||
case "$DM_ID" in
|
||||
plasmalogin) CONF_FILE="/etc/plasmalogin.conf.d/zz-steamos-autologin.conf" ;;
|
||||
sddm) CONF_FILE="/etc/sddm.conf.d/zz-steamos-autologin.conf" ;;
|
||||
gdm)
|
||||
if [[ -n "${PKEXEC_UID:-}" ]]; then TARGET_USER="$(id -un "$PKEXEC_UID")"
|
||||
else TARGET_USER="${SUDO_USER:-$(logname 2>/dev/null)}"; fi
|
||||
# At boot (steamify-boot-desktop.service) nobody is logged in: the autologin user.
|
||||
[[ -n "$TARGET_USER" ]] || TARGET_USER="$(sed -n 's/^AutomaticLogin=//p' /etc/gdm/custom.conf 2>/dev/null)"
|
||||
[[ -n "$TARGET_USER" ]] || exit 0
|
||||
ACCOUNT="/var/lib/AccountsService/users/$TARGET_USER"
|
||||
SESSION_ID="${SESSION%.desktop}"
|
||||
mkdir -p /var/lib/AccountsService/users
|
||||
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=$SESSION_ID|" "$ACCOUNT"
|
||||
else sed -i "/^\[User\]/a $key=$SESSION_ID" "$ACCOUNT"; fi
|
||||
done
|
||||
systemctl restart accounts-daemon 2>/dev/null || true
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
# Any other login manager: nothing to do.
|
||||
[[ -n "${CONF_FILE:-}" ]] || exit 0
|
||||
mkdir -p "$(dirname "$CONF_FILE")"
|
||||
printf '[Autologin]\nSession=%s\n' "$SESSION" > "$CONF_FILE"
|
||||
@@ -0,0 +1,10 @@
|
||||
[Trigger]
|
||||
Operation = Install
|
||||
Operation = Upgrade
|
||||
Type = Package
|
||||
Target = gamescope-session-cachyos
|
||||
|
||||
[Action]
|
||||
Description = Steamify: GDM support for gamescope-session-cachyos...
|
||||
When = PostTransaction
|
||||
Exec = /bin/sh -c 'install -m755 @DIR@/steam-set-session /usr/lib/steamos/steam-set-session && install -m755 @DIR@/steamos-session-select /usr/bin/steamos-session-select'
|
||||
Reference in new issue
Block a user