4

Some context in case this is an XY problem: I use a laptop which I sometimes attach to an external monitor. When attached to the external monitor, I would like to have games display on it instead of the laptop screen, however they tend to be hard-coded to display on the primary monitor. (And when I do manage to switch them, they tend to cap resolution at the primary monitor, while my external monitor is higher resolution than the laptop.) I would prefer to keep my primary monitor on the laptop screen as it is simpler for me and also the switching of the primary monitor messes with some of my KDE layouts.

On to the main question: I would like to tell certain programs that a monitor is the primary monitor without the rest of the system recognizing it as the primary monitor. Ideally this would be done in a way that defaults back to the laptop screen when said monitor isn't plugged in. Is there a way to do this?

3
  • I'm not even sure what in X11/extensions makes a monitor "primary", so this is a rather interesting question! Commented Jan 7, 2023 at 21:40
  • 1
    @MarcusMüller I am defining the primary monitor just using KSystemSettings, so it's whatever the underlying method for that is
    – fin444
    Commented Jan 7, 2023 at 21:42
  • yep! I know as little as you! That's why I hope for good answers :) Commented Jan 7, 2023 at 21:53

1 Answer 1

1

This may be an XY problem.

In span mode, X11 typically controls "primary monitor" status by giving it a start x,y coordinate of 0,0 and secondary screens are appended to that horizontally or vertically. Although the session manager may also designate a specific screen for toolbar locations, and applications can also accept a default screen internally, but this is different from being primary.

Instead of tricking one app into thinking the external monitor is primary, it may be better to get an extension that saves your session settings separately for single screen and multiple screen configurations. There is an extension for gnome-shell to do this, but I'm not aware of what is available for KDE. Even with this, you would still have to reconfigure your session for two screens at least the first time.

The alternative would be to either tell the application which screen to use (command line option? internal setting?) or run it in a shim to remap screen coordinates (and I don't know if this is possible either). You may be able to do this with a nested X server running on a portion of the screen -- but if this for a game, it may have unacceptable performance impacts.

Note that in multi-head mode (at some point in history, called Zaphod mode), screens each had separate coordinate systems and windows couldn't be dragged between them. The X11 connection (for example) was designated by DISPLAY=:0 and you could specify a screen with DISPLAY=:0.0 or DISPLAY=:0.1 and you could easily force an application to the other screen; however, I'm not even sure if this mode is supported by current X servers, and even if your display driver and X server support it, your window manager may not.

2
  • It might be enough to use an X11 proxy or a LD_PRELOAD that modifies the order of monitors in xrandr replies. But that's easier said that done: I'm not aware of an out-of-the-box tool that makes this easy. Commented Jan 8, 2023 at 12:20
  • Configuring which monitor is considered primary depending on what is plugged in isn't an issue, it all Just Works in KDE by default. The issue is that I would like to not have to change my primary screen at all, and just have certain applications behave as though something else was primary. "The alternative would be to either tell the application which screen to use" <-- the question is asking how to do this
    – fin444
    Commented Jan 8, 2023 at 22:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .