View Poll Results: Did this work for you?

Voters
23. You may not vote on this poll
  • Yes!

    17 73.91%
  • No.

    6 26.09%
Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 32

Thread: [HOWTO] Automatically disable touchpad when external mouse connected

  1. #11
    Join Date
    Feb 2010
    Beans
    35

    Re: [HOWTO] Automatically disable touchpad when external mouse connected

    After restart or suspend or hibernate script dont work, it only works again if i put in terminal halevt -c ~/.halevt.xml. I have ubuntu 10.10 i put in Startup programs this command but like i said doesnt work,any ideas how to fix it?

  2. #12
    Join Date
    Jul 2010
    Beans
    3

    Re: [HOWTO] Automatically disable touchpad when external mouse connected

    Quote Originally Posted by Shadowgamon View Post
    killer script dude! it works a heck of a lot easier than the SMHcofing hullabaloo.

    I just cant get it to shut off when my mouse is plugged in. Since deafient seems to have an identical touch pad to me that' doesn't seem to be the problem.

    I think it might be at

    halevt -i >>~/connectedDevices.txt

    cause I get
    Code:
    New Device: /org/freedesktop/Hal/devices/usb_device_15d9_a4d_noserial
    New Device: /org/freedesktop/Hal/devices/usb_device_15d9_a4d_noserial_if0
    New Device: /org/freedesktop/Hal/devices/usb_device_15d9_a4d_noserial_if0_logicaldev_input
    Device removed: /org/freedesktop/Hal/devices/usb_device_15d9_a4d_noserial_if0_logicaldev_input
    Device removed: /org/freedesktop/Hal/devices/usb_device_15d9_a4d_noserial_if0
    Device removed: /org/freedesktop/Hal/devices/usb_device_15d9_a4d_noserial
    Got signal 2
    As you can see none of them have "seemingly random numbers" Which should I use?
    I had exactly the same absence of the serial numbers, but i pasted almost all string without _if0, so "/org/freedesktop/Hal/devices/usb_device_15d9_a4d_noserial".

    And just wanted to add, that before making "toggling" testing the login/logout should be done (at least in mine maverick box ).

    To the author: After reboot, if the external mouse inserted, the script not working, then i should done re-inserting of the pointer, as i understood, the script is only catching events of the insertion, but not the initial state. But anyway thanks, because for me on rather old laptop with buggy touchpad it made life easier.

  3. #13
    Join Date
    Feb 2010
    Beans
    35

    Re: [HOWTO] Automatically disable touchpad when external mouse connected

    I get it work from boot with: /bin/sh -c 'DISPLAY=:0 halevt -c ~/.halevt.xml' in Startup programs.
    I create script which works when mouse is pluged in:

    sudo gedit /etc/init.d/touchpad
    #! /bin/sh
    DEVICE_ID=`xinput -list | grep -i mouse | grep id= | sed 's/.*id=\([0-9]*\).*/\1/' `
    if xinput -list | grep -i mouse | grep id=$DEVICE_ID > /dev/null
    then
    echo "je notr"
    /bin/sh -c `DISPLAY=:0 gconftool-2 --set "/desktop/gnome/peripherals/touchpad/touchpad_enabled" --type boolean "false"`
    else
    echo "ni notr"
    /bin/sh -c `DISPLAY=:0 gconftool-2 --set "/desktop/gnome/peripherals/touchpad/touchpad_enabled" --type boolean "true"`
    fi
    sudo chmod +x /etc/init.d/touchpad

    And than i add in startup programs /etc/init.d/touchpad that gets work from reboot now from suspend,hibernate i add:
    sudo gedit /etc/pm/sleep.d/99-touchpad.sh
    #!/bin/bash
    case "$1" in
    thaw|resume)
    /etc/init.d/touchpad 2>/dev/null
    ;;
    *)
    ;;
    esac
    exit $?
    sudo chmod +x /etc/pm/sleep.d/99-touchpad.sh

    Now everything seems to work but i have to add in toggleTouchpad after # The argument was 'on', so turn the touchpad on
    /bin/sh -c `DISPLAY=:0 gconftool-2 --set "/desktop/gnome/peripherals/touchpad/touchpad_enabled" --type boolean "true"`
    and after # The argument was 'off', so turn the touchpad off
    /bin/sh -c `DISPLAY=:0 gconftool-2 --set "/desktop/gnome/peripherals/touchpad/touchpad_enabled" --type boolean "false"`

    If anybody know better solution pleasse post it, because this script turn off in gconf-editor not in xinput soo xinput than doesnt work.
    Last edited by cobra11; December 6th, 2010 at 01:50 PM.

  4. #14
    Join Date
    Nov 2010
    Beans
    7

    Re: [HOWTO] Automatically disable touchpad when external mouse connected

    I get :
    toggleTouchpad: command not found

    I have copy and pasted everything in the guide twice now

    Any ideas???

  5. #15
    Join Date
    Mar 2007
    Location
    TN, US
    Beans
    607
    Distro
    Ubuntu

    Re: [HOWTO] Automatically disable touchpad when external mouse connected

    Quote Originally Posted by monoxide.tryst View Post
    I get :
    toggleTouchpad: command not found

    I have copy and pasted everything in the guide twice now

    Any ideas???
    It sounds like either toggleTouchpad is not in your path, or possibly named slightly differently. In terminal try
    Code:
    echo $PATH
    and make sure that the directory you have placed toggleTouchpad in shows up. If you're not sure, post the results here and we'll take a look for you.
    Registered Linux user 446122 , Registered Machine 352936.

  6. #16
    Join Date
    Mar 2010
    Location
    Sacramento, CA
    Beans
    226
    Distro
    Ubuntu Studio 10.04 Lucid Lynx

    Re: [HOWTO] Automatically disable touchpad when external mouse connected

    Working fine on my Compaq Presario V5101US & running Ubuntu 10.10 32bit
    http://colorblinddesigns.com

  7. #17
    Join Date
    Nov 2010
    Location
    New Zealand
    Beans
    1
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: [HOWTO] Automatically disable touchpad when external mouse connected

    I had some problems with the script in Karmic (9.10).

    It appears that I might be running an older version of xinput (1.4.2) that does not support --set-prop, so instead I have to use the (now deprecated) --set-int-prop command.

    I have also modified line 24 to change the way AWK is used - the previous version always assumed that there would be a fixed number of spaces in the device name.

    Code:
    # toggleTouchpad by Brendon Dugan
    # Toggles a touchpad on or off depending on it's current state or CLI argument
    #
    # To configure, run the command 'xinput list' in terminal and identify your touch pad.
    # Using the output of the above command, change the touchpadString variable to a substring
    # of your touchpad's description that is unique to that device.
    #
    # To run, simply type 'toggleTouchpad' to toggle your touchpad on or off, or
    # 'toggleTouchpad on' to explicitly turn your touchpad on, or
    # 'toggleTouchpad off' to explicitly turn it off.
    #
    # Enjoy!
    
    
    # A function for logging
    safemk () {
    if [ ! -d $1 ]; 
      then mkdir $1; 
      chmod +rw $1; 
    fi
    }
    logdir=/home/$USER/.toggleTouchpad
    touchpadString="TouchPad"
    touchpadID=$(xinput list | grep $touchpadString | awk -F '"' '{print $3}' | awk -F " " '{print $1}' | awk -F "=" '{print $2}')
    touchpadEnabled=$(xinput list-props $touchpadID | grep "Device Enabled" | awk -F ":" '{print $2}')
    sleeptime=1
    
    # Create the logging directory
    safemk $logdir
    touch $logdir/errorLog.txt
    
    # Check for arguments on the command line
    if test $# -eq 1
    then
    	# Change the argument to lowercase
    	arg1=$(echo $1 | tr [:upper:] [:lower:])
    	cliArg=1
    else
    	# There is no argument.
    	cliArg=0
    fi
    
    if [ $cliArg -eq 1 ]
    then
    	# If there's an argument, check to see whether it is on, off, or junk
    	if [ $arg1 = 'on' ]
    	then
    		# The argument was 'on', so turn the touchpad on
    		xinput --set-int-prop $touchpadID "Device Enabled" 8 1
    		if [ $(xinput list-props $touchpadID | grep "Device Enabled" | awk -F ":" '{print $2}') -eq 0 ]
    		then
    			echo "Something went wrong\n" >> $logdir/errorLog.txt
    		fi
    	elif [ $arg1 = 'off' ]
    	then
    		# Sleep for a short time to fix a bug that re-enabled the touchpad immediately after disabling it
    		sleep $sleeptime
    		# The argument was 'off', so turn the touchpad off 
    		xinput --set-int-prop $touchpadID "Device Enabled" 8 0
    		if [ $(xinput list-props $touchpadID | grep "Device Enabled" | awk -F ":" '{print $2}') -eq 1 ]
    		then
    			echo "Something went wrong, perhaps \$sleeptime needs to be greater than $sleeptime ?\n" >> $logdir/errorLog.txt
    		fi
    	else
    		# The argument was junk, so log the error and go on 
    		echo "Invalid argument \""$arg1"\" was supplied\n" >> $logdir/errorLog.txt
    	fi
    else
    	# There was no argument, so just toggle the touchpad to the opposite
    	# of the state it has now.
    	if [ $touchpadEnabled -eq 1 ]
    	then
    		xinput --set-int-prop $touchpadID "Device Enabled" 8 0
    	else
    		xinput --set-int-prop $touchpadID "Device Enabled" 8 1
    	fi
    fi
    I would be glad to hear your thoughts.

    Cheers.

  8. #18
    Join Date
    Jul 2009
    Beans
    1
    Distro
    Ubuntu Studio 10.10 Maverick Meerkat

    Re: [HOWTO] Automatically disable touchpad when external mouse connected

    I had to do the same thing with the awk statement on line 24. Mine wound up being:

    Code:
    touchpadID=$(xinput list | grep $touchpadString | awk -F " " '{print $7}' | awk -F "=" '{print $2}')
    Thanks for a great script!

    Joe

  9. #19
    Join Date
    May 2008
    Beans
    5

    Re: [HOWTO] Automatically disable touchpad when external mouse connected

    Ubuntu 10.10
    PHP Code:
    sudo nano /etc/init.d/touchpad 
    I ended up with this script:
    PHP Code:
    touchpadID=$(xinput list | grep TouchPad awk -"=" '{print $2}' awk -" " '{print $1}')
    touchpadEnabled=$(xinput list-props $touchpadID grep "Device Enabled" awk -":" '{print $2}')
    mouseId=$(xinput list | grep Mouse awk -"=" '{print $2}' awk -" " '{print $1}')
    mouseEnabled=$(xinput list-props $mouseId grep "Device Enabled" awk -":" '{print $2}')

    if [ 
    $mouseEnabled -eq 1 ]
    then
            xinput 
    --set-int-prop $touchpadID "Device Enabled" 8 0
    else
            
    xinput --set-int-prop $touchpadID "Device Enabled" 8 1
    fi 
    PHP Code:
    sudo chmod +/etc/init.d/touchpad
    update
    -rc.d touchpad defaults 
    Enjoy!

  10. #20
    Join Date
    Apr 2011
    Beans
    2

    Re: [HOWTO] Automatically disable touchpad when external mouse connected

    Hi Faifas

    I tried your script and I got the following response.

    cantru@mobile-UL50VT:~$ sudo chmod +x /etc/init.d/touchpad
    cantru@mobile-UL50VT:~$ update-rc.d touchpad defaults
    update-rc.d: warning: /etc/init.d/touchpad missing LSB information
    update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
    System start/stop links for /etc/init.d/touchpad already exist.
    Died at /usr/sbin/update-rc.d line 57.

    Any advice

    Thanks.

Page 2 of 4 FirstFirst 1234 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •