BlankSourceCode / obs-zoom-to-mouse

An OBS lua script to zoom a display-capture source to focus on the mouse
361 stars 29 forks source link

Add Linux Wayland support #50

Open calligraf0 opened 2 weeks ago

calligraf0 commented 2 weeks ago

Hi, great little script! :)

Opening an issue to suggest supporting Wayland too along X11.

While this script does not support wayland (yet? :nerd_face: ) as far as I can tell, I worked on a little workaround to use obs-zoom-to-mouse by "abusing" the obs-zoom-to-mouse-remote on KDE. I'm sure a similar solution is doable on other DE.

Hopefully this will help some people out :smile:!

For the workaround, the first script just prints the coordinates with a kwin script: mouse.coords.kwin:

print(workspace.cursorPos.x+" "+ workspace.cursorPos.y)

The second script is just a convenience script to run the above. mouse.coords.sh:

script=$1

while true; do
        now=$(date +%T)
        num=$(dbus-send --print-reply --dest=org.kde.KWin \
                /Scripting org.kde.kwin.Scripting.loadScript \
                string:"$script" | awk 'END {print $2}')

        dbus-send --print-reply --dest=org.kde.KWin /Scripting/Script$num \
                org.kde.kwin.Script.run >/dev/null

        dbus-send --print-reply --dest=org.kde.KWin /Scripting/Script$num \
                org.kde.kwin.Script.stop >/dev/null

        coords=$(journalctl _COMM=kwin_wayland -o cat --since "$now" | sed 's/^js: //' | tail -1)

        echo $coords | ncat -u 127.0.0.1 12345
        sleep 0.10 #optional
done

Launch via:

bash mouse.coords.sh mouse.coords.kwin
tommerty commented 2 days ago

Big plus 1 on this. I'm on Gnome so I couldn't test with your workaround and lack the general knowledge of how to get something going.