Hi, LM Vanessa, 5.15.0-56-generic. I have two monitors connected to my desktop PC: an oldish LG for normal use and a Benq video-projector for watching movies with my family. The video-projector is recognized as HDMI-1, the desktop screen is HDMI-2.
When I booted from the Vanessa live USB the LG screen only showed (a part of) the wallpaper; panel and icons were output to the switched off BENQ, set to primary. The BENQ was switched off but connected to the PC. After installation (which I made with the BENQ on), I set HDMI-2 (LG) to primary, which is working: I get the panel etc. on my LG after boot. But when I start an application it sometimes opens in the switched off HDMI-1 -- which was a bit puzzling at the beginning.
I have written two short bash programs using xrandr to switch between the monitors -- I never use both the monitors at the same time -- and I have made two keyboard shortcuts for them. So, the ghost screen problem is actually no big deal, because the hidden window comes back to HDMI-2 as soon as I press CTRL-ALT-O (which basically calls the line of code "xrandr --output HDMI-1 --off"). I'd prefer a cleaner solution though.
So, the question is: is there a way for having Vanessa send out its output only to a monitor that is switched on? I am a bit pessimistic, because I think that xrandr can only distinguish between a connected and a disconnected monitor, but not between two states (on and off) of a connected one. I just hope I'm wrong or there is a way for bypassing xrandr.
[SOLVED] Dual monitor - Applications open in switched off monitor
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
[SOLVED] Dual monitor - Applications open in switched off monitor
Last edited by LockBot on Tue Jun 06, 2023 10:00 pm, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Dual monitor - Applications open in switched off monitor
Is it always the same application which does this?
Or does the same application sometimes do it and sometimes not?
I could be wrong, but I thought there was a way to set where an application opened. Maybe someone else knows for sure.
A woman typing on a laptop with LM20.3 Cinnamon.
Re: Dual monitor - Applications open in switched off monitor
Thank you SMG!
I noticed that some apps systematically opened in the "ghost" videoprojector screen: System Monitor, Calculator, Libreoffice Writer. I didn't study their behavior though (whether they remember the last monitor location etc.) because I eventually made up my mind to add a short bash to my startup programs, setting HDMI-1 to off and HDMI-2 to auto. Not clean as it could be but cleaner than hunting for each application's monitor preferences.
This is the short code, in the (unlikely) case anyone else should be interested in it:
(Remember to set the Execute flag for the bash file.)
In Control Center (System Settings/Hardware/Keyboard/Shortcuts/Custom Shortcuts) I also assigned the combination CTRL-ALT-O to this bash.
To re-activate the projector and switch off the desktop LG monitor my code is:
to which I assigned the combination CTRL-ALT-V. In this way, I can switch between the monitors.
If you want to activate both the monitors, just replace "--off" with "--auto" in either bash file (and assign a new combination to it if convenient).
To find out the names of your connected devices, I suggest you open a terminal and type(there is a leading space in " connected" in order not to output the lines including "disconnected").
Ok, that's it...
I noticed that some apps systematically opened in the "ghost" videoprojector screen: System Monitor, Calculator, Libreoffice Writer. I didn't study their behavior though (whether they remember the last monitor location etc.) because I eventually made up my mind to add a short bash to my startup programs, setting HDMI-1 to off and HDMI-2 to auto. Not clean as it could be but cleaner than hunting for each application's monitor preferences.
This is the short code, in the (unlikely) case anyone else should be interested in it:
Code: Select all
#!/bin/bash
if xrandr | grep "HDMI-1 disconnected"; then
exit
fi
xrandr --output HDMI-1 --off
xrandr --output HDMI-2 --primary --auto
In Control Center (System Settings/Hardware/Keyboard/Shortcuts/Custom Shortcuts) I also assigned the combination CTRL-ALT-O to this bash.
To re-activate the projector and switch off the desktop LG monitor my code is:
Code: Select all
#!/bin/bash
if xrandr | grep "HDMI-1 disconnected"; then
exit
fi
xrandr --output HDMI-2 --off
xrandr --output HDMI-1 --primary --auto
If you want to activate both the monitors, just replace "--off" with "--auto" in either bash file (and assign a new combination to it if convenient).
To find out the names of your connected devices, I suggest you open a terminal and type
Code: Select all
xrandr | grep " connected"
Ok, that's it...
-
- Level 8
- Posts: 2237
- Joined: Wed Aug 14, 2019 1:02 am
Re: [SOLVED] Dual monitor - Applications open in switched off monitor
In such case I wonder if "Mirror displays" can be a cleaner solution than setting up all the scripts.
(https://www.technipages.com/linux-mint- ... resolution)
Re: [SOLVED] Dual monitor - Applications open in switched off monitor
Thank you billyswong. You may be right, but I had already written the scripts for alternating between monitors, and so it was pretty straightforward to run one of them at startup.billyswong wrote:In such case I wonder if "Mirror displays" can be a cleaner solution than setting up all the scripts.
IMHO the really clean thing would be, not to send any output to a switched off monitor, or at least not to set a switched off monitor to primary by default at the first boot. xrandr doesn't tell if a connected monitor is on or off but other commands do, e.g. "inxi -aG": the OS has a way to know it if it just wants
-
- Level 8
- Posts: 2237
- Joined: Wed Aug 14, 2019 1:02 am
Re: [SOLVED] Dual monitor - Applications open in switched off monitor
It depends. For many dual monitor setup, the user may not want switching off one monitor to trigger application windows a jump to the remaining monitor. The user may just want to switch off/on both monitors but unable to do them at exactly the same time. Or the user may sincerely want to use turning off a monitor as a way to not show some application windows to others.Halbarad wrote: ⤴Sat Dec 10, 2022 1:28 pm IMHO the really clean thing would be, not to send any output to a switched off monitor, or at least not to set a switched off monitor to primary by default at the first boot. xrandr doesn't tell if a connected monitor is on or off but other commands do, e.g. "inxi -aG": the OS has a way to know it if it just wants