Skip to content

Commit

Permalink
Use different tty to restart lightdm.
Browse files Browse the repository at this point in the history
  • Loading branch information
pastaq authored and Derek J. Clark committed Feb 15, 2024
1 parent eb2fe83 commit 95d6b48
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 68 deletions.
2 changes: 1 addition & 1 deletion rootfs/usr/bin/chimera-session-use-lightdm
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

sed -i "/autologin-session/c\autologin-session=$1" /etc/lightdm/lightdm.conf.d/10-chimeraos-session.conf
systemctl enable lightdm
systemctl restart lightdm
setsid sh -c 'exec systemctl restart lightdm <> /dev/tty6 >&0 2>&1'
136 changes: 69 additions & 67 deletions rootfs/usr/lib/os-session-select
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

set -e

die() { echo >&2 "!! $*"; exit 1; }
die() {
echo >&2 "!! $*"
exit 1
}

CONF_FILE="/etc/lightdm/lightdm.conf.d/10-chimeraos-session.conf"
SENTINEL_FILE="steamos-session-select"
Expand All @@ -18,90 +21,89 @@ session_launcher="gamescope-session-steam-plus"
create_sentinel=""

if [[ "$2" == "--sentinel-created" ]]; then
SENTINEL_CREATED=1
session_type="wayland"
SENTINEL_CREATED=1
session_type="wayland"
fi

# Update config sentinel
if [[ -z $SENTINEL_CREATED ]]; then
[[ $EUID == 0 ]] && die "Running $0 as root is not allowed"

[[ -n ${HOME+x} ]] || die "No \$HOME variable"
config_dir="${XDG_CONF_DIR:-"$HOME/.config"}"
session_type=$(
cd "$HOME"
mkdir -p "$config_dir"
cd "$config_dir"
if [[ -f "steamos-session-type" ]]; then
cp steamos-session-type "$SENTINEL_FILE"
else
echo "wayland" > "$SENTINEL_FILE"
fi
cat "$SENTINEL_FILE"
)

return_session=$(grep autologin-session $CONF_FILE | cut -d = -f 2)
return_session=$(
cd "$HOME"
mkdir -p "$config_dir"
cd "$config_dir"
echo "$return_session" > "$RETURN_SESSION_FILE"
cat "$RETURN_SESSION_FILE"
)

# clear steam game desktop shortcut clutter
DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
grep -r --files-with-matches "Exec=steam steam://rungameid/" "${DATA_HOME}"/applications/ | tr '\n' '\0' | xargs -0 -I {} rm {} || true

# If we were executed as a session user and then re-execute as root below, we don't want to set root's sentinel too
export SENTINEL_CREATED=1
[[ $EUID == 0 ]] && die "Running $0 as root is not allowed"

[[ -n ${HOME+x} ]] || die "No \$HOME variable"
config_dir="${XDG_CONF_DIR:-"$HOME/.config"}"
session_type=$(
cd "$HOME"
mkdir -p "$config_dir"
cd "$config_dir"
if [[ -f "steamos-session-type" ]]; then
cp steamos-session-type "$SENTINEL_FILE"
else
echo "wayland" >"$SENTINEL_FILE"
fi
cat "$SENTINEL_FILE"
)

return_session=$(grep autologin-session $CONF_FILE | cut -d = -f 2)
return_session=$(
cd "$HOME"
mkdir -p "$config_dir"
cd "$config_dir"
echo "$return_session" >"$RETURN_SESSION_FILE"
cat "$RETURN_SESSION_FILE"
)

# clear steam game desktop shortcut clutter
DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
grep -r --files-with-matches "Exec=steam steam://rungameid/" "${DATA_HOME}"/applications/ | tr '\n' '\0' | xargs -0 -I {} rm {} || true

# If we were executed as a session user and then re-execute as root below, we don't want to set root's sentinel too
export SENTINEL_CREATED=1
fi

# We use "plasma" as "desktop" to hook up to SteamOS's scripts
case "$session" in
plasma-wayland-persistent)
session_launcher="gnome-session"
;;
plasma-x11-persistent)
session_launcher="gnome-session"
;;
desktop|plasma)
session_launcher="gnome-session-oneshot"
create_sentinel=1
;;
opengamepadui|gamescope-session-opengamepadui)
session_launcher="gamescope-session-opengamepadui"
create_sentinel=1
;;
steam-plus|gamescope-session-steam-plus)
session_launcher="gamescope-session-steam-plus"
create_sentinel=1
;;
steam|gamescope-session-steam)
session_launcher="gamescope-session-steam"
create_sentinel=1
;;
*)
echo >&2 "!! Unrecognized session '$session'"
exit 1
;;
plasma-wayland-persistent)
session_launcher="gnome-session"
;;
plasma-x11-persistent)
session_launcher="gnome-session"
;;
desktop | plasma)
session_launcher="gnome-session-oneshot"
create_sentinel=1
;;
opengamepadui | gamescope-session-opengamepadui)
session_launcher="gamescope-session-opengamepadui"
create_sentinel=1
;;
steam-plus | gamescope-session-steam-plus)
session_launcher="gamescope-session-steam-plus"
create_sentinel=1
;;
steam | gamescope-session-steam)
session_launcher="gamescope-session-steam"
create_sentinel=1
;;
*)
echo >&2 "!! Unrecognized session '$session'"
exit 1
;;
esac

echo "Updated user selected session to $session_launcher"

# Become root
if [[ $EUID != 0 ]]; then
exec pkexec "$(realpath $0)" "$session" --sentinel-created
exit 1
exec pkexec "$(realpath $0)" "$session" --sentinel-created
exit 1
fi

{
echo "[Seat:*]"
echo "autologin-session=$session_launcher"
} > "$CONF_FILE"
echo "[Seat:*]"
echo "autologin-session=$session_launcher"
} >"$CONF_FILE"

echo "Updated system autologin session to $session_launcher"
systemctl reset-failed lightdm
systemctl restart lightdm
setsid sh -c 'exec systemctl restart lightdm <> /dev/tty6 >&0 2>&1'
echo "Restarted LightDM"

0 comments on commit 95d6b48

Please sign in to comment.