Turn laptop internal monitor off when using external monitor

Greetings all,

when I plug an external monitor to the port of a laptop, I have a display space spanning both the internal and the external monitors.

How does one (either automatically or manually), turn the internal monitor off when the external monitor is plugged in, so that there is only a single display space?

The card is NVIDIA, and partial output of xrandr(1) is;
Code:
Screen 0: minimum 8 x8, current 3040 x 900, maximum 8192 x 8192
VGA-0 connected primary 1600x900+1440+0 (normal left right x axis y axis) 443mm x 249mm
.
.
.
DP-3 connected 1440x900+0+0 ((normal left inverted right x axis y axis) 304mm x 190mm
.
.
.
I am using OpenBox if it is of any significance.

Kindest regards,

M
 
You could try doing it the way windows does, where closing the laptop lid will switch the laptop's screen off. Check /etc/devd.conf for related ACPI events, and use the command jbodenmann mentioned.
 
Hi jbodenmann,

Thank you for the reply.

It took me a while to decipher the syntax, but it worked. One issue with this solution is that if I forget to turn the internal display back on and unplug the external monitor, the internal one does not come back. Since I am apt to forget, I need to find a better way of switching between the monitors.

Kindest regards,

M
 
Hi dsdqmhsx,

thank you for the reply. I will look at the file.

Hi rsronin,

Thank you for the suggestion.

I am looking for the easiest and most reliable manner of doing so. As I understand the port is only a GUI for xrandr(1), so I am not sure how does it help.

Kindest regards,

M
 
One issue with this solution is that if I forget to turn the internal display back on and unplug the external monitor, the internal one does not come back. Since I am apt to forget, I need to find a better way of switching between the monitors.
I hope that somebody more knowledgeable on the subject that me can provide some good info on this.

One way I can think of is always turning on the internal display on every boot. This way, if you "get stuck" without a display you can use your blind-typing skills to change to another TTY and reboot the machine.

Alternatively, setup a hotkey (key combo) (eg. by using x11/sxhkd which turns on the internal display). This however, would require a running instance of Xorg.

Another silly idea would be to re-enable the internal display every X minutes :p

I do feel like none of these are good solutions. Hopefully somebody has a decent solution for this problem.
 
Greetings all,

thank you all for all your ideas. Currently, I favor rsronin's one because OpenBOX has facility to define keybindings, so if I forget and unplug the external monitor before switching back, I can invoke the keybinding without visual feedback.

In fact, I could have two keybindings, switching between the monitors.

Kindest regards,

M
 
  • Like
Reactions: mer
Greeting all,

as a thank you for all your help, here is the code I have for the monitor switching in rc.xlm in OpenBox. It activates the desired monitor in the given mode and turns off the other monitor.

Code:
<keybind key="Desired_keys_combination">
  <action name="Execute">
    <command>xrandr --output monitor_to_activate --mode desired_mode --output monitor_to_deactivate --off</command>
  </action>
</keybind>

Note that the code must be within the <keyboard></keyboard> scope.

Kindest regards,

M

P.S. I hate editing *.xlm in vi(1).
 
Currently, I favor [FONT=monospace]rsronin's[/FONT] one because OpenBOX has facility to define keybindings
Hey! That's not fair! I mentioned that before rsronin 😮‍💨
Obviously kidding - happy to hear that you found a suitable solution :)

I would still suggest forcing the internal display to be "on" right after the system boots up. In case your OpenBox breaks or something and the system boots without being able to jump into the WM you won't have working hotkeys to re-enable the monitor.
 
Hi jbodenmann,

ha, ha, I knew I marked the issue solved prematurely.
I would still suggest forcing the internal display to be "on" right after the system boots up.
That is an excellent point.

Currently, it is moot though, since I am still making changes to the set-up; therefore, I do not use any manager to boot directly to the X-windows. So, even if the OpenBox becomes somehow broken, I am back at the console and can fix it.

Saying that, I really like how the xdm(1) works in OpenBSD, so once I have everything set-up correctly, I might switch. Any idea where I should set it so that it does not became overwritten by another stage in the boot process?

Hey! That's not fair! I mentioned that before [FONT=monospace]rsronin[/FONT] 😮‍💨
Here is another "👍 Thanks" for my oversight. :'‑(

Kindest regards,

M
 
  • Like
Reactions: jbo
Top