Lock mouse cursor on Cities: Skylines game in KDE

HI all!

I don’t play a lot of games, but for when I do, I’d just like to know if there is, and what it is if it’s there, a way to lock the mouse cursor on the game’s screen when playing a STEAM game, so that it isn’t able to cross the border to my secondary screen.

It is probably a minor thing and very unnecessary, but when I do play a game I find myself constantly going over the border to the secondary screen. And that can be quite annoying.

Put your game in exclusive fullscreen mode instead of borderless window?

Thank you for the suggestion. I can remember enabling borderless thinking a border would make it LOOK like a window.

I can’t find where to toggle the setting(s) now. Would you be so kind as to help me with the location to it, please?

I’m not sure how to tell where to look I don’t know what game you have issue with, and I don’t know every games menus either :stuck_out_tongue: but that should be in the video setting, where you can change resolution and other graphic settings, you should be able to tick a box for fullscreen, or select in a list in between other options like windowed/borderless/fullscreen. Globally it is in video/graphics settings.

Well, that pretty much might be it. But, I’m not finding it, and I’ve looked. Oh yes, I’ve looked.

(Game is Cities: Skylines, by the way.)

Any other ideas, or instructions are welcome!

I did a quick google and it is a problem for this specific game

Interesting. Thanks! Looks like I’ll just have to be careful, then.

Maybe there is some Linux tool to do exactly that, lock your mouse on specific screen, I saw threads where people were doing that on Windows so you can maybe look into that option now? :wink:

That is what I’m trying now.

So far no success, but that doesn’t mean I’m giving up!

Update:

I managed it. And I must admit, I am actually rather proud of the way I did it.

I couldn’t find any way to do it. So I rolled my own. Mainly using XRandR, but there is more than just that.

In the end I wrote a custom little script to:

  1. Turn off my KDE composition. If I didn’t turn it off, It’s get turned off by steam and I wouldn’t be able to turn it on afterwards without going to the GUI “System settings” controller. This was done with qdbus.
  2. Switch off, or disable my secondary monitor, so that only the primary is being used. This was done with xrandr.
  3. Launch steam, but enqueue the following to run when it closes
    3.1. Enabling my secondary monitor using xrandr again.
    3.2. Enabling the composition I disabled previously.

This might not seem like a big deal, but I am actually rather proud of it.

For those interested, here is the script:

#! /usr/bin/env bash
compositingActive=$(qdbus org.kde.KWin /Compositor active)

if ( $compositingActive -eq true );
then
    qdbus org.kde.KWin /Compositor org.kde.kwin.Compositing.suspend
    xrandr --output DVI-D-0 --off
    /usr/bin/steam-runtime %U && xrandr --output HDMI-0 --auto --output DVI-D-0 --auto --right-of HDMI-0; qdbus org.kde.KWin /Compositor org.kde.kwin.Compositing.resume; 
fi

Short and sweet. I realize I can leave the check for the compositing out, but I’m leaving it in for the moment since it’s not hurting anyone.

UPDATE:
Have done exactly that, as well as try and make the script a bit more readable. So far, all seems well. The updated script for those interested:

#! /usr/bin/env bash

qdbus org.kde.KWin /Compositor org.kde.kwin.Compositing.suspend
xrandr --output DVI-D-0 --off
/usr/bin/steam-runtime %U &&
xrandr --output HDMI-0 --auto --output DVI-D-0 --auto --right-of HDMI-0
qdbus org.kde.KWin /Compositor org.kde.kwin.Compositing.resume

Another Update:

I realised the disabling and re-enabling of the compositor this way was causing problems. Sometimes it would work and sometimes not.

Whenever the game exited, the compositor would be off and I’d get a popup I can turn it on by pressing Alt+Shift+F12. So I searched the net for some way to use the command line to send key presses.

Enter xdotool. So I changed the script to check if the compositor is active when Steam has exited and if not, “press” the key combination to enable it. It seems to work. For now, anyway.

The script, for those interested:

#! /usr/bin/env bash
xdotool key Alt+Shift+F12 &&
xrandr --output DVI-D-0 --off
/usr/bin/steam-runtime %U &&
xrandr --output HDMI-0 --auto --output DVI-D-0 --auto --right-of HDMI-0 &&
notify-send -t 5000 "STEAM" "Steam has successfully quit."

If there is any problems with the compitor en-/disable I now know the shortcut of Alt+Shift+F12 for enabling and disabling it.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.