Scripting Monitors (KDE on Fedora)
Last year I wrote about scripting monitors for my Gnome/Wayland/Fedora environment, and I’ve heavily utilised that script in my day-to-day PC use.
Recently I jumped over to KDE for a change but my prior script was gnome specific and therefore no longer functioned. Luckily KDE has a handy kscreen-doctor utility which has made it easy to adapt my script to work with KDE:
#!/bin/bash
if [ -z "$1" ]; then
echo "Setting monitors to default state"
echo "================================="
kscreen-doctor output.DP-1.mode.3840x2160@60 output.DP-1.scale.2 output.DP-1.primary output.DP-2.mode.3840x2160@60 output.DP-2.scale.2 output.DP-2.enable
else
case "$1" in
"gaming")
echo "Setting monitors up for gaming"
echo "=============================="
kscreen-doctor output.DP-1.mode.3840x2160@60 output.DP-1.scale.1 output.DP-1.primary output.DP-2.disable
;;
"recording")
echo "Setting monitors for recording"
echo "=============================="
kscreen-doctor output.DP-1.mode.3840x2160@60 output.DP-1.scale.2 output.DP-2.mode.3840x2160@60 output.DP-2.scale.1.5 output.DP-2.enable output.DP-2.primary
;;
*)
echo "Unknown argument: $1; Valid arugments: gaming, recording (pass nothing for default)"
;;
esac
fi
As before, with this saved to a monitors
executable script in my PATH
, I can just run monitors gaming
to configure things for gaming, monitors recording
for recording, or just monitors
to
return things to my default setup. I now have this aliased to just m
to make switching even quicker.
If it’s not clear by the commands, this is the configuration set for each of the modes:
- Normal/Development - Dual screen, both at 200% scale
- Gaming - Single screen at 100% scale
- Recording - Dual screen, alternate primary screen, one 200% scale, one 150% scale
This script was written and tested on a Fedora 41 system running KDE plasma via Wayland.