we_cursor.sh 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # usage: we_cursor.sh <scene dir or scene.json/scene.pkg> <out dir> "x,y x,y,d x,y,u x,y,c ..." [settle seconds]
  3. # like we_full.sh, but warps the pointer (screen px on :98) before each grab: f<i>_<x>_<y>.png.
  4. # d presses, u releases, c clicks the left button there
  5. ulimit -c 0
  6. S=${WE_LIVE_DIR:-$HOME/.local/share/we_live}
  7. D=:98
  8. bash "$(dirname "$0")/we_display.sh" >/dev/null || exit 1
  9. # WE_WINE_DIR=<other Wine build root> with its own WE_PREFIX (README); default is system Wine and $S/wineprefix
  10. # WE_PROTON=<name> picks an installed Proton build (proton.sh) instead
  11. [ -n "$WE_PROTON" ] && { eval "$(bash "$(dirname "$0")/proton.sh" env "$WE_PROTON")" || exit 1; }
  12. WINE=${WE_WINE_DIR:+$WE_WINE_DIR/bin/wine}; [ -x /usr/lib/wine/wine64 ] && SYS_WINE=/usr/lib/wine/wine64 || SYS_WINE=$(command -v wine); WINE=${WINE:-$SYS_WINE}
  13. WINESERVER=${WE_WINE_DIR:+$WE_WINE_DIR/bin/wineserver}; [ -x /usr/lib/wine/wineserver ] && SYS_WINESERVER=/usr/lib/wine/wineserver || SYS_WINESERVER=$(command -v wineserver); WINESERVER=${WINESERVER:-$SYS_WINESERVER}
  14. export WINEPREFIX=${WE_PREFIX:-$S/wineprefix} DISPLAY=$D WINEDEBUG=${WE_WINEDEBUG:--all} DXVK_LOG_PATH=$S
  15. # Wine must only see the isolated :98, not the desktop session (wayland-0, D-Bus) in the shared runtime dir
  16. unset WAYLAND_DISPLAY WAYLAND_SOCKET DBUS_SESSION_BUS_ADDRESS; export XDG_RUNTIME_DIR=$S/run
  17. # 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)
  18. export PULSE_SERVER=unix:$S/run/no-pulse PIPEWIRE_REMOTE=$S/run/no-pipewire ALSA_CONFIG_PATH=/dev/null
  19. $WINESERVER -k 2>/dev/null; timeout 4 tail -f /dev/null
  20. cd $S/we28
  21. F=$1; [ -d "$F" ] && F=$F/scene.json
  22. WIN=$(echo "Z:$F" | tr '/' '\\')
  23. nohup $WINE wallpaper64.exe -control openWallpaper -file "$WIN" -monitor 0 -playInWindow -silent > $S/we_run_last.log 2>&1 &
  24. timeout 25 tail -f /dev/null
  25. mkdir -p "$2"
  26. python3 - "$2" "$3" "${4:-3}" "$D" <<'PY'
  27. import sys, time, mss
  28. from PIL import Image
  29. from Xlib import display
  30. from Xlib.ext import xtest
  31. d=display.Display(sys.argv[4]); root=d.screen().root
  32. def walk(w):
  33. for c in w.query_tree().children:
  34. yield c; yield from walk(c)
  35. for w in walk(root):
  36. try: n=w.get_wm_name()
  37. except Exception: n=None
  38. if n=='Wallpaper UI': w.unmap()
  39. for w in root.query_tree().children:
  40. g=w.get_geometry()
  41. if w.get_attributes().map_state==2 and min(g.width,g.height)<=20 and (g.width,g.height)!=(1,1): w.unmap()
  42. d.sync(); time.sleep(2)
  43. with mss.MSS(display=sys.argv[4]) as m:
  44. for i,p in enumerate(sys.argv[2].split()):
  45. f=p.split(','); x,y=int(f[0]),int(f[1]); act=f[2] if len(f)>2 else ''
  46. for k in range(10):
  47. xtest.fake_input(d, 6, x=x+(10-k), y=y); d.sync(); time.sleep(0.05)
  48. xtest.fake_input(d, 6, x=x, y=y); d.sync()
  49. if act in ('d','c'):
  50. time.sleep(0.4); xtest.fake_input(d, 4, detail=1); d.sync()
  51. if act=='c': time.sleep(0.4)
  52. if act in ('u','c'):
  53. xtest.fake_input(d, 5, detail=1); d.sync()
  54. time.sleep(float(sys.argv[3]))
  55. s=m.grab({'left':0,'top':0,'width':1920,'height':1080})
  56. Image.frombytes('RGB',s.size,s.rgb).save('%s/f%d_%d_%d.png'%(sys.argv[1],i,x,y))
  57. PY
  58. $WINESERVER -k 2>/dev/null