mirror of
https://github.com/theupriser/steamify-cachyos.git
synced 2026-10-03 17:41:58 +02:00
feat: the silent option is Steam's own autostart entry (~/.config/autostart/steam.desktop with -silent), so its "Run Steam when my computer starts" follows it; the systemd unit is gone
Sync git.upriser.nl mirror / sync (push) Skipped
Sync git.upriser.nl mirror / sync (push) Skipped
This commit is contained in:
1 parent
349492423e
commit
fbdad5a785
6 files changed
+39
-42
No files matched your search
+29
-14
@@ -16,34 +16,49 @@ steam_enable() {
|
||||
}
|
||||
|
||||
# Sub-option of the SteamOS conversion: Steam starts silently (in the tray,
|
||||
# no window) on the Plasma desktop.
|
||||
# no window) on the Plasma desktop. It is Steam's own autostart entry, the file
|
||||
# Steam's setting "Run Steam when my computer starts" creates and removes, so
|
||||
# that setting shows what Steamify did (and the other way around). Steam's copy
|
||||
# is the system steam.desktop; ours has -silent in its Exec line.
|
||||
STEAM_AUTOSTART="${XDG_CONFIG_HOME:-$HOME/.config}/autostart/steam.desktop"
|
||||
STEAM_SYSTEM_DESKTOP=/usr/share/applications/steam.desktop
|
||||
|
||||
silent_status() {
|
||||
[[ -f "$HOME/.config/systemd/user/steam-desktop-autostart.service" ]]
|
||||
grep -qs '^Exec=.*-silent' "$STEAM_AUTOSTART"
|
||||
}
|
||||
|
||||
silent_old_unit_remove() {
|
||||
# Before 2.11.0 the option was a systemd user unit: it would start Steam a second time.
|
||||
local unit="$HOME/.config/systemd/user/steam-desktop-autostart.service"
|
||||
[[ -f "$unit" ]] || return 0
|
||||
user_systemctl disable --now steam-desktop-autostart.service 2>/dev/null
|
||||
rm -f "$unit"
|
||||
user_systemctl daemon-reload
|
||||
}
|
||||
|
||||
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"
|
||||
user_systemctl daemon-reload
|
||||
user_systemctl enable --now steam-desktop-autostart.service
|
||||
ok "Steam starts silently on the desktop."
|
||||
silent_old_unit_remove
|
||||
mkdir -p "$(dirname "$STEAM_AUTOSTART")"
|
||||
if [[ -f "$STEAM_SYSTEM_DESKTOP" ]]; then
|
||||
sed 's|^Exec=/usr/bin/steam %U$|Exec=/usr/bin/steam -silent %U|' "$STEAM_SYSTEM_DESKTOP" > "$STEAM_AUTOSTART"
|
||||
fi
|
||||
silent_status || printf '%s\n' '[Desktop Entry]' 'Name=Steam' 'Exec=/usr/bin/steam -silent %U' \
|
||||
'Icon=steam' 'Terminal=false' 'Type=Application' 'Categories=Network;FileTransfer;Game;' > "$STEAM_AUTOSTART"
|
||||
ok "Steam starts silently on the desktop from the next login."
|
||||
}
|
||||
|
||||
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
|
||||
silent_old_unit_remove
|
||||
silent_status && rm -f "$STEAM_AUTOSTART"
|
||||
ok "Steam no longer starts by itself on the desktop."
|
||||
}
|
||||
|
||||
steam_disable() {
|
||||
info "Removing Steam desktop settings..."
|
||||
# The autostart unit is the `silent` option's: removed with it, and here
|
||||
# The autostart entry is the `silent` option's: removed with it, and here
|
||||
# too for when the conversion goes off by itself.
|
||||
silent_status && silent_disable
|
||||
silent_old_unit_remove
|
||||
rm -f "$HOME/.config/environment.d/99-kde-virtual-keyboard.conf"
|
||||
ok "Steam desktop settings removed (takes full effect at next login)."
|
||||
}
|
||||
|
||||
+2
-6
@@ -56,7 +56,7 @@ steamgame_steam_busy() {
|
||||
|
||||
steamgame_edit() {
|
||||
# steamgame_edit <function>: runs it with Steam closed, then starts Steam
|
||||
# again if it was running (through our autostart unit when that's there).
|
||||
# again if it was running (silently, in the tray).
|
||||
local was_running=false i
|
||||
if pgrep -x steam >/dev/null; then
|
||||
steamgame_steam_busy && return 1
|
||||
@@ -72,11 +72,7 @@ steamgame_edit() {
|
||||
fi
|
||||
"$1"; local rc=$?
|
||||
if [[ "$was_running" == true ]]; then
|
||||
if user_systemctl is-enabled -q steam-desktop-autostart.service 2>/dev/null; then
|
||||
user_systemctl start steam-desktop-autostart.service
|
||||
else
|
||||
systemd-run --user --collect -q steam -silent >/dev/null 2>&1
|
||||
fi
|
||||
systemd-run --user --collect -q steam -silent >/dev/null 2>&1
|
||||
info "Steam is starting again."
|
||||
fi
|
||||
return "$rc"
|
||||
|
||||
Reference in new issue
Block a user