首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用systemd在键盘电源键上运行脚本?

如何使用systemd在键盘电源键上运行脚本?
EN

Unix & Linux用户
提问于 2020-01-17 07:21:42
回答 1查看 1.2K关注 0票数 1

我的键盘上有一个电源键,我想在按下脚本时运行它。

我环顾四周,没有在上面发现任何东西,因为我看到的是,人们总是对logind.conf提供的东西感到满意,以下是man logind.conf的有趣之处:

代码语言:javascript
复制
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.

我没有在代码块中设置粗体文本(也没有使用引号块,因为它将所有内容都放在一行中,然后它显然是不可读的),然后在这里重复一个有趣的部分:

控制logind应如何处理系统电源和睡眠键以及盖子开关,以触发系统断电或暂停等操作。可以是“忽略”、“断电”、“重新启动”、“停止”、"kexec“、”暂停“、"hibernate”、“混合睡眠”和“锁”。

还是我走错了路,这只是为了键盘键,而不是电源按钮?

在任何情况下,在以前,使用acpi很容易,只需替换/usr/lib/acpid/中的power_button脚本就可以了,对于systemd,难道没有什么等价的东西吗?

谢谢。

PS:如何更改电源按钮关闭操作以在系统d下运行脚本在评论中建议不回答我的问题,因为我回答这个问题是为了管理键盘上的电源键,而不是电源按钮。

EN

回答 1

Unix & Linux用户

发布于 2020-02-11 14:55:06

我没有看到这个问题不再是set复制,于是我打开了另一个问题,我找到了一个答案(至少对于openbox ),因为我不知道如何设置重复,所以我只是把这个链接放在这里:https://unix.stackexchange.com/a/566910/390900

票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/562575

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档