[H-GEN] toggling touchpad

Russell Stuart russell-humbug at stuart.id.au
Mon Feb 23 00:24:49 EST 2009


On Mon, 2009-02-23 at 14:31 +1000, Peter Robinson wrote:
> # Turn the touchpad off if mouse is added and turn back on if removed
> ACTION == "add", SUBSYSTEM=="input", ID_CLASS="mouse",     
> RUN+="/home/pjr/.udevtoggletouch add"
> ACTION == "remove", SUBSYSTEM=="input", ID_CLASS="mouse",     
> RUN+="/home/pjr/.udevtoggletouch remove"
> 
> I know that the script gets called when the mouse is added/removed 
> because I added a line that touched  files in /tmp.

Does the script work if you run it manually?  If not, can you 
post a copy of the script.  Don't attach it - the list manager
doesn't like attachments.

My usual way of debugging scripts like this (assuming it is a 
shell script) is to add these lines to the front:

  if [ ! -t 0 ]
  then
    mkdir -p /tmp/daemon-trace
    chmod a+rwx "/tmp/daemon-trace" || :
    rm -f "/tmp/daemon-trace/${0##*/}"
    exec >"/tmp/daemon-trace/${0##*/}" 2>&1
    set -xv
  fi

This puts a trace of what happened in /tmp/daemon-trace every 
time your script is run in the background.

As for disabling it as boot up, my typical way of doing this 
is to make the script do mouse detection, as opposed to passing 
it a parameter on the command line as you are doing now. On my
system, /dev/input/mouse2 is present iff a USB mouse is plugged 
in, so just detecting for its existence would work for me.  This
is old school.  A more "correct" was of doing it on modern
kernels would be to check for the existence of files
under /sys/class/input.  A quick comparison of the what is in
/sys/class/input when the mouse is and isn't plugged in should
make it obvious what to check for.

On debian you can make your script run at boot up by just 
putting a symlink into /etc/rcS.d (see
http://www.debian.org/doc/FAQ/ch-customizing.en.html
section 11.6 for an explanation of how to do this.) I vaguely
recall Ubuntu changed over to some new-fangled replacement for 
init, so that may not work.  Googling "ubuntu rc.local" should 
tell you what to do.





More information about the General mailing list