Ubuntu – Disabling monitor reconfiguration when closing lid

external-monitormultiple-monitorsxorg

I often need to move my laptop from one working place to another. When I do this, there are two events Ubuntu responds to by changing the monitor set up:

  • Removing/attaching the VGA cable
  • Closing/opening the lid of the laptop

While removing the VGA cable gives me what I need (single screen, highest native resolution on the external screen if connected; otherwise highest resolution on the laptop), the laptop close/open lid response is not as good.

Every time I close or open the lid, Ubuntu reconfigures the monitor set up. When I close the lid now… the screen goes black for a few seconds and it switches to clone, with my laptop screen disabled. Reopening results in… briefly a black screen, then the external monitor being used as desktop extension.

Update: Things changed a bit recently, the behaviour is more predictable now. Closing the lid switches to single display, opening to dual screen (not clone). My question is still accurate: see below.

Ubuntu thinks too much. My first and foremost question: Is there any way to let Ubuntu ignore lid close events?

Ideally (or when there's no way to solve above question) I'd want to change how it deals with the screen reconfiguration. Why does Ubuntu toggle the screen configuration between external, clone and single display? Can't I just configure it to always use the external monitor, when present, in single screen mode?

Note that similar questions have been asked before (most notably this one), but these have been closed perhaps wrongly.

Any ideas are very welcome, I don't mind playing around a bit to see if something works.

Best Answer

Is there any way to let Ubuntu ignore lid close events?

Lid events are triggered by the lidbtn file in /etc/acpi/events/, which contains two active lines:

event=button[ /]lid
action=/etc/acpi/lid.sh -- comment this out with a # at the beginning

You can ignore lid open/close events by commenting out the second line with a # and then rebooting.

I'd want to change how it deals with the screen reconfiguration.

You can look at and try to modify the file /etc/acpi/lid.sh and the functions/commands it references.

BUT (BIG CAVEAT): If your laptop BIOS uses the lid close/open to switch the internal/external video out ports on/off, then this is beyond the OS ACPI event handler's powers.