Replies: 2 comments 1 reply
|
I am using this trick to create a "soft boundary": I setup a small gap (~10px) between monitors. |
|
i made a single line for terminal that spawns wl-mirror onto the 2nd monitor. it moves the mouse to the 2nd monitor in order to spawn wl-mirror there, then waits 0.1 seconds and moves the mouse back to the 1st monitor. this seamlessly makes a screen mirroring process alongside your position trick to lock the mouse i just made an abbreviation in dish for this, and then its all sorted my monitor names are eDP-1 and DP-2. so change those accordingly as per your monitor names:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
TL;DR
niri will lock your mouse to your primary monitor if you set the position to an unreachable point on your second monitor.
Technically it seems like it's locked to whatever monitor has focus, it doesn't need to be your primary monitor.
Example
I have (2) monitors side by side, a 3840x2160 (left) and 2560x1440 monitor (right) hooked up to my desktop machine.
Normal set up where the mouse moves between both monitors freely:
Restricted set up where the mouse is locked to my primary monitor:
Technically a value lower than
9999works, in my case3916is the first pixel where I notice it starts to get restricted but the velocity of the mouse plays a factor here. If I move it very fast then it can break free, where as 9999 is like always hitting a stone wall. Maybe this is related to the interval on when your mouse cursor gets tracked by niri?Apps and windows on the second monitor continue to work normally. If you want your mouse always locked while you've set
9999, you'll probably also want to turn offwarp-mouse-to-focus.niri msg outputssupports being able to set the position so you can script this pretty easily to turn this behavior on and off.Use cases
Do you have any other use cases?
Is this officially supported?
It ends up working out very nicely, but at the same time it feels like maybe niri does this on purpose to protect yourself from setting invalid dimensions. I hope this "it's a feature not a bug?" doesn't disappear, but if it ever does have this behavior changed, can we first make sure a first class feature exists to lock your mouse to a specific monitor?
If it will stick around as is, what do you think about documenting this somewhere?
General purpose toggle script
I ended up writing a blog post and making a video about a general purpose script to toggle locking on your focused monitor, that's at https://nickjanetakis.com/blog/lock-your-mouse-cursor-to-a-specific-monitor-with-niri.
All reactions