A while ago I asked for how to stop a music player while the screen is locked. The answer was to use actkbd which works like a charm. Now I wanted to add actkbd as a service to systemd in order to start it automatically when booting. So as you can see the service is started correctly and it shows up in htop as well. Some output below:

[root@hostname init.d]# systemctl start actkbd.service
[root@hostname init.d]# systemctl status actkbd.service
actkbd.service - Actkbd: Daemon for X-independent shortcuts
      Loaded: loaded (/etc/systemd/system/multi-user.target.wants/actkbd.service)
      Active: active (running) since Tue, 10 Apr 2012 17:50:36 +0200; 2s ago
     Process: 23526 ExecStart=/usr/local/sbin/actkbd -d /dev/input/event3 -D (code=exited, status=0/SUCCESS)
    Main PID: 23527 (actkbd)
      CGroup: name=systemd:/system/actkbd.service
              └ 23527 /usr/local/sbin/actkbd -d /dev/input/event3 -D
[root@hostname init.d]# systemctl stop actkbd.service
[root@hostname init.d]# ps -C actkbd
  PID TTY          TIME CMD

I have the following actkbd.service file in /etc/systemd/system/multi-user.target.wants/

Description=Actkbd: Daemon for X-independent shortcuts

ExecStart=/usr/local/sbin/actkbd -d /dev/input/event3 -D
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -15 $MAINPID

So the problem is that after starting the service with systemctl nothing happens if I press my usual shortcut for pausing Rhythmbox. If I instead just execute the command /usr/local/sbin/actkbd -d /dev/input/event3 -D via the a root terminal everything works fine. Why that?

Sorry if it's something obvious, I'm new to the systemd business but I couldn't find anything that helped me.


EDIT: This is still not working. If somebody has some time I'd appreciate it if one could try and reproduce it. If that is possible then I will file a bug report.

  • I have yet to try actkbd with systemd, due to lack of time, but I suspect that your issue has something to do with actkbd being started before the input system is fully initialized - actkbd works fine when started as an LSB service on my development laptop. You should make sure that it is started after the evdev module is launched, and that your keyboard always has the same eventX device node. – thkala Jun 1 '12 at 22:43
  • Thanks for the reply Theodoros. The tests that I showed above were executed while everything was booted. So in theory all modules should be loaded. The device node should be fine too as executing the command manually works fine all the time. – Azrael3000 Jun 2 '12 at 10:27

If you would like the user to be able to access the device and run the service unit then you'll need to make a udev rule and set the proper MODES to allow the user permission to access the device. Simply starting the unit file as User=root is incorrect since you are not running the session as root but as your user. When you run it from a root terminal you're activating a root terminal from inside your users session. To get more information on this look up information on systemd --user.

Putting together a udev rule

Use the following command to give you the information that you will need in order to populate the udev rule:

udevadm info --path=$(udevadm info -q path -n /dev/input/event3)

From the output of the above command create your udev rule in /etc/udev/rules.d/<device>.conf. Open it in your favorite text editor and fill in the variables

 SYSFS{idVendor}=="ID Vendor Here" ,
 SYSFS{idProduct}=="ID Model Here",

For more information on making and naming udev rules have a look at man udev or your Linux distribution's Wiki. After setting the rules, reboot. And then start the unit once logged into X.

Also, here is a much more sane system unit file then the one that you've provided.

Description=Actkbd: Daemon for X-independent shortcuts

ExecStart=/usr/sbin/actkbd -Dd /dev/input/event3
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.