Disabling monitor reconfiguration when closing lid

6,463

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.

Share:
6,463

Related videos on Youtube

Pavel Polivka
Author by

Pavel Polivka

Updated on September 18, 2022

Comments

  • Pavel Polivka
    Pavel Polivka over 1 year

    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.

    • Pavel Polivka
      Pavel Polivka almost 12 years
      For those still interested, questions appear from other people with similar issues: askubuntu.com/questions/161649/…
    • Pavel Polivka
      Pavel Polivka almost 10 years
      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.
  • Pavel Polivka
    Pavel Polivka almost 12 years
    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?
  • ish
    ish almost 12 years
    Temporarily move lidbtn from /etc/acpi/events to someplace else, say ~/ . Does that help?
  • Pavel Polivka
    Pavel Polivka almost 12 years
    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.
  • Pavel Polivka
    Pavel Polivka almost 12 years
    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 :)
  • Pavel Polivka
    Pavel Polivka almost 12 years
    you might very well be right about the caveat. Unfortunately I can't find any options in the bios to change this.
  • Pavel Polivka
    Pavel Polivka almost 12 years
    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 :)
  • ish
    ish almost 12 years
    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.
  • rubo77
    rubo77 over 9 years
    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)?
  • EvgEnZh
    EvgEnZh over 2 years
    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.