From 2e51d1d3f370d4bed83317170ed5c4db743d6878 Mon Sep 17 00:00:00 2001 From: Rick Peters Date: Thu, 1 Oct 2026 23:04:18 +0200 Subject: [PATCH] feat: "Start Steam silently" sub-option for the SteamOS conversion (silent) and Gaming on NVIDIA (nvsilent) --- TECHNICAL.md | 9 +++++---- lib/backend.sh | 8 +++++++- lib/menu.sh | 41 +++++++++++++++++++++++++++++++++-------- lib/nvidia.sh | 20 +++++++++++++++++++- lib/steam-desktop.sh | 37 ++++++++++++++++++++++++------------- ui/qml/AppState.qml | 14 ++++++++++---- ui/qml/Texts.qml | 6 ++++++ 7 files changed, 104 insertions(+), 31 deletions(-) diff --git a/TECHNICAL.md b/TECHNICAL.md index aea2016..c468b92 100644 --- a/TECHNICAL.md +++ b/TECHNICAL.md @@ -108,9 +108,9 @@ tools write to the conf.d fragment into the base config. (never `zz-steamos-autologin.conf`, which CachyOS's tools own), and installs `/usr/local/bin/sync-steamos-session.sh` plus `sync-steamos-session.path`/`.service`; -- `KWIN_IM_SHOW_ALWAYS=1` for the virtual keyboard and a - `steam-desktop-autostart` systemd user service that starts Steam silently - in Plasma only; +- `KWIN_IM_SHOW_ALWAYS=1` for the virtual keyboard; the sub-option `silent` + ("Start Steam silently", on by default) adds a `steam-desktop-autostart` + systemd user service that starts Steam silently in Plasma only; - the **Return to Gaming Mode** shortcut; on plasma-login-manager with a narrow sudoers rule (`/etc/sudoers.d/gamescope-session-switch`) so it can restart the login manager without a password prompt. @@ -242,7 +242,8 @@ Steam at login): it installs `steam` when missing (recorded in state `nvidia`, r unit `steamify-steam-autostart.service` (`services/`, `ExecStart=/usr/bin/steam @ARGS@`, Plasma only). Its sub-option `bigpicture` ("Steam starts in Big Picture", ticked along with it) rewrites the unit with `-gamepadui` and sets `ksmserverrc [General] loginMode=emptySession` (`kset`, undone with `krevert bigpicture`), so windows of the last session -(Discord, a browser) aren't restored on top of Big Picture; unticked, Steam starts in its normal window. The PC always boots into the desktop: there is no gamescope session. Takes effect at the next +(Discord, a browser) aren't restored on top of Big Picture; unticked, Steam starts in its normal window. The opt-in sub-option `nvsilent` ("Start Steam silently") rewrites the unit with `-silent` +(tray only); it and `bigpicture` exclude each other. The PC always boots into the desktop: there is no gamescope session. Takes effect at the next login. On a supported card (RTX 20 series or newer: not on chwd's legacy lists `/var/lib/chwd/ids/nvidia-*.ids`, the VRAM booster's diff --git a/lib/backend.sh b/lib/backend.sh index 31afcc6..975f9d7 100644 --- a/lib/backend.sh +++ b/lib/backend.sh @@ -50,6 +50,7 @@ backend_status() { items+="${items:+,}{\"id\":$(json_str "$c"),\"label\":$(json_str "${LABEL[$c]%%:*}")" items+=",\"hint\":$(json_str "$( [[ "${LABEL[$c]}" == *:* ]] && echo "${LABEL[$c]#*: }")")" items+=",\"kind\":\"$kind\",\"parent\":$(json_str "$parent")" + items+=",\"needs\":$(json_str "$([[ "$c" == silent ]] && silent_needs_boot && echo boot)")" items+=",\"on\":$( [[ "$now" == 1 ]] && echo true || echo false)" items+=",\"wanted\":$( [[ "${WANTED[$c]:-0}" == 1 ]] && echo true || echo false)" items+=",\"update\":$(feature_outdated "$c" && echo true || echo false)" @@ -154,7 +155,11 @@ backend_apply() { WANTED[boot]=0 fi [[ "${WANTED[bigpicture]:-0}" == 1 ]] && WANTED[nvidia]=1 - [[ "${WANTED[nvidia]:-0}" == 0 ]] && WANTED[bigpicture]=0 + [[ "${WANTED[nvsilent]:-0}" == 1 ]] && WANTED[nvidia]=1 + [[ "${WANTED[bigpicture]:-0}" == 1 ]] && WANTED[nvsilent]=0 + [[ "${WANTED[nvidia]:-0}" == 0 ]] && { WANTED[bigpicture]=0; WANTED[nvsilent]=0; } + [[ "${WANTED[silent]:-0}" == 1 ]] && component_available gaming && WANTED[gaming]=1 + [[ "${WANTED[gaming]:-0}" == 0 ]] && WANTED[silent]=0 [[ "${WANTED[poweroff]:-0}" == 1 ]] && WANTED[machine]=1 [[ "${WANTED[machine]:-0}" == 0 ]] && WANTED[poweroff]=0 [[ "${WANTED[kpin]:-0}" == 1 ]] && WANTED[machine]=1 @@ -162,6 +167,7 @@ backend_apply() { # Retired: only ever removed. WANTED[hdmi]=0 case "$boot" in desktop) WANTED[boot]=1; WANTED[gaming]=1 ;; gamescope) WANTED[boot]=0 ;; esac + silent_normalize REAPPLY=$reapply plan_changes diff --git a/lib/menu.sh b/lib/menu.sh index 4cb8d4c..abc2039 100644 --- a/lib/menu.sh +++ b/lib/menu.sh @@ -5,19 +5,19 @@ # Menu order. Components are turned on in this order and off in reverse; # gaming must come first (single user builds on it). -COMPONENTS=(gaming boot nvidia bigpicture theme glyphs single launcher steamgame notify extended_controller_support vram cec machine poweroff kpin hdmi bios) +COMPONENTS=(gaming boot silent nvidia bigpicture nvsilent theme glyphs single launcher steamgame notify extended_controller_support vram cec machine poweroff kpin hdmi bios) # One-off actions rather than on/off components: never preselected, never # re-applied, not listed as on or off. ACTIONS=(bios) # Sub-options, shown indented under their parent and only while it's ticked. -declare -A PARENT=([boot]=gaming [bigpicture]=nvidia [steamgame]=launcher [poweroff]=machine [kpin]=machine [hdmi]=machine [bios]=machine) +declare -A PARENT=([boot]=gaming [silent]=gaming [bigpicture]=nvidia [nvsilent]=nvidia [steamgame]=launcher [poweroff]=machine [kpin]=machine [hdmi]=machine [bios]=machine) # Never preselected on a first run: booting into the desktop is a choice, # gamescope is the default; HDMI-CEC is opt-in (it can wake the machine or # upset other devices on the TV, even on SteamOS), except on a Steam Machine, # which has CEC like on SteamOS. HDMI refresh boost needs someone at the # screen to confirm each step. Extended controller support builds kernel modules for # every installed kernel: opt-in. -NO_PRESELECT=(boot cec kpin hdmi extended_controller_support) +NO_PRESELECT=(boot nvsilent cec kpin hdmi extended_controller_support) # Feature versions: the Steamify version in which what a component's enable # sets up last changed; set it to the new VERSION whenever you change one. # Each successful run records it (state "features"); a component that's on @@ -26,7 +26,7 @@ NO_PRESELECT=(boot cec kpin hdmi extended_controller_support) # FEATURE_BASELINE. FEATURE_BASELINE=2.1.0 declare -A FEATURE_VERSION=( - [gaming]=2.9.0 [boot]=2.1.0 [nvidia]=2.10.0 [bigpicture]=2.10.0 [theme]=2.1.0 [glyphs]=2.1.0 [single]=2.1.0 + [gaming]=2.9.0 [boot]=2.1.0 [silent]=2.1.0 [nvidia]=2.10.0 [bigpicture]=2.10.0 [nvsilent]=2.11.0 [theme]=2.1.0 [glyphs]=2.1.0 [single]=2.1.0 [launcher]=2.1.0 [cec]=2.7.0 [machine]=2.9.0 [poweroff]=2.2.0 [vram]=2.3.0 [notify]=2.5.0 [steamgame]=2.5.1 [extended_controller_support]=2.10.0 [kpin]=2.1.0 [hdmi]=2.1.0 ) @@ -35,6 +35,8 @@ declare -A LABEL=( [gaming]="SteamOS conversion: boot into gaming mode, Steam on the desktop" [boot]="Boot into the desktop instead of gaming mode" [nvidia]="Gaming on NVIDIA: Steam on the desktop, started at login" + [silent]="Start Steam silently: in the tray at login on the desktop, no window" + [nvsilent]="Start Steam silently: in the tray at login, no window (untick: Steam's normal window)" [bigpicture]="Steam starts in Big Picture: the controller-friendly Steam (untick: Steam's normal window)" [theme]="Install SteamOS theme: Vapor look (cachyos-vapor)" [glyphs]="Install Steam Deck/Machine icons: Deck button icons in gaming mode" @@ -57,9 +59,9 @@ component_available() { case "$1" in # gamescope's own session is broken on NVIDIA: the conversion is replaced by "Gaming on NVIDIA" there (shown # anyway when it's already on, so it can be turned off). - gaming|boot|glyphs) ! nvidia_present || gaming_status ;; + gaming|boot|silent|glyphs) ! nvidia_present || gaming_status ;; nvidia) nvidia_available ;; - bigpicture) bigpicture_available ;; + bigpicture|nvsilent) bigpicture_available ;; machine|poweroff) machine_available ;; vram) vram_available ;; # Steamify in the Steam library is for gaming mode's controller: not needed for Big Picture on the desktop (NVIDIA PCs; @@ -79,10 +81,25 @@ boot_mode() { if [[ "$1" == 1 ]]; then echo desktop; else echo gamescope; fi } +silent_needs_boot() { + # On a Steam Machine, silent start only makes sense when it boots into + # the desktop (gaming mode starts its own Steam): the option is hidden, + # and off, while "Boot into" is gaming mode. + machine_available +} + +silent_normalize() { + silent_needs_boot && [[ "${WANTED[boot]:-0}" != 1 ]] && WANTED[silent]=0 + return 0 +} + menu_visible() { # Shown in the menu. A sub-option ("Boot into", the kernel pin) only # while its parent is ticked. component_available "$1" || return 1 + # Silent start is hidden while Steam starts in Big Picture. + [[ "$1" == nvsilent && "${WANTED[bigpicture]:-0}" == 1 ]] && return 1 + [[ "$1" == silent ]] && silent_needs_boot && [[ "${WANTED[boot]:-0}" != 1 ]] && return 1 [[ -z "${PARENT[$1]:-}" || "${WANTED[${PARENT[$1]}]:-0}" == 1 ]] } @@ -203,6 +220,7 @@ detect_components() { done machine_available && WANTED[cec]=1 fi + silent_normalize } defaults_options() { @@ -259,6 +277,7 @@ defaults_options() { WANTED[boot]=1 ;; gamescope) WANTED[boot]=0 ;; esac + silent_normalize return 0 } @@ -282,7 +301,7 @@ defaults_list() { [[ "$c" == cec ]] && machine_available && on=true items+="${items:+,}{\"id\":$(json_str "$c"),\"label\":$(json_str "${LABEL[$c]%%:*}")" items+=",\"hint\":$(json_str "$( [[ "${LABEL[$c]}" == *:* ]] && echo "${LABEL[$c]#*: }")")" - items+=",\"kind\":\"$kind\",\"parent\":$(json_str "${PARENT[$c]:-}"),\"on\":$on,\"selectable\":$sel}" + items+=",\"kind\":\"$kind\",\"parent\":$(json_str "${PARENT[$c]:-}"),\"needs\":$(json_str "$([[ "$c" == silent ]] && silent_needs_boot && echo boot)"),\"hideWhen\":$(json_str "$([[ "$c" == nvsilent ]] && echo bigpicture)"),\"on\":$on,\"selectable\":$sel}" done printf '[%s]\n' "$items" } @@ -299,7 +318,13 @@ toggle_component() { if [[ "$c" == boot && "${WANTED[boot]}" == 1 ]]; then WANTED[gaming]=1; fi # Big Picture is opt-out: ticked along with "Gaming on NVIDIA". if [[ "$c" == nvidia ]]; then WANTED[bigpicture]=${WANTED[nvidia]}; fi - if [[ "$c" == bigpicture && "${WANTED[bigpicture]}" == 1 ]]; then WANTED[nvidia]=1; fi + if [[ "$c" == bigpicture && "${WANTED[bigpicture]}" == 1 ]]; then WANTED[nvidia]=1; WANTED[nvsilent]=0; fi + # Silent and Big Picture exclude each other. + if [[ "$c" == nvsilent && "${WANTED[nvsilent]}" == 1 ]]; then WANTED[nvidia]=1; WANTED[bigpicture]=0; fi + if [[ "$c" == nvidia && "${WANTED[nvidia]}" == 0 ]]; then WANTED[nvsilent]=0; fi + if [[ "$c" == gaming && "${WANTED[gaming]}" == 0 ]]; then WANTED[silent]=0; fi + if [[ "$c" == silent && "${WANTED[silent]}" == 1 ]]; then WANTED[gaming]=1; fi + silent_normalize # The power-off fix is opt-out: ticked along with Steam Machine support. if [[ "$c" == machine ]]; then WANTED[poweroff]=${WANTED[machine]}; fi if [[ "$c" == poweroff && "${WANTED[poweroff]}" == 1 ]]; then WANTED[machine]=1; fi diff --git a/lib/nvidia.sh b/lib/nvidia.sh index bb8ecc1..7bc10f7 100644 --- a/lib/nvidia.sh +++ b/lib/nvidia.sh @@ -57,7 +57,8 @@ nvidia_enable() { state_set nvidia installed_pkgs steam fi # Keeps what the Big Picture option set up; a first run starts Steam normally. - local unit_args=""; bigpicture_status && unit_args=-gamepadui + local unit_args="" + if bigpicture_status; then unit_args=-gamepadui; elif nvsilent_status; then unit_args=-silent; fi nvidia_write_unit "$unit_args" || return 1 user_systemctl enable "$NVIDIA_UNIT" >/dev/null 2>&1 || { err "Enabling $NVIDIA_UNIT failed."; return 1; } nvidia_kernel_enable || return 1 @@ -96,6 +97,23 @@ bigpicture_disable() { nvidia_write_unit "" && ok "Steam starts in its normal window at your next login." } +# Sub-option: Steam starts silently (tray only, no window). Big Picture and +# a silent start exclude each other (the menus untick one when the other is +# ticked); a first run with both gets Big Picture. +nvsilent_status() { grep -qs -- '-silent' "$(nvidia_unit_file)"; } + +nvsilent_enable() { + [[ -f "$(nvidia_unit_file)" ]] || return 0 + bigpicture_status && return 0 + nvidia_write_unit -silent || return 1 + ok "Steam starts silently at your next login." +} + +nvsilent_disable() { + nvsilent_status || return 0 + nvidia_write_unit "" && ok "Steam starts in its normal window at your next login." +} + # --- Kernel parameters and early modules (a supported card only) nvidia_supported() { diff --git a/lib/steam-desktop.sh b/lib/steam-desktop.sh index 51216fe..641c5ec 100644 --- a/lib/steam-desktop.sh +++ b/lib/steam-desktop.sh @@ -5,35 +5,46 @@ steam_enable() { info "Applying non-optional SteamOS environment & keyboard fixes..." - local steam_env_dir systemd_user_dir + local steam_env_dir steam_env_dir="$HOME/.config/environment.d" mkdir -p "$steam_env_dir" # 2. Prevent KDE Wayland from blocking the virtual keyboard overlay echo "KWIN_IM_SHOW_ALWAYS=1" > "$steam_env_dir/99-kde-virtual-keyboard.conf" - # 3. Setup robust background systemd service for Steam autostart on Desktop Mode - systemd_user_dir="$HOME/.config/systemd/user" + ok "Steam UI parameters and keyboard fix deployed successfully." +} + +# Sub-option of the SteamOS conversion: Steam starts silently (in the tray, +# no window) on the Plasma desktop. +silent_status() { + [[ -f "$HOME/.config/systemd/user/steam-desktop-autostart.service" ]] +} + +silent_enable() { + local systemd_user_dir="$HOME/.config/systemd/user" mkdir -p "$systemd_user_dir" - service_file steam-desktop-autostart.service > "$systemd_user_dir/steam-desktop-autostart.service" - # Clean out old .desktop shortcut so they don't fight rm -f "$HOME/.config/autostart/steam.desktop" - - # Reload user systemd context and activate the background loop user_systemctl daemon-reload user_systemctl enable --now steam-desktop-autostart.service + ok "Steam starts silently on the desktop." +} - ok "Steam UI parameters and keyboard autostart deployed successfully." +silent_disable() { + user_systemctl disable --now steam-desktop-autostart.service 2>/dev/null + rm -f "$HOME/.config/systemd/user/steam-desktop-autostart.service" + user_systemctl daemon-reload + ok "Steam no longer starts by itself on the desktop." } steam_disable() { - info "Removing Steam desktop autostart..." - user_systemctl 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" - user_systemctl daemon-reload + info "Removing Steam desktop settings..." + # The autostart unit is the `silent` option's: removed with it, and here + # too for when the conversion goes off by itself. + silent_status && silent_disable + rm -f "$HOME/.config/environment.d/99-kde-virtual-keyboard.conf" ok "Steam desktop settings removed (takes full effect at next login)." } diff --git a/ui/qml/AppState.qml b/ui/qml/AppState.qml index f24bac6..26027d1 100644 --- a/ui/qml/AppState.qml +++ b/ui/qml/AppState.qml @@ -38,7 +38,9 @@ Item { readonly property var status: backend.status || ({}) readonly property var items: status.items || [] - readonly property var rows: items.filter(function (i) { return !i.parent || want[i.parent]; }) + // Hidden: Big Picture excludes a silent start; on a Steam Machine a silent start needs "Boot into" desktop. + function hidden(i) { return (i.id === "nvsilent" && want.bigpicture) || (i.needs === "boot" && boot !== "desktop"); } + readonly property var rows: items.filter(function (i) { return (!i.parent || want[i.parent]) && !hidden(i); }) readonly property var bios: status.bios || null signal passwordRequested() @@ -76,10 +78,13 @@ Item { w[id] = !w[id]; // The same rules as the terminal menu (toggle_component). var hasGaming = items.some(function (i) { return i.id === "gaming"; }); - if (id === "gaming" && !w.gaming) w.single = false; + if (id === "gaming" && !w.gaming) { w.single = false; w.silent = false; } if (id === "single" && w.single && hasGaming) w.gaming = true; if (id === "nvidia") w.bigpicture = w.nvidia; - if (id === "bigpicture" && w.bigpicture) w.nvidia = true; + if (id === "bigpicture" && w.bigpicture) { w.nvidia = true; w.nvsilent = false; } + if (id === "nvsilent" && w.nvsilent) { w.nvidia = true; w.bigpicture = false; } + if (id === "nvidia" && !w.nvidia) w.nvsilent = false; + if (id === "silent" && w.silent) w.gaming = true; if (id === "machine") w.poweroff = w.machine; if (id === "poweroff" && w.poweroff) w.machine = true; if (id === "machine" && !w.machine) w.kpin = false; @@ -93,6 +98,7 @@ Item { for (var i = 0; i < items.length; i++) { var it = items[i]; if (it.kind !== "toggle") continue; + if (hidden(it)) { if (it.on) p.push({ id: it.id, action: "off" }); continue; } if (it.parent && !want[it.parent]) { if (it.on) p.push({ id: it.id, action: "off" }); continue; } if (want[it.id] && !it.on) p.push({ id: it.id, action: "on", isNew: !!it["new"] }); else if (!want[it.id] && it.on) p.push({ id: it.id, action: "off" }); @@ -109,7 +115,7 @@ Item { function wantedIds() { var ids = []; for (var i = 0; i < items.length; i++) - if (items[i].kind === "toggle" && want[items[i].id] && (!items[i].parent || want[items[i].parent])) ids.push(items[i].id); + if (items[i].kind === "toggle" && want[items[i].id] && !hidden(items[i]) && (!items[i].parent || want[items[i].parent])) ids.push(items[i].id); return ids; } diff --git a/ui/qml/Texts.qml b/ui/qml/Texts.qml index 65b1403..6ba1504 100644 --- a/ui/qml/Texts.qml +++ b/ui/qml/Texts.qml @@ -10,12 +10,18 @@ QtObject { boot: { label: "Boot into", hint: "Where the PC starts", body: "Where the PC starts after a restart. Switching back and forth works the same either way.", changes: ["Desktop: the Plasma session is set before login", "Gaming: the SteamOS default"] }, + silent: { label: "Start Steam silently", hint: "In the tray at login on the desktop, no window", + body: "Steam starts by itself when you log in to the Plasma desktop, in the tray without a window. Gaming mode starts its own Steam.", + changes: ["Steam is started with -silent (a systemd user service, desktop only)", "Off: the service is removed again"] }, nvidia: { label: "Gaming on NVIDIA", hint: "Steam on the desktop, started at login", body: "gamescope's own gaming mode shows a corrupted picture on NVIDIA graphics cards (an open NVIDIA driver bug), so it isn't offered here. This puts Steam on the Plasma desktop instead and starts it when you log in.", changes: ["Steam is installed when it's missing", "Steam starts at login (a systemd user service)", "Off: the service is removed again; Steam is only removed if Steamify installed it"] }, bigpicture: { label: "Steam starts in Big Picture", hint: "The controller-friendly Steam, or the normal window", body: "Steam opens in Big Picture at login, which works well with a controller on the TV. Untick it for Steam's normal window.", changes: ["Steam is started with -gamepadui", "Plasma starts with an empty session, so old windows don't cover Big Picture", "Off: Steam starts in its normal window"] }, + nvsilent: { label: "Start Steam silently", hint: "In the tray at login, no window", + body: "Steam starts in the tray at login without a window. Not together with Big Picture: ticking one unticks the other.", + changes: ["Steam is started with -silent", "Off: Steam starts in its normal window"] }, theme: { label: "SteamOS theme", hint: "Vapor look for the desktop, Add to Steam", body: "The Vapor look of SteamOS for the desktop, with its panel, launcher icon and wallpaper.", changes: ["cachyos-vapor global theme", "Add to Steam in right-click menus", "Nested Desktop, Steam keyboard window rule"] },