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.

Tomas
  • 1,069
  • For those still interested, questions appear from other people with similar issues: http://askubuntu.com/questions/161649/how-do-i-disable-all-lid-close-processes – Tomas Jul 10 '12 at 01: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 08 '14 at 03:49

3 Answers3

7

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.

ish
  • 139,926
  • 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 02 '12 at 12:16
  • Temporarily move lidbtn from /etc/acpi/events to someplace else, say ~/ . Does that help? – ish Jun 10 '12 at 01: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 '12 at 01:52
  • @Tomas: see edit at bottom of the answer. – ish Jun 12 '12 at 11:55
  • good point. I'll see if I can find anything in my BIOS and will update this edit if I run into anything. Thanks a lot for all the time you put into this :) – Tomas Jun 13 '12 at 05:05
  • you might very well be right about the caveat. Unfortunately I can't find any options in the bios to change this. – Tomas Jun 13 '12 at 06:50
  • As far as I can tell there is no way to disable the resolution glitch and I do not know if the same thing happens on other laptops as well; could be a problem of my laptop model. I will stick with your answer, @izx. Thanks for your help, the bounty is coming your way :) – Tomas Jun 15 '12 at 08:13
  • Thanks @Tomas! I am coming to the same conclusion--that this is a hardware specific issue--based on this question from another poor chap with an external monitor issue. – ish Jun 15 '12 at 08:18
  • 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 '14 at 06: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.)

EvgEnZh
  • 705
  • 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 05 '21 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.

funicorn
  • 3,866