we_cursor.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. # usage: we_cursor.sh <scene dir or scene.json/scene.pkg> <out dir> "x,y x,y ..." [settle seconds]
  3. # like we_full.sh, but warps the pointer (screen px on :98) before each grab: f<i>_<x>_<y>.png
  4. ulimit -c 0
  5. S=${WE_LIVE_DIR:-$HOME/.local/share/we_live}
  6. D=:98
  7. 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. /usr/lib/wine/wineserver -k 2>/dev/null; timeout 4 tail -f /dev/null
  14. cd $S/we28
  15. F=$1; [ -d "$F" ] && F=$F/scene.json
  16. WIN=$(echo "Z:$F" | tr '/' '\\')
  17. nohup /usr/lib/wine/wine64 wallpaper64.exe -control openWallpaper -file "$WIN" -monitor 0 -playInWindow -silent > $S/we_run_last.log 2>&1 &
  18. timeout 25 tail -f /dev/null
  19. mkdir -p "$2"
  20. python3 - "$2" "$3" "${4:-3}" "$D" <<'PY'
  21. import sys, time, mss
  22. from PIL import Image
  23. from Xlib import display
  24. from Xlib.ext import xtest
  25. d=display.Display(sys.argv[4]); root=d.screen().root
  26. def walk(w):
  27. for c in w.query_tree().children:
  28. yield c; yield from walk(c)
  29. for w in walk(root):
  30. try: n=w.get_wm_name()
  31. except Exception: n=None
  32. if n=='Wallpaper UI': w.unmap()
  33. for w in root.query_tree().children:
  34. g=w.get_geometry()
  35. if w.get_attributes().map_state==2 and min(g.width,g.height)<=20 and (g.width,g.height)!=(1,1): w.unmap()
  36. d.sync(); time.sleep(2)
  37. with mss.MSS(display=sys.argv[4]) as m:
  38. for i,p in enumerate(sys.argv[2].split()):
  39. x,y=map(int,p.split(','))
  40. # small moves first so WE sees motion events, then the target
  41. for k in range(10):
  42. xtest.fake_input(d, 6, x=x+(10-k), y=y); d.sync(); time.sleep(0.05)
  43. xtest.fake_input(d, 6, x=x, y=y); d.sync()
  44. time.sleep(float(sys.argv[3]))
  45. s=m.grab({'left':0,'top':0,'width':1920,'height':1080})
  46. Image.frombytes('RGB',s.size,s.rgb).save('%s/f%d_%d_%d.png'%(sys.argv[1],i,x,y))
  47. PY
  48. /usr/lib/wine/wineserver -k 2>/dev/null