You are not logged in.

#1 2013-04-27 17:00:18

Atronach
Member
From: Czech Republic
Registered: 2010-11-13
Posts: 48

[SOLVED] Udev doesn't execute a script

Hi,
I've been using a script for configuring trackpoint automatically ran by udev at start for a long time. I've been using this guide.
So I have created /etc/udev/rules.d/10-custom.rules with this content:

SUBSYSTEM=="input", ATTR{name}=="*TrackPoint*", RUN+="/etc/conf.d/trackpoint"

... and /etc/conf.d/trackpoint with this one:

#!/bin/bash

## Trackpoint settings

# When run from a udev rule, DEVPATH should be set
if [ ! -z $DEVPATH ] ; then
    TPDEV=/sys/$( echo "$DEVPATH" | sed 's/\/input\/input[0-9]*//' )
else
# Otherwise just look in /sys/
    TPDEV=$(find /sys/devices/platform/i8042 -name name | xargs grep -Fl TrackPoint | sed 's/\/input\/input[0-9]*\/name$//')
fi

# http://www.thinkwiki.org/wiki/How_to_configure_the_TrackPoint
# http://wwwcssrv.almaden.ibm.com/trackpoint/files/ykt3eext.pdf
#------------------------------------------------------------
if [ -d "$TPDEV" ]; then
    echo "Configuring Trackpoint"
    echo -n 255     > $TPDEV/sensitivity     # Integer  128 Sensitivity                    
    echo -n 128     > $TPDEV/speed           # Integer  97  Cursor speed                            
    echo -n 4       > $TPDEV/inertia         # Integer  6   Described as "negative inertia." It acts more like friction. High values cause the cursor to snap backward when the Trackpoint is released.        
    echo -n 10      > $TPDEV/reach           # Integer  10  Backup for Z-axis press
    echo -n 255     > $TPDEV/draghys         # Integer  255 Drag hysteresis (how hard it is to drag with Z-axis pressed)
    echo -n 20      > $TPDEV/mindrag         # Integer  20  Minimum amount of force needed to trigger dragging
    echo -n 8       > $TPDEV/thresh          # Integer  8   Minimum value for a Z-axis press
    echo -n 255     > $TPDEV/upthresh        # Integer  255 Used to generate a 'click' on Z-axis
    echo -n 38      > $TPDEV/ztime           # Integer  38  How sharp of a press
    echo -n 135     > $TPDEV/jenks           # Integer  135 Minimum curvature for double click
    echo -n 0       > $TPDEV/press_to_select # Boolean  0   Press to select
    echo -n 0       > $TPDEV/skipback        # Boolean  0   Supress movement after drag release
    echo -n 0       > $TPDEV/ext_dev         # Boolean  0   Disable external device
else
    echo "Couldn't find trackpoint device $TPDEV"
fi

Of course the file is executable globally-wise (just for sure):

$ ls -l /etc/conf.d/trackpoint
-rwxr-xr-x 1 root root 1995 16. dub 15.08 /etc/conf.d/trackpoint

But a week back i noticed the script isn't ran automatically and I have to do

$ sudo sh /etc/conf.d/trackpoint

to get the customized settings applied, what's more I don't understand why I have to run the "sh" command as root otherwise i get "Permission denied" despite the script is executable for everyone.
Any idea? Thanks.

Last edited by Atronach (2013-04-28 01:18:39)

Offline

#2 2013-04-27 19:32:23

Atronach
Member
From: Czech Republic
Registered: 2010-11-13
Posts: 48

Re: [SOLVED] Udev doesn't execute a script

UPDATE:
I've realized that the "Permission denied" error stems from the inability to modify the Sysfs options (sensitivity, speed, ...) by the script but the sript itself is executed after all. So i just added "su -c" to every line changing a Sysfs option in the script, it now looks like this:

#!/bin/bash

## Trackpoint settings

# When run from a udev rule, DEVPATH should be set
if [ ! -z $DEVPATH ] ; then
    TPDEV=/sys/$( echo "$DEVPATH" | sed 's/\/input\/input[0-9]*//' )
else
# Otherwise just look in /sys/
    TPDEV=$(find /sys/devices/platform/i8042 -name name | xargs grep -Fl TrackPoint | sed 's/\/input\/input[0-9]*\/name$//')
fi

# http://www.thinkwiki.org/wiki/How_to_configure_the_TrackPoint
# http://wwwcssrv.almaden.ibm.com/trackpoint/files/ykt3eext.pdf
#------------------------------------------------------------
if [ -d "$TPDEV" ]; then
    echo "Configuring Trackpoint"
    su -c "echo -n 255	> $TPDEV/sensitivity"     # Integer 128 Sensitivity                    
    su -c "echo -n 128	> $TPDEV/speed"           # Integer 97  Cursor speed                            
    su -c "echo -n 4	> $TPDEV/inertia"         # Integer 6   Described as "negative inertia." It acts more like friction. High values cause the cursor to snap backward when the Trackpoint is released.        
    su -c "echo -n 10	> $TPDEV/reach"           # Integer 10  Backup for Z-axis press
    su -c "echo -n 255	> $TPDEV/draghys"         # Integer 255 Drag hysteresis (how hard it is to drag with Z-axis pressed)
    su -c "echo -n 20	> $TPDEV/mindrag"         # Integer 20  Minimum amount of force needed to trigger dragging
    su -c "echo -n 8	> $TPDEV/thresh"          # Integer 8   Minimum value for a Z-axis press
    su -c "echo -n 255	> $TPDEV/upthresh"        # Integer 255 Used to generate a 'click' on Z-axis
    su -c "echo -n 38	> $TPDEV/ztime"           # Integer 38  How sharp of a press
    su -c "echo -n 135	> $TPDEV/jenks"           # Integer 135 Minimum curvature for double click
    su -c "echo -n 0	> $TPDEV/press_to_select" # Boolean 0   Press to select
    su -c "echo -n 0	> $TPDEV/skipback"        # Boolean 0   Supress movement after drag release
    su -c "echo -n 0	> $TPDEV/ext_dev"         # Boolean 0   Disable external device
else
    echo "Couldn't find trackpoint device $TPDEV"
fi

... and I can finally execute it with "sh" without the root permssions however udev still doesn't seem to apply the Sysfs options automatically.
Nevertheless according to the debug output the udev rule should run:

$ udevadm test /sys/devices/platform/i8042/serio1/serio2/
calling: test
version 202
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

=== trie on-disk ===
tool version:          202
file size:         5615641 bytes
header size             80 bytes
strings            1258089 bytes
nodes              4357472 bytes
load module index
read rules file: /etc/udev/rules.d/10-custom.rules
...

Anybody?

Last edited by Atronach (2013-04-27 20:29:15)

Offline

#3 2013-04-27 19:35:57

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 18,552
Website

Re: [SOLVED] Udev doesn't execute a script

Not an Installation issue, moving to Kernel and Hardware...


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#4 2013-04-28 01:17:23

Atronach
Member
From: Czech Republic
Registered: 2010-11-13
Posts: 48

Re: [SOLVED] Udev doesn't execute a script

Alright, I got it working. According to this I only had to rename the udev rule "10-custom.rules" to "81-custom.rules" so it's executed later during the boot process when the device node is finally created or something like that.

Last edited by Atronach (2013-04-28 01:17:59)

Offline

Board footer

Powered by FluxBB