I want to share this information for those who want to be able to turn on/off any monitor via software in a multi-monitor setup
In my case i have a tri-monitor setup
THE CHALLENGE:
Monitors connected linearly from left to right
A. Sony 32" Monitor - My default primary desktop monitor - icons, taskbar etc etc
B. Dell Monitor
C. Sharp 52" Monitor
The 52" Monitor is the one i use for watching videos in front of the bed
I like having a permanent wallpaper with a small clock in the bottom right-hand corner
The challenge was to see if it was possible to use software or a command to turn monitor A off and then back on again and have no effect at all upon monitor C
Yes, I could turn monitor A off, however monitor C then became the default primary monitor, and hence displayed everything that monitor A had originally displayed - Something i did not want
Using the command kscreen-doctor, i was able to make bash scripts which would perform the tasks for me
I had asked Perplexity.AI a lot of questions to get answers (with linux command examples)
The first thing i had to do was to use kscreen-doctor to designate monitor B as the next-to-be primary monitor before switching monitor A off (as i do not mind this happening - i just did not want monitor C to be changed)
Then i ran the script to turn monitor A off and voila, monitor B was the one to get changed
However, there was another issue now - monitor c was now displaying the contents of what monitor B was displaying (which apparently is a totally normal procedure based on how plasma 6 works - deliberate design here - automatic indexing of monitors)
So i thought about seeing if i could use a second Activities to display the background wallpaper on my 52" monitor - monitor c
I choose the same background wallpaper for Activities number 2 for monitor C
I then added commands in my script to turn monitor A on to specify the x and y coordinates of the other 2 monitors to be turned on
Then i added a command in the script which turns monitor A ON
to tell Activities to use activity number 1 again
After running the script to turn monitor A back on again, everything was restored to the way it was meant to be
Now i created another script to turn monitor B on and i created another script to turn monitor B off
This proved to be a âtadâ more complex than i originally thought
As the act alone of turning monitor B back on - happened to change the screen priorities of monitor B and C (however, the original layout order of monitors was still correct - that did not change)
According to Perplexity.AI, the screen-doctor command only has provision to set a monitor for the first priority, but no options to set a second, third etc etc monitor as a priority
KDE Plasmaâs Display Configuration did show the âChange Screen PrioritysâŚâ as having been changed to Sony32" > Sharp 52" > Dell
from the original Screen prioritys of sony32" > Dell > Sharp 52"
So if there was no command to change the priorities of monitors other than the first priority how could i get around this ?
I deduced that i would have to do this in a way that kde plasma would see as natural/normal
So, in my script to turn monitor B off i first turned monitor B off,
then i changed the activity manager to use activity number 2
In the script to turn monitor b on again, i first turned monitor C off, then turned monitor B on, then turned monitor C on again and lastly i changed the Activity Manager to use Activity number 1 (the default)
AndâŚVoila ! - it all works perfectly
The sequence of order of turning the specific monitors off and then on again, allows kde plasma to assign the correct linear Screen Priorities
Review My scripts - they have notes
Monitor-SONY-32Inch-DP-2-Off.sh
#!/bin/bash
NOTES:
If you want a particular monitor to ALWAYS have the exact same Wallpaper as it was before you turned any other monitor(s)
off, then you need to create a second Activity, and put the SAME wallpaper on that sexond activity
You then need to use the TERMINAL command that allows you to change Activities and specify the activity to change to
(in this case, Activity Number 2)
You can create scripts to allow you to do this
You then need to do the reverse procedure once again to restore to the original default (or other normally used) Activity
when you decide to turn back on the monitor you turned off before
So you will need to then use the command (or script) to change the activity back to the one originally used again
Use the TERMINAL command âqdbus6 --literal org.kde.ActivityManager /ActivityManager/Activities ListActivitiesWithInformationâ
to show all the Activities with BOTH their activity number, and their unique UUID like number
Set DELL Monitor as the monitor to become the Primary Monitor BEFORE turning the primary monitor off
kscreen-doctor output.HDMI-A-1.primary
Turn Primary Monitor 32" Sony Monitor OFF
kscreen-doctor kscreen-doctor output.DP-2.disable
Change Activity - Change-to-Activity-No 2.sh
qdbus6 org.kde.ActivityManager /ActivityManager/Activities SetCurrentActivity f903d744-7ca6-4d63-aeb6-75e924e06774
Monitor-SONY-32Inch-DP-2-On.sh
#!/bin/bash
Turn Sony 32" Monitor ON, Set Thsi monitors position, make it the Primary output monitor again
kscreen-doctor output.DP-2.enable output.DP-2.position.0,0 output.DP-2.primary
Set positions for other monitors
kscreen-doctor output.HDMI-A-1.enable output.HDMI-A-1.position.2954,0 # Adjust the X coordinate based on your primary monitorâs width
kscreen-doctor output.HDMI-A-2.enable output.HDMI-A-2.position.4874,0 # Adjust X coordinate for the 52" Sharp monitor
Activity Manager - Change Activity to Number 1
qdbus6 org.kde.ActivityManager /ActivityManager/Activities SetCurrentActivity c7ebc27a-f50f-4235-a6e7-d87649fa847f
Monitor-DELL-HDMI-A-1-Off.sh
#!/bin/bash
kscreen-doctor output.HDMI-A-1.disable
ActivityManager - Change Activity to Number 2
qdbus6 org.kde.ActivityManager /ActivityManager/Activities SetCurrentActivity f903d744-7ca6-4d63-aeb6-75e924e06774
Monitor-DELL-HDMI-A-1-ON.sh
#!/bin/bash
- IMPORTANT NOTES ABOUT MONITOR PRIORITIES -
Itâs MANDATORY to follow this exact procedure in order to guarantee that the âScreen Priorityâ is setup correctly in the original order that it was manually setup using the KDE Plasma Display Configuration utility
in âChange Screen PrioritiesâŚâ
If one directly turns this monitor on using the command, then this monitor and the DENON/SHARP 52" Monitor will have their Screen Priorities âSwappedâ over
Resulting in the priorities being in this order: Sony 32" > Denon/52" TV > Dell
Instead of being the correct default Priority order of: Sony 32" > Dell > Denon/52" TV
A result of the Screen Priority change (Screen/Monitor being swapped around) means that the background wallpaper will of course also be swapped around
Turn 52" Sharp Monitor OFF
kscreen-doctor output.HDMI-A-2.disable
Turn DELL Monitor ON
kscreen-doctor output.HDMI-A-1.enable output.HDMI-A-1.position.2954,0
Turn 52" sharp Monitor Back On
kscreen-doctor output.HDMI-A-2.enable output.HDMI-A-2.position.4874,0
ActivityManager - Goto Avtivity Number 1
qdbus6 org.kde.ActivityManager /ActivityManager/Activities SetCurrentActivity c7ebc27a-f50f-4235-a6e7-d87649fa847f