first commit
This commit is contained in:
149
usr/bin/portproton-session-select
Executable file
149
usr/bin/portproton-session-select
Executable file
@ -0,0 +1,149 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
die() { echo >&2 "!! $*"; exit 1; }
|
||||
|
||||
SENTINEL_FILE="gamescope-session-type"
|
||||
|
||||
# Determine the configuration directory
|
||||
if [[ "$USER" == "root" ]] ; then
|
||||
config_dir="${XDG_CONF_DIR:-"/home/$4/.config"}"
|
||||
else
|
||||
config_dir="${XDG_CONF_DIR:-"$HOME/.config"}"
|
||||
fi
|
||||
|
||||
[[ -f "$config_dir/$SENTINEL_FILE" ]] && source "$config_dir/$SENTINEL_FILE"
|
||||
|
||||
session="${1:-gamescope}"
|
||||
session_launcher=""
|
||||
create_sentinel=""
|
||||
|
||||
if [[ "$2" == "--sentinel-created" ]]; then
|
||||
SENTINEL_CREATED=1
|
||||
fi
|
||||
|
||||
# Ensure necessary environment variables are set
|
||||
if [[ -z "$HOME" ]]; then
|
||||
die "No \$HOME variable"
|
||||
fi
|
||||
|
||||
update_config_sentinel() {
|
||||
[[ $EUID == 0 ]] && die "Running $0 as root is not allowed"
|
||||
mkdir -p "$config_dir"
|
||||
|
||||
if [[ ! -f "$config_dir/$SENTINEL_FILE" ]]; then
|
||||
if [[ "$XDG_SESSION_TYPE" == "wayland" ]]; then
|
||||
echo "SESSION_TYPE=wayland" > "$config_dir/$SENTINEL_FILE"
|
||||
else
|
||||
echo "SESSION_TYPE=x11" > "$config_dir/$SENTINEL_FILE"
|
||||
fi
|
||||
echo "DE=$XDG_CURRENT_DESKTOP" >> "$config_dir/$SENTINEL_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
systemctl restart lightdm
|
||||
}
|
||||
|
||||
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 restart sddm
|
||||
}
|
||||
|
||||
yad_question() {
|
||||
env GDK_BACKEND="x11" 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
|
||||
[[ "$?" != 0 ]] && return 1 || return 0
|
||||
}
|
||||
|
||||
if [[ -z $SENTINEL_CREATED ]]; then
|
||||
update_config_sentinel
|
||||
export SENTINEL_CREATED=1
|
||||
fi
|
||||
|
||||
if [[ $(grep -E '^X-KDE-PluginInfo-Version=' /usr/share/xsessions/plasmax11.desktop | cut -d'=' -f2) =~ 6.* ]] ; then
|
||||
KDE6="true"
|
||||
fi
|
||||
|
||||
case "$session" in
|
||||
desktop)
|
||||
if [[ "$SESSION_TYPE" == "wayland" ]]; then
|
||||
if [[ "$DE" == "GNOME" ]]; then
|
||||
session_launcher="gnome-wayland"
|
||||
elif [[ "$DE" == "KDE" ]]; then
|
||||
session_launcher="plasma"
|
||||
[[ "$KDE6" != "true" ]] && session_launcher="plasmawayland"
|
||||
fi
|
||||
else
|
||||
if [[ "$DE" == "GNOME" ]]; then
|
||||
session_launcher="gnome-xorg"
|
||||
elif [[ "$DE" == "KDE" ]]; then
|
||||
session_launcher="plasmax11"
|
||||
[[ "$KDE6" != "true" ]] && session_launcher="plasma"
|
||||
elif [[ "$DE" == "MATE" ]]; then
|
||||
session_launcher="mate"
|
||||
fi
|
||||
fi
|
||||
create_sentinel=1
|
||||
;;
|
||||
gamescope)
|
||||
session_launcher="gamescope-session-steam"
|
||||
create_sentinel=1
|
||||
;;
|
||||
*)
|
||||
die "Unrecognized session '$session'"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Updated user selected session to $session_launcher"
|
||||
|
||||
if [[ ! -z $4 ]]; then
|
||||
USER="$4"
|
||||
fi
|
||||
|
||||
if systemctl is-active --quiet gdm; then
|
||||
env GDK_BACKEND="x11" 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"
|
||||
echo "autologin=false" >> "$config_dir/$SENTINEL_FILE"
|
||||
die "Autologin configuration aborted due to GDM."
|
||||
fi
|
||||
|
||||
if ! grep -iq "autologin" "$config_dir/$SENTINEL_FILE" || [[ "$2" == "plasma" ]] || [[ "$2" == "desktop" ]] ; then
|
||||
if yad_question "Требуется подтверждение" "Для работы данной функции требуется настроить автологин. Хотите ли вы, чтобы это было настроено автоматически?" ; then
|
||||
echo "autologin=true" >> "$config_dir/$SENTINEL_FILE"
|
||||
echo "autologin enabled"
|
||||
else
|
||||
echo "autologin=false" >> "$config_dir/$SENTINEL_FILE"
|
||||
echo "autologin disabled"
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ -f "$config_dir/$SENTINEL_FILE" ]] && source "$config_dir/$SENTINEL_FILE"
|
||||
|
||||
if [[ "$autologin" == "true" ]] ; then
|
||||
# Re-execute as root
|
||||
if [[ $EUID != 0 ]]; then
|
||||
exec pkexec "$(realpath $0)" "$session" --sentinel-created "$session_type" "$USER"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q "nopasswdlogin" "/etc/group" ; then
|
||||
groupadd -r nopasswdlogin
|
||||
fi
|
||||
|
||||
if ! id -nG "$USER" | grep -qw "nopasswdlogin"; then
|
||||
gpasswd -a "$USER" nopasswdlogin
|
||||
fi
|
||||
|
||||
if systemctl is-active --quiet lightdm; then
|
||||
configure_lightdm
|
||||
fi
|
||||
|
||||
if systemctl is-active --quiet sddm; then
|
||||
configure_sddm
|
||||
fi
|
||||
fi
|
10
usr/share/applications/portprotonqt_return.desktop
Normal file
10
usr/share/applications/portprotonqt_return.desktop
Normal file
@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Name=Return to PortProtonQt
|
||||
Exec=portproton-session-select gamescope
|
||||
Icon=steamdeck-gaming-return
|
||||
Terminal=false
|
||||
Type=Application
|
||||
StartupNotify=false
|
||||
Comment=Quickly exit the session to switch to PortProtonQt
|
||||
Comment[ru]=Быстрый выход из сессии для перехода в PortProtonQt
|
||||
Categories=Game;
|
3
usr/share/gamescope-session-plus/sessions.d/portprotonqt
Normal file
3
usr/share/gamescope-session-plus/sessions.d/portprotonqt
Normal file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CLIENTCMD="portprotonqt --fullscreen"
|
@ -0,0 +1,7 @@
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg id="svg2" height="64" style="" viewBox="0 0 64 64" width="64" xmlns="http://www.w3.org/2000/svg" sodipodi:docname="deck_icon.svg" inkscape:version="1.2-dev (d2dd25d878, 2022-02-01, custom)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<path id="path42220" d="m 32 4 v 10 a 18 18 0 0 1 18 18 a 18 18 0 0 1 -18 18 v 10 a 28 28 0 0 0 28 -28 a 28 28 0 0 0 -28 -28 z" style="fill:#fff;fill-rule:evenodd"/>
|
||||
<circle id="path43518" cx="32" cy="32" r="14" style="fill:#1a9fff;fill-rule:evenodd"/>
|
||||
<path id="path52048" d="m 32 22 a 2 2 0 0 0 -1.4140625 .5859375 l -8 8 a 2.0002 2.0002 0 0 0 0 2.828125 l 8 8 a 2 2 0 0 0 2.828125 0 a 2 2 0 0 0 0 -2.828125 l -4.5859375 -4.5859375 h 11.171875 a 2 2 0 0 0 2 -2 a 2 2 0 0 0 -2 -2 h -11.171875 l 4.5859375 -4.5859375 a 2 2 0 0 0 0 -2.828125 a 2 2 0 0 0 -1.4140625 -.5859375 z" style="fill:#fff;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0"/>
|
||||
<g id="path89696" style=""/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
|
||||
<policyconfig>
|
||||
<vendor>PortProtonQt</vendor>
|
||||
<vendor_url>https://git.linux-gaming.ru/Boria138</vendor_url>
|
||||
<action id="org.shadowblip.pkexec.run-session-select">
|
||||
<description>Helper to switch sessions</description>
|
||||
<icon_name>package-x-generic</icon_name>
|
||||
<defaults>
|
||||
<allow_any>yes</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/portprotonqt-session-select</annotate>
|
||||
</action>
|
||||
</policyconfig>
|
@ -0,0 +1,7 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=PortProtonQt
|
||||
Comment=PortProtonQt Session
|
||||
Exec=gamescope-session-plus portprotonqt
|
||||
Type=Application
|
||||
DesktopNames=gamescope
|
Reference in New Issue
Block a user