如何禁用 Ubuntu 18.04 的睡眠/暂停/休眠 HP 键盘按钮?

mat*_*ure 8 shortcut-keys power-management 18.04

已经尝试了以下所有解决方案:如何禁用键盘上的睡眠按钮?

gsettings set org.gnome.settings-daemon.plugins.power button-suspend "nothing"
gsettings set org.gnome.settings-daemon.plugins.power button-sleep "nothing"
gsettings set org.gnome.settings-daemon.plugins.power button-hibernate "nothing"
Run Code Online (Sandbox Code Playgroud)

我现在有了dconf-tools

在此处输入图片说明

就我而言,HP Hewlett Packard WZ972AA ABA 经典键盘

在此处输入图片说明

这个“月亮”按钮仍然有效......还有其他想法吗?

Win*_*nix 7

除了 Gnome 电源设置之外,您还可以设置在以下位置systemd找到的设置/etc/systemd/logind.conf

我的笔记本电脑看起来像这样:

$ cat /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
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes
#UserTasksMax=12288
Run Code Online (Sandbox Code Playgroud)

请注意,在我的系统上,我更改的唯一选项是HandleLidswitch. 对于您的系统,我将覆盖这些默认值:

#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
Run Code Online (Sandbox Code Playgroud)

对此:

HandleSuspendKey=ignore
HandleHibernateKey=ignore
Run Code Online (Sandbox Code Playgroud)

systemd有点独特之处在于,以主题标签 ( #)开头的行不仅是评论,而且还代表所采取的默认操作。

不幸的是,我没有你的键盘来测试这个配置。

注意:保存更改后重新启动以激活或使用:

sudo systemctl restart systemd-logind.service
Run Code Online (Sandbox Code Playgroud)

  • 这个方法不起作用 (2认同)

小智 5

不是解决方案,而是解决方法,因为它禁用了挂起。
请按照以下两个步骤操作:

  1. 添加 HandleSuspendKey=ignore到 的[Login]部分/etc/systemd/logind.conf
    如果您在logind日志中启用了调试级别,您将获得如下日志条目:

    ... systemd-logind[518]: Refusing operation, as it is turned off. 
    
    Run Code Online (Sandbox Code Playgroud)

    在日志中,但它仍然暂停在其他一些触发器上。

  2. 添加/etc/systemd/sleep.conf

    [Sleep]
    SuspendMode=false
    
    Run Code Online (Sandbox Code Playgroud)

    现在它仍然对挂起按键做出反应,但失败了:

    ...systemd-logind[518]: Failed to process message type=method_call  
    sender=:1.54 destination=:1.1 path=/org/freedesktop/login1  
    interface=org.freedesktop.login1.Manager member=Suspend cookie=26  
    reply_cookie=0 signature=b error-name=n/a error-message=n/a:  
    Sleep verb not supported in journal
    
    Run Code Online (Sandbox Code Playgroud)

如前所述:在有人找到更好的解决方案之前,这是一种肮脏的解决方法。


小智 3

请尝试“xev”以查明 Linux 是否读取事件(按下按钮)。也许按钮直接触发主板上的功能?

另一方面,如果您在 中获得了键码xev,则应该能够使用其他按钮重新映射睡眠按钮。请参阅:如何重新映射某些按键或设备?