You are not logged in.
Hi.
Is there any way to run systemd service only after specific device is initialized/kernel module is loaded?
The task I'm trying to solve is applying trackpoint speed and sensitivity settings on boot in my X220.
Service code (trackpoint.service) is quite simple
[Unit]
Description=Trackpoint configuration
[Service]
Type=oneshot
EnvironmentFile=/etc/conf.d/trackpoint.conf
ExecStart=/bin/sh -c 'echo ${sensitivity} > /sys/devices/platform/i8042/serio1/serio2/sensitivity'
ExecStart=/bin/sh -c 'echo ${speed} > /sys/devices/platform/i8042/serio1/serio2/speed'
[Install]
WantedBy=graphical.target
The issue is that trackpoint.service gets executed before trackpoint device gets initialized and thus fails.
Jun 14 23:12:10 xi sh[414]: /bin/sh: /sys/devices/platform/i8042/serio1/serio2/sensitivity: No such file or directory
Jun 14 23:12:10 xi systemd[1]: Unit trackpoint.service entered failed state.
...
Jun 14 23:12:18 xi kernel: psmouse serio2: trackpoint: IBM TrackPoint firmware: 0x0e, buttons: 3/3
Jun 14 23:12:18 xi kernel: input: TPPS/2 IBM TrackPoint as /devices/platform/i8042/serio1/serio2/input/input13
What have I tried already
1. Specified systemd-modules-load in After= and Requires= directives and added psmouse module to /etc/modules-load.d
2. Tried path activation (perhaps, I did it wrong) by creating i8042.path
[Path]
PathExists=/sys/devices/platform/i8042
Unit=trackpoint.service
However, this changed nothing.
I don't know what else should I try.
Please suggest solution for this.
Thanks in advance.
Last edited by eDio (2013-06-15 13:28:36)
Offline
You actually want a custom udev rule instead of a systemd service. See: https://wiki.archlinux.org/index.php/Ud … udev_rules
Offline
Thank you very much.
I've finally managed this to work
$ cat /etc/udev/rules.d/10-trackpoint.rules
SUBSYSTEM=="input", KERNEL=="event13", ACTION=="add", RUN+="/usr/bin/trackpoint_apply"
$ cat /etc/conf.d/trackpoint.conf
speed=255
sensitivity=255
$ cat /usr/bin/trackpoint_apply
#!/usr/bin/env sh
. /etc/conf.d/trackpoint.conf
/usr/bin/echo $speed > /sys/devices/platform/i8042/serio1/serio2/sensitivity
/usr/bin/echo $sensitivity > /sys/devices/platform/i8042/serio1/serio2/speed
Offline
Instead of running a script, you can let udev do everything for you:
ACTION=="add",SUBSYSTEM=="input",ATTR{name}=="TPPS/2 IBM TrackPoint",ATTR{device/sensitivity}="255",ATTR{device/speed}="255"
Offline
Thanks for the hint! That's much simpler.
Offline