/etc/systemd/logind.conf 被忽略,设置中没有“电源按钮行为”,如何禁用该键?

/etc/systemd/logind.conf 被忽略,设置中没有“电源按钮行为”,如何禁用该键?

我正在尝试禁用按下 PC 的物理电源按钮时显示的 Ubuntu 弹出菜单。我也不希望电源按钮关闭我的 PC,我希望它被操作系统忽略。我之前在 Ubuntu 20.04 和 Ubuntu 22.04 上都这样做过,方法是/etc/systemd/logind.conf像这样更改我的文件:

#  This file is part of systemd.
#
# [...]
#
# See logind.conf(5) for details.
 
[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
HandlePowerKey=ignore
HandleSuspendKey=ignore
HandleHibernateKey=ignore
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

我确信我也更改了一些 GUI 设置……这就是问题所在:logind.conf仅在文件中进行更改是不够的(即使重新启动后,我仍然可以看到菜单),Ubuntu/Gnome 设置中没有任何相关内容……那里的“电源”类别几乎是空的。这是我执行此操作之后的结果:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

“电源按钮行为”设置不再显示,但我也需要禁用所有这些。

我发现应该存在一个/etc/acpi/events/powerbtn-acpi-support文件,但是,它不存在,并且我不希望采用这种方式,因为旧方法已经运行了一年。

我也尝试安装 gconf-editor,但几乎没有变量可以更改(贬值?)。还有这个提示:

不同的应用程序可以通过采用低级抑制锁(“handle-power-key”、“handle-suspend-key”、“handle-hibernate-key”、“handle-lid-switch”、“handle-reboot-switch”)来禁用 logind 对系统电源和睡眠键以及盖子开关的处理。

...但这是一个全新的、最小化的 Ubuntu 20.04 LTS 安装,我之前已经安装过很多次了,每次重新安装后我都会这样做。这怎么会不同呢?

相关内容