You are not logged in.

#1 2013-06-14 21:03:54

eDio
Member
From: Ukraine, Kyiv
Registered: 2008-12-02
Posts: 407

[invalid] Run systemd service after specific device is initialized

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

#2 2013-06-15 07:37:42

Stebalien
Member
Registered: 2010-04-27
Posts: 1,231
Website

Re: [invalid] Run systemd service after specific device is initialized

You actually want a custom udev rule instead of a systemd service. See: https://wiki.archlinux.org/index.php/Ud … udev_rules


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com

Offline

#3 2013-06-15 13:27:42

eDio
Member
From: Ukraine, Kyiv
Registered: 2008-12-02
Posts: 407

Re: [invalid] Run systemd service after specific device is initialized

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

#4 2013-06-15 18:31:08

Stebalien
Member
Registered: 2010-04-27
Posts: 1,231
Website

Re: [invalid] Run systemd service after specific device is initialized

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"

Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com

Offline

#5 2013-06-17 18:03:27

eDio
Member
From: Ukraine, Kyiv
Registered: 2008-12-02
Posts: 407

Re: [invalid] Run systemd service after specific device is initialized

Thanks for the hint! That's much simpler.

Offline

Board footer

Powered by FluxBB