Help with kscreen and several monitors


I have 4 monitors that are always connected to my nvidia graphics card and would like two configurations (that can be swapped between).

Desired configurations:

  1. monitors A, B, C
    • regular, non-mirrored configuration
    • A is primary
    • monitor D is disabled
  2. monitors A, D
    • D is mirrored to A
    • D is primary
    • monitors B, C are disabled

Is there a good way to handle swapping between these configurations using kscreen when all monitors are always connected?

There is seemingly no end-user documentation for kscreen, KDE’s git repository for kscreen is not helpful, and I cannot find an obvious way via System Settings/Display Configuration.

Is it best to do this with a script using xrandr or nvidia-settings's metamodes? If so, which of these are preferred? xrandr seems to wipe options (such as ForceCompositionPipeline) applied by nvidia-settings.

Thank you,

Hi, my answer will probably only tangently answer yours. Anyway: I have lost hope in using kscreen to handle monitors. I have only two monitors but kscreen seems to always forget the correct settings for single monitors and extended configuration.

So in my case I decided to use xrandr. Can’t actually answer your question about the better solution between xrandr or nvidia-settings.

One small thing: I downloaded yad and created a mini interface to create an alternate meta+p menu to handle my custom configurations.

return=$(yad --list --height=450 --width=600 --no-headers --undecorated --no-buttons --center --on-top --skip-taskbar --close-on-unfocus --separator= --title "Choose Layout" --text-align=center --column="Option" --column=@font@ Acer 30 Samsung 30 "Doule 4 Steam" 30 Extend 30 "NONE" 30 " - Display Settings - " 30 " - Arandr - " 30)

if [[ "$return" == Acer ]]; then
    bash  $( dirname "$0" )/
elif [[ "$return" == Samsung ]]; then
    bash $( dirname "$0" )/
elif [[ "$return" == "Doule 4 Steam" ]]; then
    bash $( dirname "$0" )/
elif [[ "$return" == Extend ]]; then
    bash $( dirname "$0" )/
elif [[ "$return" == " - Display Settings - " ]]; then
    kcmshell5 kcm_kscreen
elif [[ "$return" == " - Arandr - " ]]; then

Each *.sh file is a configuration setted by the xrandr command. The last two simply open the kde display setting gui or the arandr gui.

1 Like

you basically just need to write 2 scripts, one for every setup and using xrandr to set the screens as you desire.

something like that:
xrandr --output DP-1 --mode 1920x1080 --pos 0x0 --rotate normal --output DP-2 --mode 1920x1080 --pos 1920x0 --rotate normal --output DP-3 --mode 1920x1080 --pos 3860x0 --rotate normal --output DP-4 --off

xrandr --output DP-1 --mode 1920x1080 --pos 0x0 --rotate normal --output DP-2 --off --output DP-3 --off --output DP-4 --mode 1920x1080 --pos 1920x0 --rotate normal --same-as DP-1

and then just run one of the scripts.

1 Like

I’ve come up with some scripts using primarily nvidia-settings (as I think the syntax is a little easier to understand) and a single xrandr command to set the primary monitor.
# cat - 2022-05-09
# Activates monitors: lg_ultrawide, asus_left, asus_right; disables other monitors.

# xrandr outputs

# nvidia metamodes
metamode_asus_left="$output_asus_left: 1920x1080_60_0 +0+0 \
	{Rotation=90, ForceCompositionPipeline=On}"
metamode_asus_right="$output_asus_right: 1920x1080_60_0 +1080+0 \
	{Rotation=90, ForceCompositionPipeline=On}"
metamode_lg_ultrawide="$output_lg_ultrawide: 3440x1440_60 +2160+480 \

nvidia-settings --assign "CurrentMetaMode"="$metamode_asus_left, $metamode_asus_right, $metamode_lg_ultrawide"
xrandr --output $output_lg_ultrawide --primary
# cat - 2022-05-09
# Activates monitors: lg_tv, lg_ultrawide; disables other monitors.
# Configures lg_tv as the source of a mirror (tranformed to fit) to lg_ultrawide.

# xrandr outputs

# nvidia metamodes
metamode_lg_tv="$output_lg_tv: 3840x2160_60 +0+0 \
metamode_lg_ultrawide="$output_lg_ultrawide: 3440x1440_60 +0+0 \
	{Transform=(1.116272,0,0, 0,1.5,0, 0,0,1), ForceCompositionPipeline=On}"

nvidia-settings --assign "CurrentMetaMode"="$metamode_lg_tv, $metamode_lg_ultrawide"
xrandr --output $output_lg_tv --primary

Instead of manually computing the transform, I got it by running this to apply the initial transform:

  • xrandr --output [monitor] --mode [base-resolution] --scale-from [desired-resolution]

then ran:

  • nvidia-settings -q CurrentMetaMode

which reflected the transform and I used that in the script.

I still need to mess around with disabling kscreen and seeing if that messes anything up, but for now I’m content.

Thanks all!

I am not sure about whats ‘easier’ in those scripts of you.
The xrandr codes i wrote are bassically everything you need just put in the correct output IDs (you get them by running xrandr) and the correct monitor position and thats it.

1 Like

It happened this way because I was already doing research on how to use nvidia-settings's metamodes. I’m pretty sure I need to use it if I want ForceCompositionPipeline set, because xrandr seems to clear that (and any other nvidia-specific information) when it sets the mode of a monitor. I basically decided “I’m already using metamodes, so I’ll do as much as I can with them”.

Thanks again,

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