hide_steam_kde.sh 1.7 KB

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. # hide_steam_kde.sh - freezes Steam and minimizes its windows with a KWin script. On the Steam Deck shaped VM the client starts
  3. # with -steamdeck, updates itself a few minutes after login and then takes the whole screen (the VM's display reads "not active"),
  4. # a stopped client stays where it is and its sign-in window no longer covers the wallpaper.
  5. freeze() {
  6. pkill -STOP -f '[u]buntu12_32/steam'
  7. pkill -STOP -f '[s]teamwebhelper'
  8. }
  9. if [ "$1" = --watch ]; then
  10. # Steam is not running yet this early after login: keep stopping what shows up for 15 minutes
  11. (setsid nohup bash -c 'for _ in $(seq 900); do pkill -STOP -f "[u]buntu12_32/steam"; pkill -STOP -f "[s]teamwebhelper"; sleep 1; done' >/dev/null 2>&1 &)
  12. exit 0
  13. fi
  14. freeze
  15. script=$(mktemp /tmp/lwe-hide-steam-XXXXXX.js)
  16. echo 'for (const w of workspace.windowList ()) { if (String (w.resourceClass).toLowerCase ().includes ("steam")) { w.minimized = true; } }' > "$script"
  17. live=$(gdbus introspect --session --dest org.kde.KWin --object-path /Scripting | grep -o 'node Script[0-9]*' | tr -dc '0-9\n')
  18. names=()
  19. for attempt in 0 1 2 3; do
  20. name=lwe-hide-steam-$attempt
  21. id=$(gdbus call --session --dest org.kde.KWin --object-path /Scripting --method org.kde.kwin.Scripting.loadScript "$script" "$name" | tr -dc '0-9')
  22. names+=("$name")
  23. echo "$live" | grep -qx "$id" || break
  24. done
  25. gdbus call --session --dest org.kde.KWin --object-path "/Scripting/Script$id" --method org.kde.kwin.Script.run >/dev/null
  26. sleep 2
  27. for name in "${names[@]}"; do
  28. gdbus call --session --dest org.kde.KWin --object-path /Scripting --method org.kde.kwin.Scripting.unloadScript "$name" >/dev/null
  29. done
  30. rm -f "$script"