Ask Your Question

Getting error running systemd service in Fedora 26.

asked 2017-07-17 20:36:01 -0500

brandex07 gravatar image

I am trying to start the following command on boot "xinput set-prop 13 289 1"

I created a systemd service called reversemouse.service

When I try to run it I get the following error:

[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'. Do you know what this error means, did I format the systemd service correctly? Here is my systemd service:

[Unit] Description=Description of the systemd service

[Service] Type=oneshot ExecStart=/usr/bin/sh -c "xinput set-prop 13 289 1"

[Install] Excuse my noobness. Thanks!

edit retag flag offensive close merge delete


Please set a more descriptive title for your question such as “xinput fails to start through my system unit service”.

Aeyoun gravatar imageAeyoun ( 2017-07-17 21:38:05 -0500 )edit

2 Answers

Sort by » oldest newest most voted

answered 2017-07-18 00:29:36 -0500

muep gravatar image

My impression is that xinput is an X11 client that needs to communicate with an X server to do anything useful. At least by default there is no immediate access to X server from system services and I am not sure about how easy that is to set up in recent Fedora versions, especially if X server is provided by a user-specific Xwayland instance.

Just in case there are problems in doing that, an alternative might be to autorun the command as part of user session. If you wish to try this, create a ~/.config/autostart directory and in there you could place a file named ~/.config/autostart/reversemouse.desktop with content like this:

[Desktop Entry]
Name=Reverse Mouse
Exec=xinput set-prop 13 289 1

If you need, there is also documentation for these desktop files. As far as I know, at least most of the "big" desktop environments and also many smaller ones tend to support this same autostart specification.

I did try your xinput command in a virtual machine but there my device numbers and property numbers would not match yours. Hopefully they will be stable enough on your end that you can just specify fixed numbers like that.

edit flag offensive delete link more

answered 2017-07-17 21:36:40 -0500

Aeyoun gravatar image

You’ve almost got it! However, the error states that your X window server isn’t up and running yet. You need to wait for the environment to be ready to receive xinput commands. The display-manager.service is required, so start your work after it by adding the following requirements to your [Unit] section:


Be sure to reaload your daemons after modifying your service file (systemctl daemon-reload) before you try to start your service again.

edit flag offensive delete link more

Question Tools


Asked: 2017-07-17 20:36:01 -0500

Seen: 341 times

Last updated: Jul 18 '17