Command to prevent laptop to go into standby on lid close?

Dear all,

Is there a command I can run from the terminal to prevent my laptop from going into standby on lid close?

Reversely, is there also a command to toggle this state back to have my laptop go into standby on lid close?



1 Like

Perhaps this may be of some help if you are speaking of a Ubuntu-Mate desktop system

When powered by AC

gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action 'nothing'

When powered by battery

gsettings set org.gnome.settings-daemon.plugins.power lid-close-battery-action 'nothing'

Or you could run them simultaneously by issuing

gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action 'nothing' && gsettings set org.gnome.settings-daemon.plugins.power lid-close-battery-action 'nothing'

To reverse issue the same commands only replace ‘nothing’ with 'suspend’

1 Like

If for some reason you are asking about a command line only operating system such as a ubuntu server you would

sudo vim /etc/systemd/logind.conf

Replace #HandleLidSwitch=suspend

With HandleLidSwitch=ignore

Save the file and restart the service by issuing

sudo restart systemd-logind

@orschiro And of course, askubuntu has several articles/questions on this topic. See -

for a good example. HTH.

1 Like

Dear @steven,

I tried precisely this but on my MATE system, my laptop still goes into standby. :frowning:

Not a terminal command as you requested but the dconf Editor can be used to set laptop lid close behavior -

org/mate/power-manager/change button-lid-ac to ‘nothing’ and/or change button-lid-battery to ‘nothing’. Default values are ‘suspend’. HTH.

1 Like

Excellent, @mdooley, this is working! :slight_smile:

I guess something like this should work then, too, to disable the lid action:

$ dconf write /org/mate/power-manager/button-lid-ac 'nothing'
$ dconf write /org/mate/power-manager/button-lid-battery 'nothing'

And to enable it:

$ dconf write /org/mate/power-manager/button-lid-ac 'suspend'
$ dconf write /org/mate/power-manager/button-lid-battery 'suspend'

Unfortunately, this is not working:

[email protected]:~$ dconf write /org/mate/power-manager/button-lid-ac 'suspend'
error: 0-7:unknown keyword

  dconf write KEY VALUE 

Write a new value to a key

  KEY         A key path (starting, but not ending with '/')
  VALUE       The value to write (in GVariant format)

The value must have additional quotes. So the working command would be something like this -

dconf write /org/mate/power-manager/button-lid-ac "'nothing'"

See -


The final solution. Thank you so much, @mdooley! :slight_smile:

My apologies orschiro. Seems I gave you a solution for the wrong flavor of ubuntu.

I used

gsettings set org.gnome

When it should have been

gsettings set org.mate


For AC

gsettings set org.mate.power-manager button-lid-ac 'nothing'
gsettings set org.mate.power-manager button-lid-ac 'suspend'

For battery

gsettings set org.mate.power-manager button-lid-battery 'nothing'
gsettings set org.mate.power-manager button-lid-battery 'suspend'

I can verify this does work in ubuntu-mate 17.04. I have not tested it in previous versions so…

Thanks to @mdooley for providing a correct solution to your question. :+1:

1 Like

No problem, @steven!

You provided the first steps into the right direction. :slight_smile: