当我关闭笔记本电脑盖时,如何告诉Ubuntu什么都不做?
我想关闭笔记本电脑的盖子是一个无操作。 我怎样才能做到这一点?
13.10 – 18.04:
为了让笔记本电脑盖关闭时Ubuntu什么都不做:
-
以root身份在文本编辑器中打开
/etc/systemd/logind.conf
文件,例如,sudo -H gedit /etc/systemd/logind.conf
-
添加一行
HandleLidSwitch=ignore
(确保它没有被注释掉!), -
使用以下命令重新启动systemd守护程序:
sudo restart systemd-logind
或者,从15.04开始:
sudo service systemd-logind restart
另请参阅: 关闭笔记本电脑盖时,Ubuntu Server 13.10现在进入睡眠状态
对于11.04及更早版本:
笔记本电脑盖关闭时不执行任何操作 (连接外接显示器时很有帮助):
- Alt + F2并输入:
gconf-editor
- apps> gnome-power-manager>按钮
- 将
lid_ac
和lid_battery
设置为lid_ac
要么
1.在交流电源上,当笔记本电脑盖关闭时什么都不做:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_ac nothing
2.使用电池电源时,关闭笔记本电脑盖时不要执行任何操作:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_battery nothing
笔记本电脑盖关闭时的空白屏幕 (最好不连接外接显示器时):
- 系统>首选项>电源管理
- 关于交流电源(电池供电)>操作
- 当笔记本电脑盖关闭时:空白屏幕
要么
1.当笔记本电脑盖关闭时,交流电源,空白屏幕:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_ac blank
2.使用电池供电时,笔记本电脑盖关闭时出现空白屏幕:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_battery blank
11.10 – 12.04:
您可以在电源设置中选择“不执行任何操作”。 打开短划线(超级键),搜索“电源”,然后在下拉列表中选择正确的选项。 请注意,关闭盖子实际上会关闭屏幕以及任何外部显示器:
如果您移动鼠标,则任何连接的显示器将在笔记本电脑关闭时重新启动。 这将成为主监视器。
Ubuntu 15.10 – Ubuntu 18.10
TLDR:将IgnoreLid=true
添加到/etc/UPower/UPower.conf
-
在终端做:
sudoedit /etc/UPower/UPower.conf
-
将
IgnoreLid=true
更改为IgnoreLid=true
- 保存并退出编辑器。
-
使用以下命令重启UPower服务:
service upower restart
11.04及以前的版本
复制第一个给出的答案来自: http : //ubuntuforums.org/showthread.php?t = 1319921&highlight = close +laptop+lid
在终端(应用程序 – >附件 – >终端)中,键入:gconf-editor
导航到apps – > gnome-power-manager – >按钮并将lid_ac和/或lid_battery设置为“nothing”(不带引号)。
我有14.04.1 LTS,Trusty Tahr 。
什么对我不起作用:
-
以root身份在文本编辑器中打开/etc/systemd/logind.conf文件,例如,
sudo -H gedit /etc/systemd/logind.conf
添加一行
HandleLidSwitch=ignore
(确保它没有被注释掉!),使用以下命令重新启动systemd守护程序:
sudo restart systemd-logind
-
编辑gConf
使用交流电源时,笔记本电脑盖关闭时不执行任何操作:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_ac nothing
使用电池电源时,笔记本电脑盖关闭时不执行任何操作:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_battery nothing
什么对我有用:
在/etc/UPower/UPower.conf
设置IgnoreLid=true
一些笔记本电脑和显示器存在一个错误,当笔记本电脑的盖子关闭时,Ubuntu不会遵守“无所事事”的设置。 我一直无法找到完整的解决方案,但也许与此链接有关 ,他们提示此文件: /etc/default/acpi-support
并使用:
gconftool-2 -t string /apps/gnome-power-manager/buttons/lid_ac -s "blank" gconftool-2 -t string /apps/gnome-power-manager/buttons/lid_battery -s "blank"
对于Saucy:
编辑/etc/systemd/logind.conf
并设置HandleLidSwitch=lock
以锁定盖子关闭(但不挂起)的屏幕,或者HandleLidSwitch=ignore
甚至不锁定屏幕。
这是由于上游GNOME的变化。 有关此更改的基本原理,请参阅GNOME错误687277 。
11.04及以前的版本
你也可以去system->preferences->power management
在靠近窗口的底部,您会看到一个下拉列表,您可以在其中选择系统在关闭盖子时所执行的操作
12.04
在“系统设置”中,打开“亮度和锁定”。 在该页面上,取消选中底部的复选框,上面写着“从暂停状态唤醒时需要我的密码”。
我有时喜欢暂停我的笔记本电脑,有时候我喜欢让它长时间像服务器一样(当我关上盖子时什么都不做)。 我使用Debian,这是我的简单脚本,可以在不重启的情况下随时执行任一操作:
# run this in the as the same user (or root) that xwindow is using # test for required parameter --> empty not allowed if [ "$1" == "" ]; then echo "Please provide true or false" echo "True means keep running when lid is closed" echo "False means suspend the computer when lid is closed" exit; fi # "running true" means keep running even if the lid is closed if [ "$1" = "true" ]; then 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 fi # "running false" means suspend the computer! if [ "$1" = "false" ]; then gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action suspend gsettings set org.gnome.settings-daemon.plugins.power lid-close-battery-action suspend fi # if "echo" is supplied as a param, just show the current settings if [ "$1" = "echo" ]; then gsettings get org.gnome.settings-daemon.plugins.power lid-close-ac-action gsettings get org.gnome.settings-daemon.plugins.power lid-close-battery-action fi # restart gnome to make changes effective /etc/init.d/gdm3 restart
您可以通过单击启动器/任务栏中的系统设置图标,然后单击亮度和锁定来轻松禁用盖锁function 。
从那里,您将锁定开关翻转到关闭位置,并取消选中“ 从暂停时唤醒时需要我的密码。 ”复选框。
如果您还计划设置hibernate(挂起到磁盘),则必须注意的另一件事是您的系统是否具有足够大的交换分区以实际进入hibernate状态 。 hibernate与暂停不同,但有时人们喜欢在配置暂停时设置hibernatefunction。
您还可以检查电源设置,这样当盖子关闭时它们不会挂起系统。 您可以在系统设置 – >电源中执行此操作。
让我们创建一个适用于所有版本的脚本
#!/bin/bash # PLEASE FEEL FREE TO CHANGE THE SCRIPT # Ubuntu 16.04 [PLEASE COMPLETE] sed -i '/HandleLidSwitch/d' /etc/systemd/logind.conf >/dev/null 1&>2 echo 'HandleLidSwitch=nothing' >> /etc/systemd/logind.conf >/dev/null 1&>2 # Ubuntu 14.04 [PLEASE COMPLETE] sed -i '/IgnoreLid/d' /etc/UPower/UPower.conf >/dev/null 1&>2 echo 'IgnoreLid=true'>> /etc/UPower/UPower.conf # [PLEASE COMPLETE ] # gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_ac [PLEASE COMPLETE ] # gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_battery nothing [PLEASE COMPLETE ] # RESTART SERVICES service upower restart service systemd-logind restart
对于12.10:
编辑/etc/UPower/UPower.conf
并将IgnoreLid=true
添加到底部。
这种方法在Saucy中不再适用。 我不确定13.04。