translated

This commit is contained in:
geekpi 2022-09-06 08:27:12 +08:00
parent 04578897a5
commit e2711c16e0
2 changed files with 90 additions and 90 deletions

View File

@ -1,90 +0,0 @@
[#]: subject: "Dont Suspend Ubuntu When Laptop Lid is Closed"
[#]: via: "https://itsfoss.com/laptop-lid-suspend-ubuntu/"
[#]: author: "Abhishek Prakash https://itsfoss.com/"
[#]: collector: "lkxed"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Dont Suspend Ubuntu When Laptop Lid is Closed
======
If you use Ubuntu on a laptop, you might have noticed that the system is suspended when you close the lid.
Thats the expected behavior. It saves the battery as well as your work. You lift the lid, the system wakes up, and you can log in and continue your work.
That all sounds good except when you work with a multi-monitor setup. A few people, like me, prefer to have the laptop closed and only use the external monitor(s).
But if closing the laptop lid suspends the system, it creates a problem.
Let me show you how you can change this behavior.
### Dont suspend when laptop lid is closed
Actually, I have noticed that the recent versions of Ubuntu are smarter in this sense. When the laptop is connected to a docking station and you close the lid, it doesnt go in suspend mode.
Thats the normal expected behavior but it may not work all the time for reasons known to Ubuntu gods.
The good thing is that you can force change this behavior using both GUI and command line.
Let me share both methods.
#### Method 1: Using GNOME Tweaks
If you are using the default GNOME desktop, you are in luck. [Install GNOME Tweaks tool in Ubuntu][1] from the software center or use this command:
```
sudo apt install gnome-tweaks
```
Once installed, start the Tweaks application. In the **General tab** from the sidebar, **toggle off the Suspend when laptop lid is closed button**.
![change lid close behavior ubuntu][2]
Thats it. You should not need a restart for changes to take effect.
Now, lets talk about the command line method.
#### Method 2: Change login configuration (for advanced users)
If you look into the content of the file /etc/systemd/logind.conf, youll see three different types of default settings for the laptop lid closing.
* HandleLidSwitch: When the laptop is on battery power
* HandleLidSwitchExternalPower: When the laptop is plugged into a power outlet
* HandleLidSwitchDocked: When the laptop is connected to a docking station
![Default laptop lid closing settings][3]
As you can see, the laptop will suspend if the lid is closed irrespective of whether it is connected to power or not. Lid closing is ignored for docking station connections.
If you want, you can change the value of those parameters to one of these as per your preference:
* lock: lock when lid is closed
* ignore: do nothing
* poweroff: shutdown
* hibernate: hibernate when lid is closed
I would suggest going with `ignore` if you dont want your system do anything special when the laptop lid is closed.
You can either edit the /etc/systemd/logind.conf file and uncomment the said settings and change their value, or you create a new file in /etc/systemd/logind.conf.d directory. Create this directory if it doesnt exist.
I am not going to give you the exact commands. If you are familiar with the command line, you should be able to do it. If you are uncomfortable with the command line, please stick with the earlier GUI method.
I hope this helps you. Let me know if you have any questions.
--------------------------------------------------------------------------------
via: https://itsfoss.com/laptop-lid-suspend-ubuntu/
作者:[Abhishek Prakash][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/
[b]: https://github.com/lkxed
[1]: https://itsfoss.com/gnome-tweak-tool/
[2]: https://itsfoss.com/wp-content/uploads/2022/08/change-lid-close-behavior-ubuntu.png
[3]: https://itsfoss.com/wp-content/uploads/2022/08/laptop-lid-settings-ubuntu.png

View File

@ -0,0 +1,90 @@
[#]: subject: "Dont Suspend Ubuntu When Laptop Lid is Closed"
[#]: via: "https://itsfoss.com/laptop-lid-suspend-ubuntu/"
[#]: author: "Abhishek Prakash https://itsfoss.com/"
[#]: collector: "lkxed"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
笔记本电脑合盖时不挂起 Ubuntu
======
如果你在笔记本电脑上使用 Ubuntu你可能已经注意到当你合上盖子时系统处于挂起状态。
这是预期的行为。它可以节省电池和你的工作。你掀开盖子,系统唤醒,你可以登录并继续工作。
这一切听起来都不错,除非你使用多显示器设置。像我这样的一些人更喜欢关闭笔记本电脑,只使用外接显示器。
但是,如果关闭笔记本电脑盖会挂起系统,那么会产生问题。
让我告诉你如何改变这种行为。
### 关闭笔记本电脑盖时不要挂起
实际上,我注意到最近的 Ubuntu 版本在这个情况下更智能。当笔记本电脑连接到扩展坞并合上盖子时,它不会进入挂起模式。
这是正常的预期行为,但由于 Ubuntu 之神才知的原因,它可能不会一直有效。
好消息是你可以使用 GUI 和命令行强制更改此行为。
让我分享这两种方法。
#### 方法 1使用 GNOME Tweaks
如果你使用的是默认的 GNOME 桌面,那么你很幸运。 [在 Ubuntu 的软件中心安装 GNOME Tweaks 工具][1]或使用以下命令:
```
sudo apt install gnome-tweaks
```
安装后,启动 Tweaks 应用。在侧边栏的**常规选项卡**中,**关闭“关闭笔记本电脑盖时观其”按钮**。
![change lid close behavior ubuntu][2]
这就好了。你不需要重启即可使更改生效。
现在,让我们谈谈命令行方法。
#### 方法 2更改登录配置针对高级用户
如果你查看文件 /etc/systemd/logind.conf 的内容,你将看到三种不同类型的笔记本电脑合盖默认设置。
* HandleLidSwitch当笔记本电脑使用电池供电时
* HandleLidSwitchExternalPower当笔记本电脑插入电源插座时
* HandleLidSwitchDocked当笔记本电脑连接到扩展坞时
![Default laptop lid closing settings][3]
如你所见,如果合上盖子,笔记本电脑将挂起,无论它是否连接到电源。连接扩展坞忽略合盖。
如果需要,你可以根据自己的喜好将这些参数的值更改为其中之一:
* lock合盖时锁定
* ignore什么都不做
* poweroff关机
* hibernate合盖时休眠
如果你不希望你的系统在笔记本电脑盖合上时执行任何特殊操作,我建议你使用 `ignore`
你可以编辑 /etc/systemd/logind.conf 文件并取消注释上述设置并更改其值,或者在 /etc/systemd/logind.conf.d 目录中创建一个新文件。如果此目录不存在,请创建此目录。
我不会给你确切的命令。如果你熟悉命令行,你应该可以做到。如果你对命令行感到不舒服,请使用前面的 GUI 方法。
我希望这可以帮助你。如果你有任何问题,请告诉我。
--------------------------------------------------------------------------------
via: https://itsfoss.com/laptop-lid-suspend-ubuntu/
作者:[Abhishek Prakash][a]
选题:[lkxed][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/
[b]: https://github.com/lkxed
[1]: https://itsfoss.com/gnome-tweak-tool/
[2]: https://itsfoss.com/wp-content/uploads/2022/08/change-lid-close-behavior-ubuntu.png
[3]: https://itsfoss.com/wp-content/uploads/2022/08/laptop-lid-settings-ubuntu.png