![让 Ubuntu 在笔记本电脑盖关闭时不执行任何操作](https://linux22.com/image/1021521/%E8%AE%A9%20Ubuntu%20%E5%9C%A8%E7%AC%94%E8%AE%B0%E6%9C%AC%E7%94%B5%E8%84%91%E7%9B%96%E5%85%B3%E9%97%AD%E6%97%B6%E4%B8%8D%E6%89%A7%E8%A1%8C%E4%BB%BB%E4%BD%95%E6%93%8D%E4%BD%9C.png)
每次我离开房间,我的猫就喜欢咬我的笔记本电脑的按键。关闭笔记本电脑可以避免这个问题,但它会让我退出,而且重新登录很麻烦,尤其是在后台任务正在运行等情况下。
这是我的/etc/systemd/logind.conf
文件,其中我将所有盖子开关内容设置为忽略:
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See logind.conf(5) for details.
[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
我也IgnoreLid=true
开始/etc/UPower/UPower.conf
看起来我的设置在前几秒确实被遵守了,但如果我离开的时间更长,那么我仍然会被注销/暂停。也许这与设置有关HoldoffTimeoutSec=30s
?
更新:我将其设置HoldoffTimeoutSec
为 3600,也将其设置LidSwitchIgnoreInhibited
为 no。其中一种似乎有效,至少到目前为止。
答案1
如果您的桌面环境是gnome
,您可以尝试setting->power
修改右侧面板上的设置。此设置可能会覆盖您配置文件中的设置。