OBS Hyprland Mouse Follow Script
A Lua script for OBS Studio that pans a scaled Display Capture to follow the mouse cursor on Hyprland. Ideal for creating smooth zoom-and-follow effects when screen recording or streaming.I made this script as I tried using similar one, however it was not compatible with hyprland.

Features
- Smooth following using exponential smoothing
- Locks to display edges to avoid overscrolling
- Configurable zoom, output size, display size, and smoothing
- Designed for Hyprland (Wayland) using hyprctl cursorpos
Requirements
- OBS Studio
- Hyprland with hyprctl in your PATH
Installation
- Open OBS Studio.
- Go to Tools > Scripts.
- Click + and select hypr_mouse_follow.lua.
- Fill in the required fields: source name, display size, output size, etc.
Configuration
After adding the script in OBS (via Tools > Scripts > +), you'll need to configure the following settings:- Source Name
The exact name of the display capture source you want the script to control. Make sure it matches the source name in your current scene. - Display Width & Height
The resolution of your physical display (e.g., 2560 for width and 1440 for height). This should match your monitor’s actual resolution. - Output Width & Height
The size of the OBS output canvas or the portion you want to crop and zoom. Usually, this matches your streaming or recording resolution (e.g., 1920×1080). - Zoom Scale
The factor by which the display capture is zoomed. For example, 1.5 means 150% zoom. Adjust this to control how tightly the capture follows the cursor. - Smoothing Factor
Controls how smoothly the capture follows your mouse cursor.- 1 means no smoothing (instant movement).
- Values close to 0 (e.g., 0.01) mean very slow, smooth movement.
- Update Interval (ms)
How often the script updates the position (in milliseconds). Lower values make the follow smoother but can use more CPU.
I've only tested the script on my 2560x1440 display, however, there's no reason why it wouldn't work on other resolutions.