xbindkeys 不会在 ExecStart 脚本中运行,而是在常规脚本中运行

xbindkeys 不会在 ExecStart 脚本中运行,而是在常规脚本中运行

我有一个脚本start.sh,它是ExecStart我拥有的服务的脚本(由 systemd 调用)。

DISPLAY=:0 xbindkeys当我在脚本中添加该行时start.sh,它不会启动xbindkeys

user@host:~$ service SERVICE status
● SERVICE.service - "MY AWESOME SERVICE"
   Loaded: loaded (/etc/systemd/system/SERVICE.service; enabled)
   Active: active (running) since Thu 2020-03-05 21:44:22 CET; 13min ago
 Main PID: 5508 (bash)
   CGroup: /system.slice/SERVICE.service
           ├─5508 /bin/bash /home/user/start.sh
           └─5530 /usr/lib/PROGRAM

Mar 05 21:44:24 HOSTNAME bash[5508]: <SOME LOGS>
Hint: Some lines were ellipsized, use -l to show in full.
user@host:~$ ps -ef | grep xbindkeys
user      6181  3545  0 21:57 pts/1    00:00:00 grep xbindkeys
user@host:~$

我还尝试创建一个单独的服务并使我的原始服务依赖于它:

[Unit]
Description="Xbindkeys Service to block keys"
Before=SERVICE.service
Requires=SERVICE.service

[Service]
Environment="DISPLAY=:0"
ExecStart=/usr/bin/xbindkeys
Restart=always

[Install]
WantedBy=multi-user.target

我无法启动它

user@host:~$ service xbindkeys status
● xbindkeys.service - "Xbindkeys Service to block keys"
   Loaded: loaded (/etc/systemd/system/xbindkeys.service; disabled)
  Active: failed (Result: start-limit) since Thu 2020-03-05 21:47:37 CET; 1s ago
  Process: 6122 ExecStart=/usr/bin/xbindkeys -X :0 (code=killed, signal=SEGV)
 Main PID: 6122 (code=killed, signal=SEGV)

Mar 05 21:47:37 HOST systemd[1]: Unit xbindkeys.service entered failed state.
Mar 05 21:47:37 HOST systemd[1]: xbindkeys.service holdoff time over, scheduling restart.
Mar 05 21:47:37 HOST systemd[1]: Stopping "Xbindkeys Service to block keys"...
Mar 05 21:47:37 HOST systemd[1]: Starting "Xbindkeys Service to block keys"...
Mar 05 21:47:37 HOST systemd[1]: xbindkeys.service start request repeated too quickly, refusing to start.
Mar 05 21:47:37 HOST systemd[1]: Failed to start "Xbindkeys Service to block keys".
Mar 05 21:47:37 HOST systemd[1]: Unit xbindkeys.service entered failed state.

我还尝试过以各种方式ExecStart更改:xbindkeys.service

  • ExecStart=/usr/bin/xbindkeys -X :0

它们都不起作用并导致上面相同的输出。

当我DISPLAY=:0 xbindkeys从终端调用时,xbindkeys它按预期工作并作为进程在后台运行,直到我杀死它。

~$ xbindkeys
~$ ps -ef | grep xbindkeys
user      6166     1  0 21:54 ?        00:00:00 xbindkeys
user      6168  3545  0 21:54 pts/1    00:00:00 grep xbindkeys
~$

另外,如果我有一个简单的脚本:

#!/bin/bash
# start-xbindkeys.sh

DISPLAY=:0 xbindkeys

如果我通过以下方式调用脚本,它也会按预期在后台运行./start-xbindkeys.sh

~$ ./start-xbindkeys.sh
~$ ps -ef | grep xbindkeys
user      6166     1  0 21:54 ?        00:00:00 xbindkeys
user      6168  3545  0 21:54 pts/1    00:00:00 grep xbindkeys
~$

为什么我无法运行xbindkeysvia systemd

我在 i386 Debian 8 Jessie 系统上运行它。

相关内容