we_full.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # usage: we_full.sh <scene dir or scene.json/scene.pkg> <out dir> [count] [interval seconds]
  3. # runs on the GPU display :98 (DXVK); WE_DISPLAY=:97 WE_WINED3D=1 is the old Xvfb + wined3d (llvmpipe) path
  4. # full window captures (1920x1058 at +4+30 on :97) of real WE 2.8.42 under Wine, see README.md
  5. S=${WE_LIVE_DIR:-$HOME/.local/share/we_live}
  6. D=${WE_DISPLAY:-:98}
  7. [ "$D" = ":98" ] && { bash "$(dirname "$0")/we_display.sh" >/dev/null || exit 1; }
  8. export WINEPREFIX=$S/wineprefix DISPLAY=$D WINEDEBUG=-all DXVK_LOG_PATH=$S
  9. # Wine must only see the isolated :98, not the desktop session (wayland-0, D-Bus) in the shared runtime dir
  10. unset WAYLAND_DISPLAY WAYLAND_SOCKET DBUS_SESSION_BUS_ADDRESS; export XDG_RUNTIME_DIR=$S/run
  11. # keep Wine off the desktop's audio server (a shared /run/user/<uid>/pulse would play the wallpaper's sounds on real speakers and feed real system audio to the visualizers)
  12. export PULSE_SERVER=unix:$S/run/no-pulse PIPEWIRE_REMOTE=$S/run/no-pipewire ALSA_CONFIG_PATH=/dev/null
  13. [ -n "$WE_WINED3D" ] && export WINEDLLOVERRIDES="d3d11,d3d10core,dxgi=b"
  14. [ "$D" != ":97" ] || pgrep -f "Xvfb :97" >/dev/null || { Xvfb :97 -screen 0 1920x1080x24 -nolisten tcp >/dev/null 2>&1 & sleep 1; }
  15. /usr/lib/wine/wineserver -k 2>/dev/null; timeout 4 tail -f /dev/null
  16. cd $S/we28
  17. F=$1; [ -d "$F" ] && F=$F/scene.json
  18. WIN=$(echo "Z:$F" | tr '/' '\\')
  19. nohup /usr/lib/wine/wine64 wallpaper64.exe -control openWallpaper -file "$WIN" -monitor 0 -playInWindow -silent > $S/we_run_last.log 2>&1 &
  20. timeout 25 tail -f /dev/null
  21. mkdir -p "$2"
  22. python3 - "$2" "${3:-10}" "${4:-1}" "$D" <<'PY'
  23. import sys, time, mss
  24. from PIL import Image
  25. from Xlib import display
  26. d=display.Display(sys.argv[4]); root=d.screen().root
  27. def walk(w):
  28. for c in w.query_tree().children:
  29. yield c; yield from walk(c)
  30. for w in walk(root):
  31. try: n=w.get_wm_name()
  32. except Exception: n=None
  33. if n=='Wallpaper UI': w.unmap()
  34. # the hidden UI leaves its border/shadow strips (8px override-redirect windows) and a small bar on top
  35. for w in root.query_tree().children:
  36. g=w.get_geometry()
  37. if w.get_attributes().map_state==2 and min(g.width,g.height)<=20 and (g.width,g.height)!=(1,1): w.unmap()
  38. d.sync(); time.sleep(2)
  39. t0=time.time()
  40. with mss.MSS(display=sys.argv[4]) as m:
  41. for i in range(int(sys.argv[2])):
  42. s=m.grab({'left':0,'top':0,'width':1920,'height':1080})
  43. Image.frombytes('RGB',s.size,s.rgb).save('%s/f%03d_%.1f.png'%(sys.argv[1],i,time.time()-t0))
  44. time.sleep(float(sys.argv[3]))
  45. PY
  46. /usr/lib/wine/wineserver -k 2>/dev/null