wem_check.sh 5.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash
  2. # wem_check.sh <vm> <app dir | .deb> [screen] - we_manager in a VM's desktop session, driven over DevTools (cdp.py):
  3. # distro detection and the prebuilt engine it picks, install from the GitHub release, launch of a scene and a web
  4. # wallpaper, stop and kill all leaving nothing behind, autostart entry written. Needs the session running (sessenv).
  5. # The app dir is we_manager's dist/linux-unpacked (what an AppImage unpacks to), a .deb is installed with the
  6. # distribution's package manager first. Prints one PASS|FAIL line per check.
  7. # WEM_FLAGS adds command line flags for the app (COSMIC needs --disable-gpu-compositing in the VM).
  8. # SKIP_ENGINE_INSTALL=1 keeps the engine that is installed (update_check.sh leaves the candidate's there).
  9. HERE=$(cd "$(dirname "$0")" && pwd)
  10. vm=$1 app=$2 screen=${3:-Virtual-1}
  11. sshv() { "$HERE/linuxvm.sh" ssh "$vm" "$@" </dev/null; }
  12. status=0
  13. pass() { echo "PASS $1"; }
  14. fail() { echo "FAIL $1"; status=1; }
  15. . "$HERE/wem_lib.sh"
  16. sshv 'mkdir -p ~/wem; pkill -f "[w]em/.*we-manager" 2>/dev/null; pkill -f "[w]e-manager" 2>/dev/null; true'
  17. wem_wait_gone
  18. wem_install || exit 1
  19. wem_steam_lib 1120596121 1078208425
  20. wem_run || exit 1
  21. pass "we_manager starts"
  22. out=$(cdp 'window.electronAPI.lwe.detectDistro()'); echo " distro: $out"
  23. out=$(cdp 'window.electronAPI.lwe.prebuiltTarget()')
  24. if echo "$out" | grep -q '"supported": true'; then pass "prebuilt engine offered: $(echo "$out" | grep -o '"asset": "[^"]*"')"; else fail "no prebuilt engine offered: $out"; fi
  25. out=$(cdp 'window.electronAPI.lwe.listScreens()')
  26. if echo "$out" | grep -q "$screen"; then pass "screens found: $out"; else fail "screen $screen not found: $out"; fi
  27. if [ -z "$SKIP_ENGINE_INSTALL" ]; then
  28. sshv 'rm -rf ~/.local/share/linux-wallpaperengine-kde'
  29. out=$(sshv ". ~/sessenv; cd ~/wem; timeout 400 python3 cdp.py 'window.electronAPI.lwe.installPrebuilt()' 2>&1 | cut -c1-300")
  30. if echo "$out" | grep -q '"installed": true'; then pass "engine installed from the release: $(echo "$out" | grep -o '"version": "[^"]*"')"; else fail "engine install failed: $out"; fi
  31. fi
  32. if [ -n "$SKIP_ENGINE_INSTALL" ] && ! sshv 'test -x ~/.local/share/linux-wallpaperengine-kde/linux-wallpaperengine'; then
  33. # a read-only system skips the clean install and the update check has nothing to update: put the candidate where the install would
  34. sshv 'mkdir -p ~/.local/share && rm -rf ~/.local/share/linux-wallpaperengine-kde && cp -a ~/lwe/lwe-hints ~/.local/share/linux-wallpaperengine-kde'
  35. echo " no engine was installed through we_manager here, copied the candidate into ~/.local/share/linux-wallpaperengine-kde"
  36. fi
  37. launch() { cdp "window.electronAPI.lwe.launch('$HOME_STEAM/$1', {screen: '$screen'})"; }
  38. HOME_STEAM=$(sshv 'echo $HOME')/.steam/steam/steamapps/workshop/content/431960
  39. for id in 1120596121 1078208425; do
  40. out=$(launch "$id"); sleep 15
  41. engines=$(sshv 'pgrep -fc "/[l]inux-wallpaperengine(\.bin)? "')
  42. if echo "$out" | grep -q '"running": true' && [ "$engines" -gt 0 ]; then pass "$id launched from we_manager ($engines engine processes)"; else fail "$id did not launch: $out"; fi
  43. cdp 'window.electronAPI.lwe.stop()' >/dev/null; sleep 5
  44. left=$(sshv 'echo $(pgrep -fc "/[l]inux-wallpaperengine(\.bin)? ") $(pgrep -fc "[w]eb-helper")')
  45. [ "$left" = "0 0" ] && pass "$id: stop leaves nothing behind" || fail "$id: after stop engines/helpers: $left"
  46. done
  47. launch 1078208425 >/dev/null; sleep 12
  48. cdp 'window.electronAPI.lwe.killAll()' >/dev/null; sleep 6
  49. left=$(sshv 'echo $(pgrep -fc "/[l]inux-wallpaperengine(\.bin)? ") $(pgrep -fc "[w]eb-helper")')
  50. [ "$left" = "0 0" ] && pass "kill all leaves nothing behind" || fail "after kill all engines/helpers: $left"
  51. engine_args() { sshv 'pgrep -af "/[l]inux-wallpaperengine(\.bin)? " | head -1'; }
  52. apply_with_automute() { # <wallpaper override: false|undefined>
  53. cdp "(async () => { const api = window.electronAPI; const id = '1120596121'; const cfg = await api.config.get(); \
  54. await api.config.setEngineFlags({ ...(cfg.engineFlags || {}), automute: true }); \
  55. await api.library.update(id, { engineFlags: $1 === false ? { automute: false } : undefined }); \
  56. return await api.wallpaper.apply({ wallpaperId: id }) })()" >/dev/null
  57. sleep 15
  58. }
  59. cdp 'window.electronAPI.library.scan()' >/dev/null
  60. if cdp "window.electronAPI.library.getAll().then(a => a.some(w => w.id === '1120596121'))" | grep -q true; then
  61. apply_with_automute false
  62. args=$(engine_args)
  63. if [ -n "$args" ] && ! echo "$args" | grep -q -- '--automute'; then pass "automute ignore: a wallpaper on the list is launched without --automute"; else fail "automute ignore: engine args with the wallpaper on the list: ${args:-none running}"; fi
  64. apply_with_automute undefined
  65. args=$(engine_args)
  66. if echo "$args" | grep -q -- '--automute'; then pass "automute ignore: off the list the wallpaper is launched with --automute"; else fail "automute ignore: engine args after removing it from the list: ${args:-none running}"; fi
  67. cdp "(async () => { const api = window.electronAPI; const cfg = await api.config.get(); await api.config.setEngineFlags({ ...(cfg.engineFlags || {}), automute: false }) })()" >/dev/null
  68. cdp 'window.electronAPI.lwe.killAll()' >/dev/null; sleep 5
  69. else
  70. echo "SKIP automute ignore: wallpaper 1120596121 is not in we_manager's library"
  71. fi
  72. cdp 'window.electronAPI.config.setAutostart(true, true, null)' >/dev/null
  73. entry=$(sshv 'cat ~/.config/autostart/we-manager.desktop 2>/dev/null | grep "^Exec="')
  74. [ -n "$entry" ] && pass "autostart entry: $entry" || fail "no autostart entry written"
  75. exit $status