change lid close behaviour

How to Change Lid Close Behavior

This simple tutorial shows how to change the action (e.g. power off, hibernate, do nothing, or lock) when laptop lid is closed in Ubuntu 20.04, while it suspends Ubuntu by default.

Dconf editor offers options to change the action to take when the laptop lid is closed on AC or power, but it doesn’t work!

So far as I know, you can edit the logind.conf file to change the action. And it should work on all Ubuntu desktop, server, and flavors.

1.) Open terminal (press Ctrl+Alt+T on Gnome) from your system application menu. When it opens, run command:

sudo gedit /etc/systemd/logind.conf

Type user password (no asterisk feedback) and hit Enter. For Ubuntu server without UI, use nano text editor instead.

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-h5Kh1HfA-1596697746552)(…/medias/edit-logind-600x124.jpg)]

2.) When the file opens, find out the line #HandleLidSwitch=suspend and change it to one of following :

  • HandleLidSwitch=lock – lock when lid closed.
  • HandleLidSwitch=ignore – do nothing.
  • HandleLidSwitch=poweroff – shutdown.
  • HandleLidSwitch=hibernate – hibernate Ubuntu.

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-co2Nd3Jg-1596697746572)(…/medias/lidclose-action.png)]

For automatic hibernate, you have to test if it works properly via command:

sudo systemctl hibernate

3.) Finally apply changes by running command:
(Save your works before running the command, it may restart your session)

systemctl restart systemd-logind.service

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cCQOWYZF-1596697746577)(…/medias/restart-logind-600x124.jpg)]

外链图片转存中…(img-cCQOWYZF-1596697746577)]

Note you have to do previous steps every time you want to change the action. And ‘Suspend when laptop lid is closed‘ option in Gnome Tweaks will no longer work before you comment (add # at the beginning) the line in /etc/systemd/logind.conf.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值