我的键盘上有一个电源键,我想在按下它时运行脚本。
我环顾四周,没有发现任何关于这一点的东西,就我所见,人们总是对什么感到满意登录配置文件正在提供,这是有趣的部分人登录.conf:
HandlePowerKey=, HandleSuspendKey=, HandleHibernateKey=, HandleLidSwitch=, HandleLidSwitchDocked=
Controls how logind shall handle the system power and sleep keys and the lid switch to trigger actions such as system power-off or suspend. Can be one of "ignore", "poweroff", "reboot", "halt", "kexec", "suspend", "hibernate", "hybrid-sleep", and "lock". If "ignore", logind will never handle these keys. If
"lock", all running sessions will be screen-locked; otherwise, the specified action will be taken in the respective event. Only input devices with the
"power-switch" udev tag will be watched for key/lid switch events. HandlePowerKey= defaults to "poweroff". HandleSuspendKey= and HandleLidSwitch= default to
"suspend". HandleLidSwitchDocked= defaults to "ignore". HandleHibernateKey= defaults to "hibernate". If the system is inserted in a docking station, or if
more than one display is connected, the action specified by HandleLidSwitchDocked= occurs; otherwise the HandleLidSwitch= action occurs.
A different application may disable logind's handling of system power and sleep keys and the lid switch by taking a low-level inhibitor lock
("handle-power-key", "handle-suspend-key", "handle-hibernate-key", "handle-lid-switch"). This is most commonly used by graphical desktop environments to take
over suspend and hibernation handling, and to use their own configuration mechanisms. If a low-level inhibitor lock is taken, logind will not take any action
when that key or switch is triggered and the Handle*= settings are irrelevant.
我没有设法在代码块中设置粗体文本(并且没有使用引号块,因为它将所有内容放在一行中,然后它显然不可读),然后我在这里重复有趣的部分:
控制登录应如何处理系统电源和睡眠键以及盖子开关以触发系统断电或挂起等操作。可以是“忽略”、“断电”、“重新启动”、“停止”、“kexec”、“挂起”、“休眠”、“混合睡眠”和“锁定”之一。
或者我走错了路,这只是键盘按键,而不是电源按钮?
无论如何,以前用acpi很容易,只需更换电源按钮脚本在/usr/lib/acpid/,systemd 没有等效的东西吗?
谢谢。
附:如何更改电源按钮关闭操作以在 systemd 下运行脚本评论中的建议并不能回答我的问题,因为我回答这是从键盘管理电源键,而不是电源按钮。
答案1
我没有看到这个问题不再设置重复,然后我打开了另一个问题,我找到了答案(至少对于 openbox),因为我不知道如何设置重复,我只是将答案的链接放在这里:https://unix.stackexchange.com/a/566910/390900