mirror of
https://github.com/theupriser/steamify-cachyos.git
synced 2026-10-03 17:41:58 +02:00
refactor: theme_enable and create_desktop_shortcut in steps; make test skips the hardware test
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ss5gKj7XG5JPi27XwGBGTs
This commit is contained in:
1 parent
7ae1565fe3
commit
df74295a3d
4 files changed
+61
-44
No files matched your search
+30
-29
@@ -2,41 +2,46 @@
|
||||
# "Return to Gaming Mode" desktop shortcut and the sudoers rule it needs.
|
||||
# Sourced by steamify.sh; not meant to be run on its own.
|
||||
|
||||
create_desktop_shortcut() {
|
||||
# Determine the home directory of the target user
|
||||
local user_home
|
||||
shortcut_desktop_dir() {
|
||||
# The target user's Desktop folder, from their user-dirs.dirs.
|
||||
local user_home desktop_dir
|
||||
user_home="$(getent passwd "$TARGET_USER" | cut -d: -f6)"
|
||||
|
||||
# Locate the correct Desktop directory
|
||||
local desktop_dir
|
||||
if [[ -f "$user_home/.config/user-dirs.dirs" ]]; then
|
||||
desktop_dir=$(grep '^XDG_DESKTOP_DIR=' "$user_home/.config/user-dirs.dirs" | cut -d '"' -f 2)
|
||||
desktop_dir="${desktop_dir/\$HOME/$user_home}"
|
||||
fi
|
||||
desktop_dir="${desktop_dir:-$user_home/Desktop}"
|
||||
echo "${desktop_dir:-$user_home/Desktop}"
|
||||
}
|
||||
|
||||
shortcut_install_sudoers() {
|
||||
# plasma-login-manager needs the sync bridge run and a restart, which the
|
||||
# shortcut can't sudo for interactively (Terminal=false), so it gets a
|
||||
# password-less rule scoped to exactly those two commands.
|
||||
local sudoers_tmp
|
||||
sudoers_tmp="$(mktemp)"
|
||||
cat > "$sudoers_tmp" << EOF
|
||||
$TARGET_USER ALL=(root) NOPASSWD: /usr/bin/systemctl start sync-steamos-session.service, /usr/bin/systemctl restart plasmalogin
|
||||
EOF
|
||||
if sudo visudo -cf "$sudoers_tmp" >/dev/null; then
|
||||
sudo install -m 0440 -o root -g root "$sudoers_tmp" /etc/sudoers.d/gamescope-session-switch
|
||||
ok "Installed /etc/sudoers.d/gamescope-session-switch for the shortcut."
|
||||
else
|
||||
warn "Generated sudoers rule failed validation; the shortcut will not be able to restart plasmalogin."
|
||||
fi
|
||||
rm -f "$sudoers_tmp"
|
||||
}
|
||||
|
||||
create_desktop_shortcut() {
|
||||
local desktop_dir
|
||||
desktop_dir="$(shortcut_desktop_dir)"
|
||||
mkdir -p "$desktop_dir"
|
||||
|
||||
# On SDDM, steamos-session-select logging out is enough: Relogin=true
|
||||
# logs straight back in to the newly selected session, like SteamOS.
|
||||
# plasma-login-manager needs the sync bridge run and a restart, which
|
||||
# the shortcut can't sudo for interactively (Terminal=false), so it gets
|
||||
# a password-less rule scoped to exactly those two commands.
|
||||
local exec_line="steamos-session-select gamescope"
|
||||
if [[ "$LOGIN_MANAGER" == "plasmalogin" ]]; then
|
||||
exec_line="sh -c 'steamos-session-select gamescope && sudo -n /usr/bin/systemctl start sync-steamos-session.service && sudo -n /usr/bin/systemctl restart plasmalogin'"
|
||||
local sudoers_tmp
|
||||
sudoers_tmp="$(mktemp)"
|
||||
cat > "$sudoers_tmp" << EOF
|
||||
$TARGET_USER ALL=(root) NOPASSWD: /usr/bin/systemctl start sync-steamos-session.service, /usr/bin/systemctl restart plasmalogin
|
||||
EOF
|
||||
if sudo visudo -cf "$sudoers_tmp" >/dev/null; then
|
||||
sudo install -m 0440 -o root -g root "$sudoers_tmp" /etc/sudoers.d/gamescope-session-switch
|
||||
ok "Installed /etc/sudoers.d/gamescope-session-switch for the shortcut."
|
||||
else
|
||||
warn "Generated sudoers rule failed validation; the shortcut will not be able to restart plasmalogin."
|
||||
fi
|
||||
rm -f "$sudoers_tmp"
|
||||
shortcut_install_sudoers
|
||||
else
|
||||
sudo rm -f /etc/sudoers.d/gamescope-session-switch
|
||||
fi
|
||||
@@ -49,11 +54,11 @@ EOF
|
||||
[[ -f /usr/local/share/icons/hicolor/scalable/actions/gaming-return.svg ]] &&
|
||||
shortcut_icon="gaming-return"
|
||||
|
||||
# 2. Generate the .desktop shortcut with instant session switcher strings
|
||||
local shortcut_path="$desktop_dir/Return to Gaming Mode.desktop"
|
||||
info "Creating 'Return to Gaming Mode' desktop shortcut at: $shortcut_path"
|
||||
|
||||
cat << EOF > "$shortcut_path"
|
||||
# Written with its mode already set: Plasma opens a desktop icon it first
|
||||
# saw non-executable in an editor.
|
||||
install_executable "$shortcut_path" 755 << EOF
|
||||
[Desktop Entry]
|
||||
Name=Return to Gaming Mode
|
||||
Comment=Switch session back to Gamescope
|
||||
@@ -63,10 +68,6 @@ Terminal=false
|
||||
Type=Application
|
||||
Categories=System;
|
||||
EOF
|
||||
|
||||
# Fix permissions for the target user and KDE Plasma desktop ecosystem
|
||||
chmod +x "$shortcut_path"
|
||||
|
||||
ok "Desktop shortcut created successfully."
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user