2

I would like to prevent my mouse from leaving the current screen it is on after pressing a key combination. (Multiscreen setup)

On Windows, this can be accomplished by DualMonitorTools where one can assign a shortcut to "lock cursor on current screen". enter image description here

I traversed the whole internet in search of a similar tool for ubuntu, though to no avail. The only solution I found does not prevent the mouse from leaving, rather it pulls the cursor back into the screen which looks wonky and does not help when trying to hit a scrollbar on the right side of the screen, for example.

I also found https://github.com/pfanne/mousejail (under the hood uses XFixes) which restricts the mouse movement perfectly to a certain window, though my goal is to have it restricted to the whole display.

I tried utilizing DualMonitorTools through wine, though it can't recognize the display properties. I know I can move the screen arrangement so only the edges touch, but that's also rather wonky and the mouse leaves more often than not by accident.

Currently I'm running Ubuntu 20.04 with KDE Plasma 5.18.5

Perhaps you got some suggestions on how to create a script myself, I read about Pointer Barriers, though I have no idea if that would also end up just pulling back the mouse, e.g. allowing the input.

What I also saw is that you can't make the displays completely separate in the display arrangement, there is always a connection where the mouse can pass. Sadly I did not find a way to circumvent it.

Kind of weird that such a simple issue still does not have a fix, but perhaps I just overlooked it.

mkV
  • 111
  • To confirm you have multiple monitors but you don't want to use them? – WinEunuuchs2Unix Jan 06 '21 at 01:09
  • Multimonitor setup, correct. I don't want my mouse to enter them, for example when gaming or single monitor coding + second monitor video output. I still need the monitors to be on and connected. – mkV Jan 06 '21 at 01:48
  • I think then you are asking how to mirror all monitors into a single one so the cursor doesn't leave the single one? – WinEunuuchs2Unix Jan 06 '21 at 03:27
  • no, I just want to trap the mouse on the screen it is currently on, with a shortcut (and release with a shortcut). Though that is only necessary when I extend the monitors since mirroring would practically give me only one usable monitor. – mkV Jan 06 '21 at 03:43
  • Exactly. All you need to do is mirror all your monitors to the one the game is on. When you are finished playing games restore the extended desktop. The only caveat is all the windows on the monitors loosing focus go to the single mirrored monitor. After unmirroring you may have to manually move the windows back. – WinEunuuchs2Unix Jan 06 '21 at 03:46
  • You can always file a feature request to have that option added. – Terrance Jan 06 '21 at 05:44
  • @WinEunuuchs2Unix I appreciate your time and willingness to help, but mirroring is not a solution. There are plenty of workflows and usecases which involve multimonitors without interacting with them. Most prominently: RDP connections where you want to trap the mouse, or gaming + messengers on second screen, or coding + tutorial on second, etc. – mkV Jan 06 '21 at 12:21
  • @Terrance I'll have a go at it. Though I'm aware that at best this will take 5 years to be implemented. Since there's nothing similar, I assume the demand on linux for this is not really high.Worth a shot though! Still I hope someone can help me fix it in the meantime :) – mkV Jan 06 '21 at 12:24

0 Answers0