How can I tell Ubuntu to do nothing when I close my laptop lid?

For 13.10 - 21.10:

To disable Ubuntu doing anything closing the laptop lid:

  1. Open the /etc/systemd/logind.conf file in a text editor as root, for example,

     sudo -H gedit /etc/systemd/logind.conf
    
  2. If HandleLidSwitch is not set to ignore then change it:

     HandleLidSwitch=ignore
    

    Make sure it's not commented out (it is commented out if it is preceded by the symbol #) or add it if it is missing.

  3. Restart the systemd daemon (be aware that this will log you off) with this command:

sudo systemctl restart systemd-logind

or, from 15.04 onwards:

sudo service systemd-logind restart

See also: Ubuntu Server 13.10 now goes to sleep when closing laptop lid

For GNOME Users:

If you are using GNOME (the default in 18.04+), then you can do this easily without changing system settings by using the "Gnome Tweak Tool". It can be installed from the Ubuntu Software Store (It is called GNOME Tweaks). Or if you prefer the console: sudo apt-get install gnome-tweak-tool

Run it after installing, then under Power, Turn off the setting to do nothing when lid is closed. I tested this on Ubuntu 18.04 and it works.


For 11.04 and earlier:

Do nothing when laptop lid is closed (helpful when an external monitor is connected):

  • Alt + F2 and enter this: gconf-editor
  • apps > gnome-power-manager > buttons
  • Set lid_ac and lid_battery to nothing

alt text

OR

1.When on AC Power, do nothing when laptop lid is closed:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_ac nothing

2.When on Battery Power, do nothing when laptop lid is closed:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_battery nothing


Blank screen when laptop lid is closed (preferable when no external monitor is connected):

  • System > Preferences > Power Management
  • On AC Power (On Battery Power) > Actions
  • When laptop lid is closed: Blank screen

alt text

OR

1.When on AC Power, blank screen when laptop lid is closed:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_ac blank

2.When on Battery Power, blank screen when laptop lid is closed:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_battery blank