Compare commits

..

3 Commits

Author SHA1 Message Date
8aa326c000 fix autologin work on non X11 kde6
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
2025-07-13 12:15:42 +05:00
91d53625f5 make portprotonqt-desktop-return simply
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
2025-07-12 12:32:21 +05:00
33e06fb5ec fix autologin
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
2025-07-12 11:53:15 +05:00
3 changed files with 50 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
[Seat:*]
#autologin-user=
#autologin-user-timeout=
#autologin-session=
#autologin-user=
autologin-user-timeout=

View File

@@ -5,22 +5,5 @@
CONFIG_FILE="$HOME/.config/gamescope-session-type"
if [[ -f "$CONFIG_FILE" ]] && grep -q 'autologin=true' "$CONFIG_FILE"; then
XDG_DESKTOP=$(echo "${XDG_CURRENT_DESKTOP,,}")
if [[ "$XDG_DESKTOP" == *gnome* ]]; then
exec gnome-session-quit --no-prompt
elif [[ "$XDG_DESKTOP" == *kde* ]]; then
VERSION=$(grep -E '^X-KDE-PluginInfo-Version=' /usr/share/xsessions/plasmax11.desktop 2>/dev/null | cut -d'=' -f2)
if [[ "$VERSION" =~ ^6\..* ]]; then
exec qdbus org.kde.Shutdown /Shutdown org.kde.Shutdown.logout
else
exec qdbus org.kde.ksmserver /KSMServer logout 0 0 0
fi
elif [[ "$XDG_DESKTOP" == *mate* ]]; then
exec mate-session-save --force-logout
elif [[ "$XDG_DESKTOP" == *hyprland* ]]; then
exec loginctl terminate-user "$(id -u)"
elif [[ "$XDG_DESKTOP" == *xfce* ]]; then
exec xfce4-session-logout --logout
fi
exec loginctl terminate-user "$(id -u)"
fi

View File

@@ -17,7 +17,7 @@ mkdir -p "${config_dir}/environment.d"
[[ -f "$config_dir/$SENTINEL_FILE" ]] && source "$config_dir/$SENTINEL_FILE"
session="${1:-gamescope}"
session="${1:-portprotonqt}"
session_launcher=""
create_sentinel=""
@@ -45,9 +45,9 @@ update_config_sentinel() {
}
configure_lightdm() {
sed -i "s/^.*autologin-user=.*/autologin-user=${USER}/" /etc/lightdm/lightdm.conf.d/10-gamescope-session.conf
sed -i "s/^.*autologin-user-timeout=.*/autologin-user-timeout=0/" /etc/lightdm/lightdm.conf.d/10-gamescope-session.conf
sed -i "s/^.*autologin-session=.*/autologin-session=$session_launcher/" /etc/lightdm/lightdm.conf.d/10-gamescope-session.conf
sed -i "s/^.*autologin-user=.*/autologin-user=${USER}/" /etc/lightdm/lightdm.conf.d/10-gamescope-session.conf
systemctl reset-failed lightdm
systemctl restart lightdm
}
@@ -55,11 +55,12 @@ configure_sddm() {
sed -i "s/^.*Relogin=.*/Relogin=true/" /etc/sddm.conf.d/10-gamescope-session.conf
sed -i "s/^.*Session=.*/Session=$session_launcher/" /etc/sddm.conf.d/10-gamescope-session.conf
sed -i "s/^.*User=.*/User=${USER}/" /etc/sddm.conf.d/10-gamescope-session.conf
systemctl reset-failed sddm
systemctl restart sddm
}
yad_question() {
yad --window-icon="/usr/share/icons/hicolor/scalable/actions/steamdeck-gaming-return.svg" --image="/usr/share/icons/hicolor/scalable/actions/steamdeck-gaming-return.svg" --question --title="$1" --text="$2" --width=300 --text-align=center
yad --window-icon="/usr/share/icons/hicolor/scalable/actions/portprotonqt-gaming-return.svg" --image="/usr/share/icons/hicolor/scalable/actions/portprotonqt-gaming-return.svg" --question --title="$1" --text="$2" --width=300 --text-align=center
[[ "$?" != 0 ]] && return 1 || return 0
}
@@ -68,17 +69,38 @@ if [[ -z $SENTINEL_CREATED ]]; then
export SENTINEL_CREATED=1
fi
if [[ -f /usr/share/xsessions/plasmax11.desktop ]]; then
version=$(grep -E '^X-KDE-PluginInfo-Version=' /usr/share/xsessions/plasmax11.desktop | cut -d'=' -f2)
if [[ $version =~ ^6.* ]]; then
KDE6="true"
KDE6=""
HAS_KDE_X11=""
KDE_VERSION=""
for file in \
/usr/share/xsessions/plasmax11.desktop \
/usr/share/wayland-sessions/plasma.desktop \
/usr/share/wayland-sessions/plasmawayland.desktop \
/usr/share/xsessions/plasmax.desktop; do
if [[ -f "$file" ]]; then
version=$(grep -E '^X-KDE-PluginInfo-Version=' "$file" | cut -d'=' -f2)
if [[ -n "$version" ]]; then
KDE_VERSION="$version"
break
fi
fi
done
if [[ -n "$KDE_VERSION" && "${KDE_VERSION%%.*}" -ge 6 ]]; then
KDE6="true"
else
KDE6=""
fi
if [[ -f /usr/share/xsessions/plasmax11.desktop ]]; then
HAS_KDE_X11="true"
fi
de_normalized="${DE,,}"
# TODO: Check ALT Workstation session_launcher
case "$session" in
desktop)
if [[ "$SESSION_TYPE" == "wayland" ]]; then
@@ -87,8 +109,11 @@ case "$session" in
elif [[ "$de_normalized" == *gnome* ]]; then
session_launcher="gnome-wayland"
elif [[ "$de_normalized" == *kde* ]]; then
session_launcher="plasma"
[[ "$KDE6" != "true" ]] && session_launcher="plasmawayland"
if [[ "$KDE6" == "true" ]]; then
session_launcher="plasma"
else
session_launcher="plasmawayland"
fi
elif [[ "$de_normalized" == *hyprland* ]]; then
session_launcher="hyprland"
elif [[ "$de_normalized" == *xfce* && "$de_normalized" != *unicorn* ]]; then
@@ -100,8 +125,15 @@ case "$session" in
elif [[ "$de_normalized" == *gnome* ]]; then
session_launcher="gnome-xorg"
elif [[ "$de_normalized" == *kde* ]]; then
session_launcher="plasmax11"
[[ "$KDE6" != "true" ]] && session_launcher="plasma"
if [[ "$KDE6" == "true" ]]; then
if [[ "$HAS_KDE_X11" == "true" ]]; then
session_launcher="plasmax11"
else
die "KDE6 detected, but plasmax11 (X11 session) not available"
fi
else
session_launcher="plasma"
fi
elif [[ "$de_normalized" == *mate* ]]; then
session_launcher="mate"
elif [[ "$de_normalized" == *unicorn* ]]; then
@@ -132,7 +164,7 @@ if [[ ! -z $4 ]]; then
fi
if systemctl is-active --quiet gdm; then
yad --window-icon="/usr/share/icons/hicolor/scalable/actions/steamdeck-gaming-return.svg" --image="/usr/share/icons/hicolor/scalable/actions/steamdeck-gaming-return.svg" --title="Требуется подтверждение" --text="Для работы данной функции требуется LIGHTDM или SDDM, GDM не поддерживается" --width=290 --text-align=center --button="OK"
yad --window-icon="/usr/share/icons/hicolor/scalable/actions/portprotonqt-gaming-return.svg" --image="/usr/share/icons/hicolor/scalable/actions/portprotonqt-gaming-return.svg" --title="Требуется подтверждение" --text="Для работы данной функции требуется LIGHTDM или SDDM, GDM не поддерживается" --width=290 --text-align=center --button="OK"
if [[ -f "$config_dir/$SENTINEL_FILE" ]]; then
if grep -iq "autologin" "$config_dir/$SENTINEL_FILE"; then
if ! grep -q "autologin=false" "$config_dir/$SENTINEL_FILE"; then
@@ -149,7 +181,7 @@ if systemctl is-active --quiet gdm; then
die "Autologin configuration aborted due to GDM."
fi
if ! grep -iq "autologin" "$config_dir/$SENTINEL_FILE" && [[ "$2" == "desktop" ]]; then
if ! grep -iq "autologin" "$config_dir/$SENTINEL_FILE"; then
if yad_question "Требуется подтверждение" "Для работы данной функции требуется настроить автологин. Хотите ли вы, чтобы это было настроено автоматически?" ; then
echo "autologin=true" >> "$config_dir/$SENTINEL_FILE"
echo "autologin enabled"