You are not logged in.

#1 2009-10-25 13:33:57

cyanode
Member
From: Hamburg, Germany
Registered: 2009-10-25
Posts: 4

[SOLVED] udev rules for disabling touchpad

Hello everyone,
I'm relatively new to arch but I have made myself familiar with it quite quickly.
However, I'm stuck with creating an udev rule for disabling the touchpad while an external mouse is plugged in.

ACTION=="add", SUBSYSTEM=="input", ENV{ID_CLASS}="mouse", RUN+="/usr/bin/synclient -s TouchpadOff=1"
ACTION=="remove", SUBSYSTEM=="input", ENV{ID_CLASS}="mouse", RUN+="/usr/bin/synclient -s TouchpadOff=0"

as proposed in the wiki did not work for me.
I found out that the mouse is indeed recognized by udev, as adding

SYMLINK+="usbmouse"

to the rule does create the corresponding device node in /dev.
Changing the "RUN+="-command was sometimes successful. Apparently

RUN+="/bin/touch /123"

works, as well as

RUN+="/usr/bin/xterm -display :0.0"

while for instance

RUN+="/usr/bin/firefox"

does not (I tested with several commands to see if that changes anything)
Does anyone have an idea why some programs are being run by udev and others are not?
http://reactivated.net/writing_udev_rules.html says

udev does not run these programs on any active terminal, and it does not execute them under the context of a shell. Be sure to ensure your program is marked executable, if it is a shell script ensure it starts with an appropriate shebang (e.g. #!/bin/sh), and do not expect any standard output to appear on your terminal.

Wrapping the synclient command into a wrapper script and adding that to the "RUN+="-command didn't work either.
Any idea how to make my rule work properly?
Thanks in advance

EDIT: Maybe I should add that running the synclient command manually has the desired effect (both as root and as normal user)

Last edited by cyanode (2009-10-27 11:49:06)

Offline

#2 2009-10-26 17:27:52

cyanode
Member
From: Hamburg, Germany
Registered: 2009-10-25
Posts: 4

Re: [SOLVED] udev rules for disabling touchpad

Bump

Offline

#3 2009-10-26 19:59:45

barto
Member
From: Budapest, Hungary
Registered: 2009-10-22
Posts: 88

Re: [SOLVED] udev rules for disabling touchpad

Hello,

I don't know whether it is a solution or just a dirty, lazy workaround, but it works for me.

It's quite a common problem especially with at and cron, that some commands need a special environment to run correctly, and at's, cron's and apparently udev's environment differs from that you have in a terminal. I don't know which environmental variable(s) are the "guilty", so I suggest you to save the whole environment, and restore it when needed.

1. Search for an environment where synclient works. In the same terminal (if it is a terminal), issue the command:

export -p > /path/to/your/environmentbackup

2. Add the following line to your wrapper script, right after the shebang.

. /path/to/your/environmentbackup

I hope it will work. I have no touchpad, so I couldn't test is. But I managed to start firefox* just by plugging my scanner. Which is absolutely not the way I would like to use my scanner, however... smile

No bumps please.

*EDIT: I must add that it is not a good idea to do anything with a firefox started with that artificial environment. You will still have root privileges (insecure), but with your home directory set to that of your user results some additional files in your ~/.mozilla, but owned by root (messy and disfunctional). Maybe you can delete those obviously unrelated lines from your /path/to/your/environmentbackup.

Last edited by barto (2009-10-27 12:01:45)


“First principle, Clarice. Simplicity” – Dr. Hannibal Lecter

Offline

#4 2009-10-27 11:23:08

cyanode
Member
From: Hamburg, Germany
Registered: 2009-10-25
Posts: 4

Re: [SOLVED] udev rules for disabling touchpad

Great it worked like a charm smile
Thank you very much!
(and sorry for bumping)
And indeed, running programs like firefox in such a messed up environment is definetely a bad idea.
Synclient is a harmless one I think.
Anyway thanks again.

Offline

#5 2009-11-23 17:39:02

Zerimas
Member
From: Waterloo, Ontario
Registered: 2009-08-25
Posts: 21

Re: [SOLVED] udev rules for disabling touchpad

I am having the same problem. Is there any chance you could post your wrapper script? I've never done any shell scripting and I am a little unclear where the path variable goes.  Thanks!

Offline

#6 2009-11-25 01:42:06

barto
Member
From: Budapest, Hungary
Registered: 2009-10-22
Posts: 88

Re: [SOLVED] udev rules for disabling touchpad

It should look something like this:

#!/bin/bash

. /path/to/your/environmentbackup
/usr/bin/synclient -s TouchpadOff=$1

In this case you should launch your script to enable/disable touchpad with the required value (0/1 respectively) as a command line argument to the script.

A very good howto to start learning bash scripting can be found here:
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
It's likely you can read it in your native language too:
http://www.ibiblio.org/pub/Linux/docs/H … nslations/


“First principle, Clarice. Simplicity” – Dr. Hannibal Lecter

Offline

Board footer

Powered by FluxBB