9

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.

2
  • For those still interested, questions appear from other people with similar issues: askubuntu.com/questions/161649/…
    – Tomas
    Jul 10, 2012 at 1:58
  • I noticed this question is still getting a couple of views per week. I've switched to Arch Linux a while ago and noticed that lid close events are completely ignored by default, not even a screen flicker is seen. It might be that a newer Linux kernel fixes the issues described in this question (both desktop environments I use completely ignore the lid if I tell them to). If so, it is very likely that newer releases of Ubuntu include/will include this fix.
    – Tomas
    Jul 8, 2014 at 3:49

3 Answers 3

7
+50

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.

9
  • Looks interesting but commenting out the 2nd line does not solve my problem. Diving into the lid.sh file suggests it handles switching off the screen (commands like xscreensaver-command -unthrottle, xscreensaver-command -deactivate, /usr/share/acpi-support/screenblank and xset dpms force on). Nothing is mentioned about switching or detecting screens (I was expecting xrandr or something for this). Any more tips?
    – Tomas
    Jun 2, 2012 at 12:16
  • Temporarily move lidbtn from /etc/acpi/events to someplace else, say ~/ . Does that help?
    – ish
    Jun 10, 2012 at 1:21
  • Doesn't change anything, as far as I can tell this has the exact same effect as leaving the file there. Have tried rebooting to make sure the change is applied, of course.
    – Tomas
    Jun 12, 2012 at 1:52
  • @Tomas: see edit at bottom of the answer.
    – ish
    Jun 12, 2012 at 11:55
  • 1
    On my Ubuntu 14.04 I neither have a lid.sh nor a lidbtn on my system (searched with locate) Can I create one of these to add some functionality (I want to disable my touchscreen on closing laptop lid)?
    – rubo77
    Sep 19, 2014 at 6:21
0

This behavior is a Gnome feature, and it is controlled by a dconf setting. You can change it via dconf-editor or directly using command line:

gsettings set org.gnome.settings-daemon.plugins.xrandr default-monitors-setup <value>

The description says following:

Summary: Whether to turn off specific monitors after boot

'clone' will display the same thing on all monitors, 'dock' will switch off the internal monitor, 'do-nothing' will use the default Xorg behaviour (extend the desktop in recent versions). The default, 'follow-lid', will choose between 'do-nothing' and 'dock' depending on whether the lid is (respectively) open or closed.

So, if you'd like to use only the external monitor when it is connected, use dock as <value>.

If you want both monitors to always work, no matter if lid is closed or not, use do-nothing. (I often closed the lid temporarily just so that it did not shine into my dark room, I didn't want all windows to migrate to external monitor.)

And finally, if you want to use laptop screen but only when it is open, use follow-lid. (Use case: amount of free space on your desk varies, and sometimes you have to put the laptop behind your monitor instead of beside it.)

1
  • Almost 4 years later, I had this very problem again, and spent an hour googling before vaguely remembering that I might have answered that question myself a while back... And viola, here it is! Still wirking. Still with zero votes. And I still couldn't google it up, found it by looking through questions I answered here.
    – EvgEnZh
    Dec 5, 2021 at 14:46
0

Can't I just configure it to always use the external monitor, when present, in single screen mode?

I can answer this part. I run ubuntu 17.10 on wayland. In the gnome-control-center -> device -> display, you can choose single display with only the $external_monitor enabled, then click on "apply". That generates a $HOME/.confg/monitors.xml file. The file fixes the display arragemment when the same $external_monitor is connected, and toggles on the internal monitor once it's disconnected. What's better, you can put the same monitors.xml in /var/lib/gdm3/.config/, in that case the same thing holds for GDM too.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .