mirror of
https://github.com/theupriser/steamify-cachyos.git
synced 2026-10-03 17:41:58 +02:00
fix: Replace the question flow with a menu that turns components on and off
- Menu detects what is on and applies only the changes: SteamOS conversion, SteamOS theme, Steam Deck/Machine icons, single user mode, and Steam Machine support (only on Fremont hardware) - Everything is reversible: KDE settings go through an undo journal (lib/state.sh), system files are restored from their backups - Steam Machine support: LED driver, udev rule giving the user the LED files, steamos-manager for Steam's hardware settings; OpenRGB dropped - Edit Plasma files only while plasmashell is stopped so it can't overwrite them - README and AGENTS.md describe the menu, the component model and the test environment
This commit is contained in:
1 parent
a0bc385765
commit
b91fa4bc83
13 files changed
+773
-567
No files matched your search
@@ -45,3 +45,25 @@ backup_file() {
|
||||
info "Backed up $f -> ${f}.bak-gamescope-wizard"
|
||||
fi
|
||||
}
|
||||
|
||||
# plasmashell keeps its config in memory and writes it back on exit, so
|
||||
# edits to its files (panels, applets, wallpaper) must be made while it is
|
||||
# stopped. It is restarted through systemd so it keeps the session's
|
||||
# environment (platform theme etc.); a plain --replace from this shell
|
||||
# may not, which gives a light-themed desktop.
|
||||
stop_plasmashell_for_edit() {
|
||||
PLASMASHELL_WAS_RUNNING=false
|
||||
if pgrep -u "$USER" -x plasmashell >/dev/null; then
|
||||
PLASMASHELL_WAS_RUNNING=true
|
||||
systemctl --user stop plasma-plasmashell.service 2>/dev/null
|
||||
pkill -u "$USER" -x plasmashell && sleep 2
|
||||
fi
|
||||
}
|
||||
|
||||
restart_plasmashell_if_stopped() {
|
||||
if [[ "${PLASMASHELL_WAS_RUNNING:-false}" == true ]]; then
|
||||
rm -rf ~/.cache/plasmashell* ~/.cache/org.kde.dirmodel-qml.kcache
|
||||
systemctl --user start plasma-plasmashell.service 2>/dev/null ||
|
||||
{ setsid plasmashell >/dev/null 2>&1 & }
|
||||
fi
|
||||
}
|
||||
@@ -68,3 +68,10 @@ EOF
|
||||
|
||||
ok "Desktop shortcut created successfully."
|
||||
}
|
||||
|
||||
remove_desktop_shortcut() {
|
||||
local desktop_dir
|
||||
desktop_dir="$(xdg-user-dir DESKTOP 2>/dev/null || echo "$HOME/Desktop")"
|
||||
rm -f "$desktop_dir/Return to Gaming Mode.desktop"
|
||||
sudo rm -f /etc/sudoers.d/gamescope-session-switch
|
||||
}
|
||||
+62
-35
@@ -1,58 +1,86 @@
|
||||
#!/bin/bash
|
||||
# plasma-login-manager autologin into gamescope, and the session sync bridge.
|
||||
# Booting into gaming mode: autologin into gamescope with SDDM or
|
||||
# plasma-login-manager (plus the session sync bridge the latter needs).
|
||||
# Sourced by setup-gamescope-boot.sh; not meant to be run on its own.
|
||||
|
||||
BASE_CONF="/etc/plasmalogin.conf"
|
||||
|
||||
choose_setup_mode() {
|
||||
# Step 1: one question decides both the login manager and locking.
|
||||
# "Single user, no password" is SteamOS: SDDM (which CachyOS's session
|
||||
# tools support directly, no workarounds) plus no lock screen, user
|
||||
# switching or log out. Otherwise keep the current login manager
|
||||
# (CachyOS's default plasma-login-manager gets the sync bridge below)
|
||||
# and KDE's normal locking. Sets SINGLE_USER and LOGIN_MANAGER.
|
||||
local current
|
||||
current="$(systemctl show -p Id --value display-manager 2>/dev/null | sed 's/\.service$//')"
|
||||
info "Detected display manager: ${current:-none}"
|
||||
|
||||
echo "SteamOS is a single-user console without passwords: no login screen, no"
|
||||
echo "lock screen, no user switching or logging out - typing a password with a"
|
||||
echo "controller is no fun. It uses the SDDM login manager for that."
|
||||
if ask_yn "Single user, no password, like SteamOS? (switches to SDDM)" y; then
|
||||
SINGLE_USER=true
|
||||
LOGIN_MANAGER="sddm"
|
||||
return
|
||||
fi
|
||||
|
||||
SINGLE_USER=false
|
||||
if [[ "$current" == "sddm" ]]; then
|
||||
LOGIN_MANAGER="sddm"
|
||||
return
|
||||
fi
|
||||
LOGIN_MANAGER="plasmalogin"
|
||||
if [[ "$current" != "plasmalogin" ]]; then
|
||||
warn "The workarounds are built for plasma-login-manager, but '${current:-unknown}' is active."
|
||||
ask_yn "Continue anyway?" n || exit 0
|
||||
fi
|
||||
# The "SteamOS conversion" menu item: gaming mode boot, the Return to
|
||||
# Gaming Mode shortcut and Steam on the desktop (lib/steam-desktop.sh).
|
||||
gaming_status() {
|
||||
# Autologin into gamescope is configured for this user.
|
||||
case "$(current_display_manager)" in
|
||||
sddm) [[ -f /etc/sddm.conf.d/10-gamescope-autologin.conf ]] ;;
|
||||
plasmalogin)
|
||||
sed -n '/^\[Autologin\]/,/^\[/p' "$BASE_CONF" 2>/dev/null | grep -qx "User=$USER" &&
|
||||
[[ -f /etc/systemd/system/sync-steamos-session.path ]] ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
setup_login_manager() {
|
||||
# Steps 3-8 for whichever login manager was chosen in step 1.
|
||||
gaming_enable() {
|
||||
# LOGIN_MANAGER (sddm with single user, else plasmalogin) is set by the
|
||||
# menu. Re-running with the other value switches over cleanly.
|
||||
install_required_packages || return 1
|
||||
case "$LOGIN_MANAGER" in
|
||||
sddm)
|
||||
switch_to_sddm || exit 1
|
||||
switch_to_sddm || return 1
|
||||
configure_sddm_autologin
|
||||
remove_session_sync
|
||||
;;
|
||||
plasmalogin)
|
||||
remove_sddm_autologin
|
||||
switch_to_plasmalogin || return 1
|
||||
configure_autologin
|
||||
install_session_sync
|
||||
;;
|
||||
esac
|
||||
create_desktop_shortcut
|
||||
steam_enable
|
||||
}
|
||||
|
||||
gaming_disable() {
|
||||
# Back to a normal desktop boot with CachyOS's default login manager.
|
||||
# Packages (steam, gamescope-session-cachyos, ...) are kept.
|
||||
info "Turning off booting into gaming mode..."
|
||||
remove_sddm_autologin
|
||||
remove_session_sync
|
||||
restore_plasmalogin_config
|
||||
switch_to_plasmalogin
|
||||
remove_desktop_shortcut
|
||||
steam_disable
|
||||
ok "The PC boots to the normal login screen again (from the next boot)."
|
||||
}
|
||||
|
||||
switch_to_plasmalogin() {
|
||||
[[ "$(current_display_manager)" == plasmalogin ]] && return 0
|
||||
info "Switching the login manager to plasma-login-manager..."
|
||||
sudo pacman -S --needed --noconfirm plasma-login-manager || { err "Installing plasma-login-manager failed."; return 1; }
|
||||
local current
|
||||
current="$(systemctl show -p Id --value display-manager 2>/dev/null)"
|
||||
[[ -n "$current" && "$current" != plasmalogin.service ]] && sudo systemctl disable "$current"
|
||||
sudo systemctl enable -f plasmalogin.service || { err "Enabling plasmalogin failed."; return 1; }
|
||||
ok "plasma-login-manager is the login manager from the next boot on."
|
||||
}
|
||||
|
||||
remove_sddm_autologin() {
|
||||
sudo rm -f /etc/sddm.conf.d/10-gamescope-autologin.conf
|
||||
}
|
||||
|
||||
restore_plasmalogin_config() {
|
||||
# Put back the original /etc/plasmalogin.conf from the first run's
|
||||
# backup, or at least drop our [Autologin] section.
|
||||
if [[ -f "${BASE_CONF}.bak-gamescope-wizard" ]]; then
|
||||
sudo cp -a "${BASE_CONF}.bak-gamescope-wizard" "$BASE_CONF"
|
||||
elif [[ -f "$BASE_CONF" ]]; then
|
||||
sudo awk '/^\[Autologin\]/ { skip=1; next } /^\[/ { skip=0 } !skip { print }' "$BASE_CONF" |
|
||||
sudo tee "${BASE_CONF}.tmp" > /dev/null && sudo mv "${BASE_CONF}.tmp" "$BASE_CONF"
|
||||
fi
|
||||
}
|
||||
|
||||
switch_to_sddm() {
|
||||
# Takes effect at the next boot; the running session is left alone.
|
||||
[[ "$(current_display_manager)" == sddm ]] && return 0
|
||||
info "Installing and enabling SDDM..."
|
||||
sudo pacman -S --needed --noconfirm sddm || { err "Installing sddm failed."; return 1; }
|
||||
local current
|
||||
@@ -62,7 +90,6 @@ switch_to_sddm() {
|
||||
fi
|
||||
sudo systemctl enable -f sddm.service || { err "Enabling sddm failed."; return 1; }
|
||||
ok "SDDM is the login manager from the next boot on."
|
||||
echo
|
||||
}
|
||||
|
||||
configure_sddm_autologin() {
|
||||
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
#!/bin/bash
|
||||
# Interactive menu: detects which components are on, lets the user pick what
|
||||
# they want, then turns components on or off to match.
|
||||
# Sourced by setup-gamescope-boot.sh; not meant to be run on its own.
|
||||
|
||||
# Menu order. Components are turned on in this order and off in reverse;
|
||||
# gaming must come first (single user builds on it).
|
||||
COMPONENTS=(gaming theme glyphs single machine)
|
||||
|
||||
declare -A LABEL=(
|
||||
[gaming]="SteamOS conversion: boot into gaming mode, Steam on the desktop"
|
||||
[theme]="Install SteamOS theme: Vapor look, dark mode, SteamOS taskbar"
|
||||
[glyphs]="Install Steam Deck/Machine icons: Deck button icons in gaming mode"
|
||||
[single]="Single user mode: no password, lock screen or log out (SDDM)"
|
||||
[machine]="Steam Machine support: LED bar driver, hardware settings in Steam"
|
||||
)
|
||||
declare -A CURRENT WANTED
|
||||
|
||||
component_available() {
|
||||
[[ "$1" != machine ]] || machine_available
|
||||
}
|
||||
|
||||
detect_components() {
|
||||
local c any=false
|
||||
for c in "${COMPONENTS[@]}"; do
|
||||
component_available "$c" || continue
|
||||
if "${c}_status"; then CURRENT[$c]=1; any=true; else CURRENT[$c]=0; fi
|
||||
WANTED[$c]=${CURRENT[$c]}
|
||||
done
|
||||
# First run: preselect the full SteamOS experience.
|
||||
if [[ "$any" == false ]]; then
|
||||
for c in "${COMPONENTS[@]}"; do
|
||||
component_available "$c" && WANTED[$c]=1
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
toggle_component() {
|
||||
local c="$1"
|
||||
WANTED[$c]=$(( 1 - WANTED[$c] ))
|
||||
# Single user mode only makes sense on top of the SteamOS conversion.
|
||||
if [[ "$c" == single && "${WANTED[single]}" == 1 ]]; then WANTED[gaming]=1; fi
|
||||
if [[ "$c" == gaming && "${WANTED[gaming]}" == 0 ]]; then WANTED[single]=0; fi
|
||||
}
|
||||
|
||||
show_menu() {
|
||||
local i=0 c now want
|
||||
echo
|
||||
printf " ${c_bold}%-3s %-6s %-6s %s${c_reset}\n" "#" "Now" "Want" "Component"
|
||||
MENU_ITEMS=()
|
||||
for c in "${COMPONENTS[@]}"; do
|
||||
component_available "$c" || continue
|
||||
i=$((i + 1)); MENU_ITEMS[$i]=$c
|
||||
now="off"; [[ "${CURRENT[$c]}" == 1 ]] && now="${c_green}on${c_reset} "
|
||||
want="[ ]"; [[ "${WANTED[$c]}" == 1 ]] && want="[x]"
|
||||
printf " %-3s %-6b %-6s %s\n" "$i" "$now " "$want" "${LABEL[$c]}"
|
||||
done
|
||||
echo
|
||||
}
|
||||
|
||||
run_menu() {
|
||||
# Sets REAPPLY. Returns 1 if the user quit.
|
||||
REAPPLY=false
|
||||
local reply
|
||||
while true; do
|
||||
show_menu
|
||||
read -rp "$(echo -e "${c_bold}Type a number to toggle, Enter to continue, a = also re-apply what's on, q = quit:${c_reset} ")" reply
|
||||
case "$reply" in
|
||||
"") return 0 ;;
|
||||
a|A) REAPPLY=true; return 0 ;;
|
||||
q|Q) return 1 ;;
|
||||
*)
|
||||
if [[ "$reply" =~ ^[0-9]+$ && -n "${MENU_ITEMS[$reply]:-}" ]]; then
|
||||
toggle_component "${MENU_ITEMS[$reply]}"
|
||||
else
|
||||
warn "Unknown choice: $reply"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
plan_changes() {
|
||||
# Fills TO_DISABLE (reverse order) and TO_ENABLE. Switching single user
|
||||
# on or off moves gaming mode to the other login manager, so gaming
|
||||
# mode is re-applied then too.
|
||||
TO_DISABLE=(); TO_ENABLE=()
|
||||
local c i
|
||||
for (( i = ${#COMPONENTS[@]} - 1; i >= 0; i-- )); do
|
||||
c=${COMPONENTS[$i]}
|
||||
component_available "$c" || continue
|
||||
[[ "${CURRENT[$c]}" == 1 && "${WANTED[$c]}" == 0 ]] && TO_DISABLE+=("$c")
|
||||
done
|
||||
for c in "${COMPONENTS[@]}"; do
|
||||
component_available "$c" || continue
|
||||
[[ "${WANTED[$c]}" == 1 ]] || continue
|
||||
if [[ "${CURRENT[$c]}" == 0 || "$REAPPLY" == true ]] ||
|
||||
[[ "$c" == gaming && "${CURRENT[single]}" != "${WANTED[single]}" ]]; then
|
||||
TO_ENABLE+=("$c")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
apply_changes() {
|
||||
local c failed=()
|
||||
LOGIN_MANAGER=plasmalogin
|
||||
[[ "${WANTED[single]}" == 1 ]] && LOGIN_MANAGER=sddm
|
||||
|
||||
for c in "${TO_DISABLE[@]}"; do
|
||||
echo; echo -e "${c_bold}Turning off: ${LABEL[$c]}${c_reset}"
|
||||
"${c}_disable" || failed+=("$c")
|
||||
done
|
||||
for c in "${TO_ENABLE[@]}"; do
|
||||
echo; echo -e "${c_bold}Turning on: ${LABEL[$c]}${c_reset}"
|
||||
"${c}_enable" || failed+=("$c")
|
||||
done
|
||||
FAILED=("${failed[@]}")
|
||||
}
|
||||
+2
-7
@@ -60,13 +60,8 @@ install_required_packages() {
|
||||
mapfile -t MISSING < <(pacman -T gamescope-session-cachyos steam mangohud xterm ttf-liberation wqy-zenhei plasma-keyboard)
|
||||
|
||||
if [[ ${#MISSING[@]} -gt 0 ]]; then
|
||||
info "Missing packages: ${MISSING[*]}"
|
||||
if ask_yn "Install them now?"; then
|
||||
sudo pacman -S --needed --noconfirm "${MISSING[@]}" || { err "Package installation failed."; exit 1; }
|
||||
else
|
||||
err "Cannot continue without these packages."
|
||||
exit 1
|
||||
fi
|
||||
info "Installing missing packages: ${MISSING[*]}"
|
||||
sudo pacman -S --needed --noconfirm "${MISSING[@]}" || { err "Package installation failed."; return 1; }
|
||||
else
|
||||
ok "All required packages already installed."
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
# Single user, no password, like SteamOS: no lock screen, user switching or
|
||||
# log out, since typing a password with a controller is miserable. Goes
|
||||
# together with SDDM (see lib/login-manager.sh). All changes are journaled
|
||||
# per user (lib/state.sh), so turning it off restores KDE's previous state.
|
||||
# Sourced by setup-gamescope-boot.sh; not meant to be run on its own.
|
||||
|
||||
single_status() {
|
||||
[[ "$(kreadconfig6 --file kdeglobals --group "KDE Action Restrictions" --key action/lock_screen)" == false ]]
|
||||
}
|
||||
|
||||
single_enable() {
|
||||
info "Turning off the lock screen, user switching and logging out..."
|
||||
stop_plasmashell_for_edit
|
||||
|
||||
# Hides Lock / Switch User in menus.
|
||||
local action applet
|
||||
for action in lock_screen switch_user start_new_session; do
|
||||
kset single kdeglobals "KDE Action Restrictions" "action/$action" false
|
||||
done
|
||||
# Never lock on idle or resume.
|
||||
kset single kscreenlockerrc Daemon Autolock false
|
||||
kset single kscreenlockerrc Daemon LockOnResume false
|
||||
kset single kscreenlockerrc Daemon Timeout 0
|
||||
# The restrictions don't cover the shortcuts: unbind Meta+L and the
|
||||
# Ctrl+Alt+Del logout screen (format: current,default,description).
|
||||
kset single kglobalshortcutsrc ksmserver "Lock Session" $'none,Screensaver\tMeta+L,Lock Session'
|
||||
kset single kglobalshortcutsrc ksmserver "Log Out" 'none,Ctrl+Alt+Del,Show Logout Screen'
|
||||
# Launcher: only Sleep / Restart / Shut Down, no Session dropdown (where
|
||||
# Log Out lives). Restricting action/logout instead would also hide
|
||||
# Restart and Shut Down.
|
||||
for applet in $(plasma_applets org.kde.plasma.kickoff); do
|
||||
local grp="Containments|${applet%%:*}|Applets|${applet#*:}|Configuration|General"
|
||||
kset single plasma-org.kde.plasma.desktop-appletsrc "$grp" primaryActions 3
|
||||
kset single plasma-org.kde.plasma.desktop-appletsrc "$grp" systemFavorites 'suspend,reboot,shutdown'
|
||||
done
|
||||
|
||||
restart_plasmashell_if_stopped
|
||||
ok "Single user: no lock screen, user switching or log out."
|
||||
}
|
||||
|
||||
single_disable() {
|
||||
info "Restoring the lock screen, user switching and logging out..."
|
||||
stop_plasmashell_for_edit
|
||||
if has_journal single; then
|
||||
krevert single
|
||||
else
|
||||
# Set up by a version of this script without the undo journal:
|
||||
# fall back to KDE's defaults for everything it changes.
|
||||
local action applet key
|
||||
for action in lock_screen switch_user start_new_session; do
|
||||
kwriteconfig6 --file kdeglobals --group "KDE Action Restrictions" --key "action/$action" --delete
|
||||
done
|
||||
for key in Autolock LockOnResume Timeout; do
|
||||
kwriteconfig6 --file kscreenlockerrc --group Daemon --key "$key" --delete
|
||||
done
|
||||
kwriteconfig6 --file kglobalshortcutsrc --group ksmserver --key "Lock Session" $'Screensaver\tMeta+L,Screensaver\tMeta+L,Lock Session'
|
||||
kwriteconfig6 --file kglobalshortcutsrc --group ksmserver --key "Log Out" 'Ctrl+Alt+Del,Ctrl+Alt+Del,Show Logout Screen'
|
||||
for applet in $(plasma_applets org.kde.plasma.kickoff); do
|
||||
kwriteconfig6 --file plasma-org.kde.plasma.desktop-appletsrc --group Containments --group "${applet%%:*}" \
|
||||
--group Applets --group "${applet#*:}" --group Configuration --group General --key primaryActions --delete
|
||||
kwriteconfig6 --file plasma-org.kde.plasma.desktop-appletsrc --group Containments --group "${applet%%:*}" \
|
||||
--group Applets --group "${applet#*:}" --group Configuration --group General --key systemFavorites --delete
|
||||
done
|
||||
fi
|
||||
restart_plasmashell_if_stopped
|
||||
ok "KDE's normal lock screen and user switching are back."
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#!/bin/bash
|
||||
# Undo journal for per-user KDE settings, so every component can be turned
|
||||
# off again exactly: the first time a component changes a key, the key's
|
||||
# previous value is recorded, and reverting the component puts it back (or
|
||||
# deletes the key if it didn't exist before).
|
||||
# Sourced by setup-gamescope-boot.sh; not meant to be run on its own.
|
||||
|
||||
STATE_DIR="${XDG_STATE_HOME:-$HOME/.local/state}/cachyos-gamescope-boot"
|
||||
UNSET=$'\x01'
|
||||
|
||||
kset() {
|
||||
# kset <component> <file> <group[|group...]> <key> <value>
|
||||
# kwriteconfig6, recording the old value in the component's journal.
|
||||
# <value> "--delete" removes the key.
|
||||
local component="$1" file="$2" groups="$3" key="$4" value="$5"
|
||||
local journal="$STATE_DIR/$component.journal" old id
|
||||
local -a gargs=() g
|
||||
local groups_item
|
||||
IFS='|' read -ra g <<< "$groups"
|
||||
for groups_item in "${g[@]}"; do gargs+=(--group "$groups_item"); done
|
||||
|
||||
mkdir -p "$STATE_DIR"
|
||||
id="$(printf '%s\t%s\t%s' "$file" "$groups" "$key")"
|
||||
if ! grep -qxF -- "$id" <(cut -f1-3 "$journal" 2>/dev/null); then
|
||||
old="$(kreadconfig6 --file "$file" "${gargs[@]}" --key "$key" --default "$UNSET")"
|
||||
printf '%s\t%s\n' "$id" "$(printf '%s' "$old" | base64 -w0)" >> "$journal"
|
||||
fi
|
||||
|
||||
if [[ "$value" == "--delete" ]]; then
|
||||
kwriteconfig6 --file "$file" "${gargs[@]}" --key "$key" --delete
|
||||
else
|
||||
kwriteconfig6 --file "$file" "${gargs[@]}" --key "$key" "$value"
|
||||
fi
|
||||
}
|
||||
|
||||
krevert() {
|
||||
# krevert <component>: restore every key the component changed, newest
|
||||
# first, then forget the journal.
|
||||
local component="$1"
|
||||
local journal="$STATE_DIR/$component.journal"
|
||||
local file groups key old groups_item
|
||||
local -a g
|
||||
[[ -f "$journal" ]] || return 0
|
||||
while IFS=$'\t' read -r file groups key old; do
|
||||
local -a gargs=()
|
||||
IFS='|' read -ra g <<< "$groups"
|
||||
for groups_item in "${g[@]}"; do gargs+=(--group "$groups_item"); done
|
||||
old="$(printf '%s' "$old" | base64 -d)"
|
||||
if [[ "$old" == "$UNSET" ]]; then
|
||||
kwriteconfig6 --file "$file" "${gargs[@]}" --key "$key" --delete
|
||||
else
|
||||
kwriteconfig6 --file "$file" "${gargs[@]}" --key "$key" "$old"
|
||||
fi
|
||||
done < <(tac "$journal")
|
||||
rm -f "$journal"
|
||||
}
|
||||
|
||||
has_journal() {
|
||||
[[ -s "$STATE_DIR/$1.journal" ]]
|
||||
}
|
||||
|
||||
state_set() {
|
||||
# state_set <component> <name> <value>: remember a value for later.
|
||||
mkdir -p "$STATE_DIR"
|
||||
kwriteconfig6 --file "$STATE_DIR/$1.state" --group State --key "$2" "$3"
|
||||
}
|
||||
|
||||
state_get() {
|
||||
# state_get <component> <name> [default]
|
||||
kreadconfig6 --file "$STATE_DIR/$1.state" --group State --key "$2" --default "${3:-}"
|
||||
}
|
||||
|
||||
state_clear() {
|
||||
rm -f "$STATE_DIR/$1.state"
|
||||
}
|
||||
|
||||
current_display_manager() {
|
||||
systemctl show -p Id --value display-manager 2>/dev/null | sed 's/\.service$//'
|
||||
}
|
||||
+32
-76
@@ -1,24 +1,14 @@
|
||||
#!/bin/bash
|
||||
# Steam in the Plasma desktop session: gamepad UI args, virtual keyboard,
|
||||
# autostart, and no screen locking (like SteamOS).
|
||||
# autostart. Part of the SteamOS conversion (gaming_enable/gaming_disable).
|
||||
# Sourced by setup-gamescope-boot.sh; not meant to be run on its own.
|
||||
|
||||
setup_steam_desktop() {
|
||||
# Step 8b: always runs.
|
||||
steam_enable() {
|
||||
info "Applying non-optional SteamOS environment & keyboard fixes..."
|
||||
local steam_env_dir gs_env systemd_user_dir
|
||||
local steam_env_dir systemd_user_dir
|
||||
steam_env_dir="$HOME/.config/environment.d"
|
||||
mkdir -p "$steam_env_dir"
|
||||
|
||||
# 1. Force Gamescope Steam to boot into Deck mode and load Deck glyphs
|
||||
echo "STEAM_GAMEPADUI_ARGS=\"-gamepadui -steamos3\"" > "$steam_env_dir/99-gamescope-steam-glyphs.conf"
|
||||
gs_env="$HOME/.config/gamescope-session/environment"
|
||||
if [[ -d "$HOME/.config/gamescope-session" ]]; then
|
||||
touch "$gs_env"
|
||||
sed -i '/^STEAM_GAMEPADUI_ARGS=/d' "$gs_env"
|
||||
echo "STEAM_GAMEPADUI_ARGS=\"-gamepadui -steamos3\"" >> "$gs_env"
|
||||
fi
|
||||
|
||||
# 2. Prevent KDE Wayland from blocking the virtual keyboard overlay
|
||||
echo "KWIN_IM_SHOW_ALWAYS=1" > "$steam_env_dir/99-kde-virtual-keyboard.conf"
|
||||
|
||||
@@ -54,70 +44,36 @@ EOF
|
||||
ok "Steam UI parameters and keyboard autostart deployed successfully."
|
||||
}
|
||||
|
||||
setup_single_user() {
|
||||
# With SINGLE_USER (chosen in step 1), like SteamOS: one user and no
|
||||
# password prompts, since typing a password with a controller is
|
||||
# miserable. Hides Lock / Switch User / Log Out
|
||||
# everywhere (launcher, Meta+L, Ctrl+Alt+Del) and never locks on idle or
|
||||
# resume; "Return to Gaming Mode" is the way out of the desktop. Declining
|
||||
# restores KDE's defaults.
|
||||
local action allow=true
|
||||
[[ "$SINGLE_USER" == true ]] && allow=false
|
||||
for action in lock_screen switch_user start_new_session; do
|
||||
kwriteconfig6 --file kdeglobals --group "KDE Action Restrictions" --key "action/$action" "$allow"
|
||||
done
|
||||
if [[ "$allow" == false ]]; then
|
||||
kwriteconfig6 --file kscreenlockerrc --group Daemon --key Autolock false
|
||||
kwriteconfig6 --file kscreenlockerrc --group Daemon --key LockOnResume false
|
||||
kwriteconfig6 --file kscreenlockerrc --group Daemon --key Timeout 0
|
||||
# The action restriction hides Lock in menus but not the Meta+L
|
||||
# shortcut; unbind it (format: current,default,description).
|
||||
kwriteconfig6 --file kglobalshortcutsrc --group ksmserver --key "Lock Session" \
|
||||
$'none,Screensaver\tMeta+L,Lock Session'
|
||||
kwriteconfig6 --file kglobalshortcutsrc --group ksmserver --key "Log Out" \
|
||||
'none,Ctrl+Alt+Del,Show Logout Screen'
|
||||
set_launcher_leave_buttons single
|
||||
ok "Screen locking, user switching and logging out disabled."
|
||||
else
|
||||
kwriteconfig6 --file kscreenlockerrc --group Daemon --key Autolock --delete
|
||||
kwriteconfig6 --file kscreenlockerrc --group Daemon --key LockOnResume --delete
|
||||
kwriteconfig6 --file kscreenlockerrc --group Daemon --key Timeout --delete
|
||||
kwriteconfig6 --file kglobalshortcutsrc --group ksmserver --key "Lock Session" \
|
||||
$'Screensaver\tMeta+L,Screensaver\tMeta+L,Lock Session'
|
||||
kwriteconfig6 --file kglobalshortcutsrc --group ksmserver --key "Log Out" \
|
||||
'Ctrl+Alt+Del,Ctrl+Alt+Del,Show Logout Screen'
|
||||
set_launcher_leave_buttons default
|
||||
ok "Keeping KDE's normal screen locking and user switching."
|
||||
fi
|
||||
steam_disable() {
|
||||
info "Removing Steam desktop autostart..."
|
||||
systemctl --user disable --now steam-desktop-autostart.service 2>/dev/null
|
||||
rm -f "$HOME/.config/systemd/user/steam-desktop-autostart.service" \
|
||||
"$HOME/.config/environment.d/99-kde-virtual-keyboard.conf"
|
||||
systemctl --user daemon-reload
|
||||
ok "Steam desktop settings removed (takes full effect at next login)."
|
||||
}
|
||||
|
||||
set_launcher_leave_buttons() {
|
||||
# "single": only Sleep / Restart / Shut Down buttons in the launcher, no
|
||||
# Session dropdown (that's where Log Out lives). Restricting the
|
||||
# "logout" action instead would also hide Restart and Shut Down.
|
||||
# "default": Plasma's own buttons.
|
||||
local mode="$1" applet
|
||||
for applet in $(plasma_applets org.kde.plasma.kickoff); do
|
||||
local -a grp=(--file plasma-org.kde.plasma.desktop-appletsrc --group Containments
|
||||
--group "${applet%%:*}" --group Applets --group "${applet#*:}"
|
||||
--group Configuration --group General)
|
||||
if [[ "$mode" == single ]]; then
|
||||
kwriteconfig6 "${grp[@]}" --key primaryActions 3
|
||||
kwriteconfig6 "${grp[@]}" --key systemFavorites 'suspend,reboot,shutdown'
|
||||
else
|
||||
kwriteconfig6 "${grp[@]}" --key primaryActions --delete
|
||||
kwriteconfig6 "${grp[@]}" --key systemFavorites --delete
|
||||
fi
|
||||
done
|
||||
if pgrep -u "$USER" -x plasmashell >/dev/null; then
|
||||
local js
|
||||
if [[ "$mode" == single ]]; then
|
||||
js="w.writeConfig('primaryActions', 3); w.writeConfig('systemFavorites', 'suspend,reboot,shutdown');"
|
||||
else
|
||||
js="w.writeConfig('primaryActions', 0); w.writeConfig('systemFavorites', 'suspend,hibernate,reboot,shutdown');"
|
||||
fi
|
||||
qdbus6 org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript \
|
||||
"panels().forEach(function (p) { p.widgets('org.kde.plasma.kickoff').forEach(function (w) { w.currentConfigGroup = ['General']; $js w.reloadConfig(); }); })" \
|
||||
>/dev/null 2>&1 || true
|
||||
# "Steam Deck/Machine icons" menu item: Steam's gamepad UI in SteamOS 3
|
||||
# mode, which shows Steam Deck button glyphs in gaming mode.
|
||||
glyphs_status() {
|
||||
[[ -f "$HOME/.config/environment.d/99-gamescope-steam-glyphs.conf" ]]
|
||||
}
|
||||
|
||||
glyphs_enable() {
|
||||
local gs_env="$HOME/.config/gamescope-session/environment"
|
||||
mkdir -p "$HOME/.config/environment.d"
|
||||
echo 'STEAM_GAMEPADUI_ARGS="-gamepadui -steamos3"' > "$HOME/.config/environment.d/99-gamescope-steam-glyphs.conf"
|
||||
if [[ -d "$HOME/.config/gamescope-session" ]]; then
|
||||
touch "$gs_env"
|
||||
sed -i '/^STEAM_GAMEPADUI_ARGS=/d' "$gs_env"
|
||||
echo 'STEAM_GAMEPADUI_ARGS="-gamepadui -steamos3"' >> "$gs_env"
|
||||
fi
|
||||
ok "Steam Deck/Machine icons on (from the next gaming mode start)."
|
||||
}
|
||||
|
||||
glyphs_disable() {
|
||||
rm -f "$HOME/.config/environment.d/99-gamescope-steam-glyphs.conf"
|
||||
[[ -f "$HOME/.config/gamescope-session/environment" ]] &&
|
||||
sed -i '/^STEAM_GAMEPADUI_ARGS=/d' "$HOME/.config/gamescope-session/environment"
|
||||
ok "Steam's default button icons are back (from the next gaming mode start)."
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
# Valve Fremont (Steam Machine) front LED bar driver.
|
||||
# "Steam Machine support" menu item, only on Valve Fremont hardware: the
|
||||
# front LED bar driver, LED access for Steam, and steamos-manager.
|
||||
# Sourced by setup-gamescope-boot.sh; not meant to be run on its own.
|
||||
|
||||
detect_valve_fremont() {
|
||||
@@ -92,22 +93,49 @@ install_valve_led_driver() {
|
||||
warn " ls /sys/class/leds/ | grep valve ; sudo dmesg | grep -i valve"
|
||||
fi
|
||||
|
||||
echo
|
||||
info "Steam only pushes download progress to the LED bar in real SteamOS Game Mode."
|
||||
if ask_yn "Also install the experimental OpenRGB build (openrgb-git), which can drive the LED bar?" n; then
|
||||
"$aur_helper" -S "${flags[@]}" openrgb-git &&
|
||||
ok "openrgb-git installed. Launch OpenRGB to detect and configure the front panel."
|
||||
fi
|
||||
}
|
||||
|
||||
setup_led_driver() {
|
||||
# Step 8c: only on Fremont hardware, and only if the user wants it.
|
||||
if detect_valve_fremont; then
|
||||
info "Detected Valve Fremont hardware (Steam Machine)."
|
||||
if ask_yn "Set up the front-panel LED bar driver (leds-valve) so it isn't stuck dark/breathing?" y; then
|
||||
ensure_aur_helper || warn "Couldn't set up an AUR helper automatically. You can install one yourself later and run: yay -S leds-valve-dkms-git"
|
||||
install_valve_led_driver || warn "LED driver setup ran into a problem - see errors above. Your gamescope boot setup above is unaffected."
|
||||
fi
|
||||
echo
|
||||
fi
|
||||
LED_UDEV_RULE="/etc/udev/rules.d/70-valve-leds-user.rules"
|
||||
|
||||
machine_available() { detect_valve_fremont; }
|
||||
|
||||
machine_status() {
|
||||
pacman -Qi leds-valve-dkms-git >/dev/null 2>&1 && pacman -Qi steamos-manager >/dev/null 2>&1
|
||||
}
|
||||
|
||||
machine_enable() {
|
||||
ensure_aur_helper || { warn "Couldn't set up an AUR helper automatically. Install yay or paru, then run the wizard again."; return 1; }
|
||||
install_valve_led_driver || { warn "LED driver setup ran into a problem - see errors above."; return 1; }
|
||||
|
||||
# The LED files are root-only. Steam runs as the user; let it write them
|
||||
# in case it drives the bar directly (Valve's own privileged-write helper
|
||||
# doesn't cover the Steam Machine's LED bar).
|
||||
info "Letting $TARGET_USER control the LED bar..."
|
||||
sudo tee "$LED_UDEV_RULE" > /dev/null << EOF
|
||||
# Let the console user (and Steam) control the Steam Machine's front LED bar.
|
||||
SUBSYSTEM=="leds", KERNEL=="valve-leds*", RUN+="/usr/bin/find /sys%p -maxdepth 1 -type f -exec /usr/bin/chown $TARGET_USER {} +"
|
||||
EOF
|
||||
sudo udevadm control --reload
|
||||
sudo udevadm trigger --subsystem-match=leds --action=add
|
||||
|
||||
# steamos-manager is what Steam in gaming mode talks to for hardware
|
||||
# settings (fan, HDMI-CEC TV control, performance); it knows the Steam
|
||||
# Machine from its DMI data.
|
||||
info "Installing steamos-manager (Steam Machine hardware settings in Steam)..."
|
||||
sudo pacman -S --needed --noconfirm steamos-manager || { err "Installing steamos-manager failed."; return 1; }
|
||||
sudo systemctl enable --now steamos-manager.service
|
||||
systemctl --user enable steamos-manager.service 2>/dev/null
|
||||
ok "Steam Machine support on."
|
||||
}
|
||||
|
||||
machine_disable() {
|
||||
info "Removing Steam Machine support..."
|
||||
systemctl --user disable --now steamos-manager.service 2>/dev/null
|
||||
sudo systemctl disable --now steamos-manager.service 2>/dev/null
|
||||
sudo pacman -Rns --noconfirm steamos-manager 2>/dev/null
|
||||
sudo rm -f "$LED_UDEV_RULE" /etc/modules-load.d/leds-valve.conf
|
||||
sudo udevadm control --reload
|
||||
sudo modprobe -r leds-valve 2>/dev/null
|
||||
sudo pacman -Rns --noconfirm leds-valve-dkms-git 2>/dev/null
|
||||
ok "Steam Machine support removed (the AUR helper, if installed, is kept)."
|
||||
}
|
||||
+119
-174
@@ -4,22 +4,22 @@
|
||||
|
||||
merge_kde_config() {
|
||||
# Merge a KDE-style ini file (e.g. one of Valve's /etc/xdg defaults) into
|
||||
# the user's own config with kwriteconfig6, so SteamOS defaults win over
|
||||
# the user's own config (journaled, see lib/state.sh), so SteamOS defaults win over
|
||||
# the distro's without touching package-owned files in /etc/xdg.
|
||||
# Nested groups ("[A][B]") are supported; immutable "[$i]" groups and
|
||||
# comments are skipped.
|
||||
local src="$1" target="$2" line key value
|
||||
local -a groups=()
|
||||
local groups=""
|
||||
local skip=0
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
line="${line%$'\r'}"
|
||||
[[ -z "$line" || "$line" == \#* ]] && continue
|
||||
if [[ "$line" == \[* ]]; then
|
||||
skip=0; groups=()
|
||||
skip=0; groups=""
|
||||
[[ "$line" == *'[$'* ]] && { skip=1; continue; }
|
||||
local rest="$line"
|
||||
while [[ "$rest" =~ ^\[([^]]*)\](.*)$ ]]; do
|
||||
groups+=("--group" "${BASH_REMATCH[1]}")
|
||||
groups+="${groups:+|}${BASH_REMATCH[1]}"
|
||||
rest="${BASH_REMATCH[2]}"
|
||||
done
|
||||
continue
|
||||
@@ -27,7 +27,7 @@ merge_kde_config() {
|
||||
(( skip )) && continue
|
||||
[[ "$line" == *=* ]] || continue
|
||||
key="${line%%=*}"; value="${line#*=}"
|
||||
kwriteconfig6 --file "$target" "${groups[@]}" --key "$key" "$value"
|
||||
kset theme "$target" "$groups" "$key" "$value"
|
||||
done < "$src"
|
||||
}
|
||||
|
||||
@@ -113,15 +113,19 @@ install_vapor_theme() {
|
||||
[[ -f "${tmp_dir}/etc/xdg/$f" ]] && merge_kde_config "${tmp_dir}/etc/xdg/$f" "$f"
|
||||
done
|
||||
[[ -f "${tmp_dir}/etc/xdg/kded5rc" ]] && merge_kde_config "${tmp_dir}/etc/xdg/kded5rc" kded6rc
|
||||
kwriteconfig6 --file konsolerc --group "Desktop Entry" --key DefaultProfile Vapor.profile
|
||||
kset theme konsolerc "Desktop Entry" DefaultProfile Vapor.profile
|
||||
mkdir -p ~/.config/gtk-3.0 ~/.config/gtk-4.0
|
||||
kwriteconfig6 --file ~/.config/gtk-3.0/settings.ini --group Settings --key gtk-theme-name Vapor
|
||||
kwriteconfig6 --file ~/.config/gtk-4.0/settings.ini --group Settings --key gtk-theme-name Vapor
|
||||
kset theme ~/.config/gtk-3.0/settings.ini Settings gtk-theme-name Vapor
|
||||
kset theme ~/.config/gtk-4.0/settings.ini Settings gtk-theme-name Vapor
|
||||
# Vapor is a dark theme: tell GTK, libadwaita and portal-aware apps
|
||||
# (Firefox, Steam's web views, Flatpaks) to use their dark variants too.
|
||||
kwriteconfig6 --file ~/.config/gtk-3.0/settings.ini --group Settings --key gtk-application-prefer-dark-theme true
|
||||
kwriteconfig6 --file ~/.config/gtk-4.0/settings.ini --group Settings --key gtk-application-prefer-dark-theme true
|
||||
kset theme ~/.config/gtk-3.0/settings.ini Settings gtk-application-prefer-dark-theme true
|
||||
kset theme ~/.config/gtk-4.0/settings.ini Settings gtk-application-prefer-dark-theme true
|
||||
if command -v gsettings >/dev/null 2>&1; then
|
||||
[[ -n "$(state_get theme gsettings_scheme)" ]] ||
|
||||
state_set theme gsettings_scheme "$(gsettings get org.gnome.desktop.interface color-scheme 2>/dev/null)"
|
||||
[[ -n "$(state_get theme gsettings_gtk)" ]] ||
|
||||
state_set theme gsettings_gtk "$(gsettings get org.gnome.desktop.interface gtk-theme 2>/dev/null)"
|
||||
gsettings set org.gnome.desktop.interface color-scheme prefer-dark 2>/dev/null || true
|
||||
gsettings set org.gnome.desktop.interface gtk-theme Vapor 2>/dev/null || true
|
||||
fi
|
||||
@@ -130,138 +134,52 @@ install_vapor_theme() {
|
||||
info "Cleaning up temporary files..."
|
||||
rm -rf "$tmp_dir"
|
||||
|
||||
# Launcher icon
|
||||
# Remember what to go back to when the theme is turned off again.
|
||||
[[ -n "$(state_get theme lookandfeel)" ]] ||
|
||||
state_set theme lookandfeel "$(kreadconfig6 --file kdeglobals --group KDE --key LookAndFeelPackage \
|
||||
--default "$(kreadconfig6 --file /etc/xdg/kdeglobals --group KDE --key LookAndFeelPackage --default org.kde.breeze.desktop)")"
|
||||
[[ -n "$(state_get theme colorscheme)" ]] ||
|
||||
state_set theme colorscheme "$(kreadconfig6 --file kdeglobals --group General --key ColorScheme --default BreezeLight)"
|
||||
|
||||
local appletsrc="plasma-org.kde.plasma.desktop-appletsrc" applet
|
||||
|
||||
# Same launcher icon SteamOS sets (Vapor Deck plasmoid setup script).
|
||||
local icon_name="distributor-logo-steamdeck"
|
||||
local conf_file="$HOME/.config/plasma-org.kde.plasma.desktop-appletsrc"
|
||||
for applet in $(plasma_applets org.kde.plasma.kickoff); do
|
||||
kset theme "$appletsrc" "Containments|${applet%%:*}|Applets|${applet#*:}|Configuration|General" icon distributor-logo-steamdeck
|
||||
done
|
||||
# SteamOS scales tray icons to the panel height. Valve's setup script
|
||||
# targets Plasma 5's separate tray containment; in Plasma 6 the setting
|
||||
# lives on the systemtray applet itself.
|
||||
for applet in $(plasma_applets org.kde.plasma.systemtray); do
|
||||
kset theme "$appletsrc" "Containments|${applet%%:*}|Applets|${applet#*:}|General" scaleIconsToFit true
|
||||
done
|
||||
# SteamOS shows the date below the time.
|
||||
for applet in $(plasma_applets org.kde.plasma.digitalclock); do
|
||||
kset theme "$appletsrc" "Containments|${applet%%:*}|Applets|${applet#*:}|Configuration|Appearance" dateDisplayFormat BelowTime
|
||||
done
|
||||
|
||||
if ! find ~/.local/share/icons /usr/share/icons -iname "${icon_name}.*" 2>/dev/null | grep -q .; then
|
||||
warn "Could not find '${icon_name}' installed anywhere under ~/.local/share/icons or /usr/share/icons."
|
||||
warn "The launcher icon will be set anyway, but it may show as a broken icon until the file is installed."
|
||||
fi
|
||||
|
||||
if [[ -f "$conf_file" ]]; then
|
||||
info "Looking for the Application Launcher applet (Kickoff/Kicker) to set the custom icon..."
|
||||
local matches=()
|
||||
local current_section=""
|
||||
local current_containment=""
|
||||
local current_applet=""
|
||||
|
||||
while IFS= read -r line; do
|
||||
if [[ "$line" =~ ^\[Containments\]\[([0-9]+)\]\[Applets\]\[([0-9]+)\]$ ]]; then
|
||||
current_containment="${BASH_REMATCH[1]}"
|
||||
current_applet="${BASH_REMATCH[2]}"
|
||||
current_section="applet_root"
|
||||
continue
|
||||
fi
|
||||
if [[ "$line" =~ ^\[ ]]; then
|
||||
current_section=""
|
||||
continue
|
||||
fi
|
||||
if [[ "$current_section" == "applet_root" && "$line" =~ ^plugin=(org\.kde\.plasma\.(kickoff|kicker|simplemenu|homerun|application-menu))$ ]]; then
|
||||
matches+=( "${current_containment}:${current_applet}:${BASH_REMATCH[1]}" )
|
||||
current_section=""
|
||||
fi
|
||||
done < "$conf_file"
|
||||
|
||||
if [[ ${#matches[@]} -gt 0 ]]; then
|
||||
for m in "${matches[@]}"; do
|
||||
IFS=':' read -r containment applet plugin <<< "$m"
|
||||
info "Setting launcher icon on Containment $containment / Applet $applet ($plugin)..."
|
||||
kwriteconfig6 \
|
||||
--file "$conf_file" \
|
||||
--group Containments --group "$containment" \
|
||||
--group Applets --group "$applet" \
|
||||
--group Configuration --group General \
|
||||
--key icon "$icon_name"
|
||||
ok "Icon set to '$icon_name'."
|
||||
done
|
||||
else
|
||||
warn "No compatible Application Launcher applet found in panel config. Skipping icon assignment."
|
||||
fi
|
||||
else
|
||||
warn "$conf_file not found. Skipping menu icon configuration."
|
||||
fi
|
||||
|
||||
# SteamOS scales system tray icons to the panel height. Valve's setup
|
||||
# script targets Plasma 5's separate tray containment; in Plasma 6 the
|
||||
# setting lives on the systemtray applet itself.
|
||||
if [[ -f "$conf_file" ]]; then
|
||||
local tray
|
||||
for tray in $(awk '
|
||||
/^\[Containments\]\[[0-9]+\]\[Applets\]\[[0-9]+\]$/ { split($0, p, /[][]+/); sect = p[3] ":" p[5] }
|
||||
/^\[/ && !/\]\[Applets\]\[[0-9]+\]$/ { sect = "" }
|
||||
/^plugin=org\.kde\.plasma\.systemtray$/ && sect != "" { print sect }
|
||||
' "$conf_file"); do
|
||||
kwriteconfig6 --file "$conf_file" --group Containments --group "${tray%%:*}" \
|
||||
--group Applets --group "${tray#*:}" --group General \
|
||||
--key scaleIconsToFit true
|
||||
# Wallpaper: Valve ships them as flat JPGs in usr/share/wallpapers.
|
||||
local wallpaper="$HOME/.local/share/wallpapers/Steam Deck Logo Default.jpg" containment
|
||||
if [[ -f "$wallpaper" ]]; then
|
||||
for containment in $(grep -oP '^\[Containments\]\[\K[0-9]+(?=\]$)' ~/.config/"$appletsrc" 2>/dev/null); do
|
||||
grep -q "^\[Containments\]\[$containment\]\[Wallpaper\]" ~/.config/"$appletsrc" || continue
|
||||
kset theme "$appletsrc" "Containments|$containment|Wallpaper|org.kde.image|General" Image "file://$wallpaper"
|
||||
done
|
||||
fi
|
||||
|
||||
# SteamOS shows the date below the time in the panel clock.
|
||||
if [[ -f "$conf_file" ]]; then
|
||||
local clock
|
||||
for clock in $(awk '
|
||||
/^\[Containments\]\[[0-9]+\]\[Applets\]\[[0-9]+\]$/ { split($0, p, /[][]+/); sect = p[3] ":" p[5] }
|
||||
/^\[/ && !/\]\[Applets\]\[[0-9]+\]$/ { sect = "" }
|
||||
/^plugin=org\.kde\.plasma\.digitalclock$/ && sect != "" { print sect }
|
||||
' "$conf_file"); do
|
||||
kwriteconfig6 --file "$conf_file" --group Containments --group "${clock%%:*}" \
|
||||
--group Applets --group "${clock#*:}" --group Configuration --group Appearance \
|
||||
--key dateDisplayFormat BelowTime
|
||||
done
|
||||
fi
|
||||
# Vapor color scheme and Plasma style; the theme's own defaults use
|
||||
# breeze-dark icons (there is no "Vapor" icon theme).
|
||||
kset theme kdeglobals KDE LookAndFeelPackage com.valve.vapor.desktop
|
||||
kset theme kdeglobals Icons Theme breeze-dark
|
||||
kset theme kdeglobals General ColorScheme Vapor
|
||||
kset theme plasmarc Theme name Vapor
|
||||
|
||||
# Wallpaper
|
||||
# Valve ships the wallpapers as flat JPGs in usr/share/wallpapers.
|
||||
local wallpaper_path="$HOME/.local/share/wallpapers/Steam Deck Logo Default.jpg"
|
||||
|
||||
if [[ -f "$wallpaper_path" ]]; then
|
||||
info "Applying official Steam Deck Vapor wallpaper via D-Bus script..."
|
||||
local dbus_cmd="
|
||||
var allDesktops = desktops();
|
||||
for (var i = 0; i < allDesktops.length; i++) {
|
||||
var d = allDesktops[i];
|
||||
d.currentConfigGroup = ['Wallpaper', 'org.kde.image', 'General'];
|
||||
d.writeConfig('Image', 'file://${wallpaper_path}');
|
||||
}
|
||||
"
|
||||
if ! pgrep -u "$USER" -x plasmashell >/dev/null; then
|
||||
:
|
||||
elif command -v qdbus6 >/dev/null 2>&1; then
|
||||
qdbus6 org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "$dbus_cmd" >/dev/null 2>&1 || true
|
||||
else
|
||||
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "$dbus_cmd" >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
if [[ -f "$conf_file" ]]; then
|
||||
local desktop_sections=$(grep -E '^\[Containments\]\[[0-9]+\]$' "$conf_file" || true)
|
||||
while read -r section; do
|
||||
if [[ -n "$section" ]]; then
|
||||
local clean_sec=$(echo "$section" | tr -d '[]')
|
||||
kwriteconfig6 --file "$conf_file" --group "$clean_sec" --group Wallpaper --group org.kde.image --group General --key Image "file://${wallpaper_path}"
|
||||
fi
|
||||
done <<< "$desktop_sections"
|
||||
fi
|
||||
ok "Wallpaper path pushed to session config."
|
||||
else
|
||||
warn "Could not find extracted Vapor wallpaper file. Skipping."
|
||||
fi
|
||||
|
||||
# Activate the Vapor global theme and color scheme, then restart
|
||||
# plasmashell once so it picks everything up (restarting first races
|
||||
# with the settings being written). The theme's own defaults use
|
||||
# breeze-dark icons; there is no "Vapor" icon theme.
|
||||
kwriteconfig6 --file kdeglobals --group Icons --key Theme "breeze-dark"
|
||||
kwriteconfig6 --file kdeglobals --group General --key ColorScheme "Vapor"
|
||||
kwriteconfig6 --file plasmarc --group Theme --key name "Vapor"
|
||||
|
||||
# Same panel change for the next login, in case Plasma isn't running now.
|
||||
# SteamOS uses a solid, full-width bottom panel at Plasma's stock 44px
|
||||
# height (CachyOS ships a floating 30px one).
|
||||
local panel
|
||||
for panel in $(grep -oP '^\[PlasmaViews\]\[Panel \K[0-9]+(?=\]$)' ~/.config/plasmashellrc 2>/dev/null); do
|
||||
kwriteconfig6 --file plasmashellrc --group PlasmaViews --group "Panel $panel" --key floating 0
|
||||
kwriteconfig6 --file plasmashellrc --group PlasmaViews --group "Panel $panel" --group Defaults --key thickness 44
|
||||
kset theme plasmashellrc "PlasmaViews|Panel $panel" floating 0
|
||||
kset theme plasmashellrc "PlasmaViews|Panel $panel|Defaults" thickness 44
|
||||
done
|
||||
|
||||
gtk-update-icon-cache -f -t ~/.local/share/icons/hicolor 2>/dev/null || true
|
||||
@@ -269,56 +187,83 @@ install_vapor_theme() {
|
||||
|
||||
# Live changes need a running Plasma session; otherwise they are picked
|
||||
# up from the config files above at the next Plasma login.
|
||||
if pgrep -u "$USER" -x plasmashell >/dev/null; then
|
||||
if [[ "${PLASMASHELL_WAS_RUNNING:-false}" == true ]]; then
|
||||
info "Applying the theme to the running Plasma session..."
|
||||
lookandfeeltool -a com.valve.vapor.desktop >/dev/null 2>&1 || true
|
||||
# lookandfeeltool leaves the distro's color scheme active; apply it explicitly.
|
||||
plasma-apply-colorscheme Vapor >/dev/null 2>&1 || true
|
||||
qdbus6 org.kde.kded6 /modules/gtkconfig org.kde.gtkconfig.setGtkTheme Vapor >/dev/null 2>&1 || true
|
||||
qdbus6 org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript \
|
||||
'panels().forEach(function (p) {
|
||||
p.widgets("org.kde.plasma.systemtray").forEach(function (w) { w.currentConfigGroup = ["General"]; w.writeConfig("scaleIconsToFit", true); });
|
||||
p.widgets("org.kde.plasma.digitalclock").forEach(function (w) { w.currentConfigGroup = ["Appearance"]; w.writeConfig("dateDisplayFormat", "BelowTime"); });
|
||||
})' \
|
||||
>/dev/null 2>&1 || true
|
||||
# SteamOS uses a solid, full-width bottom panel at Plasma's stock
|
||||
# 44px height (CachyOS ships a floating 30px one).
|
||||
qdbus6 org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript \
|
||||
'panels().forEach(function (p) { p.floating = false; p.lengthMode = "fill"; p.height = 44; })' \
|
||||
>/dev/null 2>&1 || true
|
||||
sleep 2 # let plasmashell flush the scripted changes before replacing it
|
||||
rm -rf ~/.cache/plasmashell* ~/.cache/org.kde.dirmodel-qml.kcache
|
||||
qdbus6 org.kde.KWin /KWin org.kde.KWin.reconfigure >/dev/null 2>&1 || true
|
||||
# Restart through systemd so plasmashell keeps the session's environment
|
||||
# (platform theme etc.); a plain --replace from this shell may not.
|
||||
if systemctl --user cat plasma-plasmashell.service >/dev/null 2>&1; then
|
||||
# Also takes over from a stray instance started by an earlier --replace.
|
||||
systemctl --user stop plasma-plasmashell.service
|
||||
pkill -u "$USER" -x plasmashell && sleep 2
|
||||
systemctl --user start plasma-plasmashell.service
|
||||
else
|
||||
setsid plasmashell --replace >/dev/null 2>&1 &
|
||||
fi
|
||||
else
|
||||
info "No running Plasma session; the theme applies at your next desktop login."
|
||||
fi
|
||||
|
||||
ok "Vapor theme assets installed. Apply it under System Settings > Appearance"
|
||||
ok "> Global Theme > Vapor (Steam Deck), next time you're in a Plasma session."
|
||||
ok "SteamOS desktop look installed."
|
||||
}
|
||||
|
||||
setup_vapor_theme() {
|
||||
# Step 9 (optional): ask, make sure curl/zstd exist, then install.
|
||||
echo
|
||||
if ask_yn "Also install Valve's official Vapor (Steam Deck) KDE theme for your desktop session?" n; then
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
warn "curl not found, installing it first..."
|
||||
sudo pacman -S --needed --noconfirm curl
|
||||
fi
|
||||
if ! command -v unzstd >/dev/null 2>&1; then
|
||||
warn "zstd not found, installing it first..."
|
||||
sudo pacman -S --needed --noconfirm zstd
|
||||
fi
|
||||
install_vapor_theme || warn "Vapor theme install ran into a problem - see errors above. Your gamescope boot setup above is unaffected."
|
||||
theme_status() {
|
||||
[[ "$(kreadconfig6 --file kdeglobals --group KDE --key LookAndFeelPackage)" == com.valve.vapor.desktop ]]
|
||||
}
|
||||
|
||||
theme_enable() {
|
||||
command -v curl >/dev/null 2>&1 || sudo pacman -S --needed --noconfirm curl
|
||||
command -v unzstd >/dev/null 2>&1 || sudo pacman -S --needed --noconfirm zstd
|
||||
# Stop plasmashell first: the panel and wallpaper edits go to files it
|
||||
# would otherwise overwrite with its in-memory config on exit.
|
||||
stop_plasmashell_for_edit
|
||||
install_vapor_theme
|
||||
local rc=$?
|
||||
restart_plasmashell_if_stopped
|
||||
(( rc == 0 )) || warn "Vapor theme install ran into a problem - see errors above."
|
||||
return $rc
|
||||
}
|
||||
|
||||
theme_disable() {
|
||||
info "Restoring the previous desktop look..."
|
||||
local lookandfeel colorscheme
|
||||
lookandfeel="$(state_get theme lookandfeel org.kde.breeze.desktop)"
|
||||
colorscheme="$(state_get theme colorscheme BreezeLight)"
|
||||
|
||||
stop_plasmashell_for_edit
|
||||
if has_journal theme; then
|
||||
krevert theme
|
||||
else
|
||||
# Installed by a version of this script without the undo journal:
|
||||
# undo the main settings it made.
|
||||
kwriteconfig6 --file kdeglobals --group KDE --key LookAndFeelPackage --delete
|
||||
kwriteconfig6 --file kdeglobals --group General --key ColorScheme --delete
|
||||
kwriteconfig6 --file kdeglobals --group Icons --key Theme --delete
|
||||
kwriteconfig6 --file plasmarc --group Theme --key name --delete
|
||||
local f
|
||||
for f in ~/.config/gtk-3.0/settings.ini ~/.config/gtk-4.0/settings.ini; do
|
||||
[[ -f "$f" ]] || continue
|
||||
kwriteconfig6 --file "$f" --group Settings --key gtk-theme-name --delete
|
||||
kwriteconfig6 --file "$f" --group Settings --key gtk-application-prefer-dark-theme --delete
|
||||
done
|
||||
kwriteconfig6 --file konsolerc --group "Desktop Entry" --key DefaultProfile --delete
|
||||
fi
|
||||
if command -v gsettings >/dev/null 2>&1; then
|
||||
local v
|
||||
v="$(state_get theme gsettings_scheme)"
|
||||
if [[ -n "$v" ]]; then gsettings set org.gnome.desktop.interface color-scheme "$v" 2>/dev/null
|
||||
else gsettings reset org.gnome.desktop.interface color-scheme 2>/dev/null; fi
|
||||
v="$(state_get theme gsettings_gtk)"
|
||||
if [[ -n "$v" ]]; then gsettings set org.gnome.desktop.interface gtk-theme "$v" 2>/dev/null
|
||||
else gsettings reset org.gnome.desktop.interface gtk-theme 2>/dev/null; fi
|
||||
fi
|
||||
rm -rf ~/.local/share/plasma/look-and-feel/com.valve.vapor.desktop \
|
||||
~/.local/share/plasma/desktoptheme/Vapor \
|
||||
~/.local/share/themes/Vapor \
|
||||
~/.local/share/color-schemes/Vapor.colors ~/.local/share/color-schemes/VGUI.colors \
|
||||
~/.local/share/konsole/Vapor.profile ~/.local/share/konsole/Vapor.colorscheme \
|
||||
~/.local/share/wallpapers/Steam\ Deck\ Logo*.jpg ~/.local/share/wallpapers/Troll.jpg
|
||||
rm -f ~/.gtkrc-2.0
|
||||
kbuildsycoca6 --noincremental 2>/dev/null || true
|
||||
|
||||
if [[ -n "${WAYLAND_DISPLAY:-}${DISPLAY:-}" ]]; then
|
||||
lookandfeeltool -a "$lookandfeel" >/dev/null 2>&1 || true
|
||||
plasma-apply-colorscheme "$colorscheme" >/dev/null 2>&1 || true
|
||||
fi
|
||||
restart_plasmashell_if_stopped
|
||||
state_clear theme
|
||||
ok "Previous desktop look restored."
|
||||
}
|
||||
Reference in new issue
Block a user