我试图在启动时启动以下命令“xinput set-prop 13 289 1”
我创建了一个名为reversemouse.service的systemd服务
当我尝试运行它时,出现以下错误:
[brandon@localhost ~]$ sudo systemctl status reversemouse.service
● reversemouse.service - Description of the systemd service
Loaded: loaded (/etc/systemd/system/reversemouse.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2017-07-17 21:11:51 EDT; 4s ago
Process: 2863 ExecStart=/usr/bin/sh -c xinput set-prop 13 289 1 (code=exited, status=1/FAILURE)
Main PID: 2863 (code=exited, status=1/FAILURE)
Jul 17 21:11:51 localhost.localdomain systemd[1]: Starting Description of the systemd service...
Jul 17 21:11:51 localhost.localdomain sh[2863]: Unable to connect to X server
Jul 17 21:11:51 localhost.localdomain systemd[1]: reversemouse.service: Main process exited, code=exited, sta
Jul 17 21:11:51 localhost.localdomain systemd[1]: Failed to start Description of the systemd service.
Jul 17 21:11:51 localhost.localdomain systemd[1]: reversemouse.service: Unit entered failed state.
Jul 17 21:11:51 localhost.localdomain systemd[1]: reversemouse.service: Failed with result 'exit-code'.
你知道这个错误是什么意思吗?我是否正确格式化了 systemd 服务?这是我的系统服务:
[Unit]
Description=Description of the systemd service
[Service]
Type=oneshot
ExecStart=/usr/bin/sh -c "xinput set-prop 13 289 1"
[Install]
WantedBy=default.target
答案1
我通过创建桌面应用程序解决了该问题:
在 ~/.config/autostart 中,创建一个桌面文件,如下所示:
[Desktop Entry]
Name=startup
GenericName=startup
Comment=Start these up at login
Exec=/home/[your username]/reversemouse.sh
Terminal=False
Type=Application
X-GNOME-Autostart-enabled=true
然后将复制的桌面文件复制到自动启动文件夹: /usr/share/applications/ 到 ~/.config/autostart/
最后,我使用我想要运行的命令创建了一个启动文件(reversemouse.sh):
#!/bin/bash
xinput set-prop 13 289 1