キーボードの電源キーを押したときにsystemdを使用してスクリプトを実行するには?

キーボードの電源キーを押したときにsystemdを使用してスクリプトを実行するには?

キーボードに電源キーがあり、このキーを押すとスクリプトを実行したいと思います。

周りを見回しましたが、これについて何も見つかりませんでした。私が見たのは、人々がいつも満足しているのを見ました。ログインプロファイル提供されていますが、これは面白い部分です。人々 login.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.

コードブロックに太字のテキストを設定できませんでした(そして、すべてを1行に入れると確実に読み取れなくなるため、引用符ブロックを使用しませんでした)、ここで興味深い部分を繰り返します。

システムの電源オフやサスペンドなどの操作をトリガーするために、ログインがシステムの電源、スリープキー、およびカバースイッチを処理する方法を制御します。 「無視」、「電源オフ」、「再起動」、「停止」、「kexec」、「一時停止」、「休止状態」、「ハイブリッド省電力」、「ロック」のいずれかです。

それとも私が間違っていると思いますか?これは電源ボタンではなくキーボードキーだけですか?

とにかく以前はacpiを使用すると簡単だったので、交換してください。電源ボタンスクリプトは/usr/lib/acpid/、systemdに対応するものはありませんか?

ありがとうございます。

添付:systemdでスクリプトを実行するために電源ボタンの終了動作を変更する方法コメントの提案は私の質問に対する答えではありません。電源ボタンではなくキーボードの電源キーを管理すると答えたからです。

ベストアンサー1

繰り返し設定に関するこの質問はもう表示されず、別の質問を開いて回答を見つけました(少なくともopenboxの場合)。繰り返し設定方法がわからなかったので、回答へのリンクをここに入れました。 :https://unix.stackexchange.com/a/566910/390900

おすすめ記事