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 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 32

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

  1. #21
    Join Date
    May 2008
    Beans
    5

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

    Hi,

    my script wasn't following rules described at debian wiki

    here's a quick fix
    PHP Code:
    #!/bin/bash
    ### BEGIN INIT INFO
    # Provides:          touchpad
    # Required-Start:    $remote_fs $syslog
    # Required-Stop:     $remote_fs $syslog
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Start daemon at boot time
    # Description:       Enable service provided by daemon.
    ### END INIT INFO

    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 
    Error message saying
    Code:
    System start/stop links for /etc/init.d/touchpad already exist.
    means you already have touchpad script added to run-time. If it is the same script you can

    Code:
    sudo update-rc.d -f touchpad remove
    sudo update-rc.d touchpad defaults
    Hope this helps!

  2. #22
    Join Date
    Aug 2009
    Beans
    3

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

    Hey brennydoogles, thanks for your script! After the "touchpad-indicator" did not work on my laptop this was a neat solution for my problems!

    However, in order to get the script (the version of the first post) running properly i had to do some minor adjustment:

    This part of your code:

    Code:
    touchpadString="TouchPad"
    touchpadID=$(xinput list | grep $touchpadString | awk -F " " '{print $6}' | awk -F "=" '{print $2}')
    touchpadEnabled=$(xinput list-props $touchpadID | grep "Device Enabled" | awk -F ":" '{print $2}')
    sleeptime=1
    I had to change to:

    Code:
    
    touchpadString="PS/2 Mouse"
    touchpadID=$(xinput list | grep "PS/2 Mouse" | awk -F " " '{print $5}' | awk -F "=" '{print $2}')
    touchpadEnabled=$(xinput list-props $touchpadID | grep "Device Enabled" | awk -F ":" '{print $2}')
    sleeptime=1
    
    Due to the fact that
    a) my mouse name was "PS/2 Mouse"
    b) depending on the name of your mouse, the number after print has to be changed. Best try the command:
    Code:
    xinput list | grep "PS/2 Mouse" | awk -F " " '{print $5}'
    with always different numbers, until it gives you something like "id=12"
    Last edited by Votti; July 8th, 2011 at 06:31 PM.

  3. #23
    Join Date
    Sep 2011
    Beans
    21

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

    Thanks a lot, however the auto start did not work for my for some strange reason so i created a keyboard shortcut to turn on/off the touchpad.

    Thanks a lot for your work!

  4. #24
    Join Date
    Nov 2009
    Beans
    26

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

    Here's a sript I've used. It's essentially the same as above, but it should figure out the mouse id automatically and it toggles touchpad off only is usb/bluetooth/wireless mouse is connected.

    Now if I only got this to run automatically when mouse is (dis)connected...

    I had it in startup applications, and Karmic it worked fine. But in Lucid some other application enables touchpad right away again.


    Code:
    #!/bin/sh
    
    DEVICE_ID=`xinput -list | grep -i touchpad | grep id= | sed 's/.*id=\([0-9]*\).*/\1/' `
    
    if xinput -list-props $DEVICE_ID | grep "Device Enabled" | grep "1$" > /dev/null
    then 
        if xinput -list | grep -i mouse | egrep -i 'usb|bluetooth|wireless' > /dev/null
        then
            xinput set-int-prop $DEVICE_ID "Device Enabled" 8 0
        fi
    else
        xinput set-int-prop $DEVICE_ID "Device Enabled" 8 1
    fi

  5. #25
    Join Date
    Feb 2010
    Beans
    35

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

    Is there anyway that i could hide or move this script? Because it is in home folder and goes on my nervous, when i open home map?

  6. #26
    Join Date
    Sep 2011
    Beans
    21

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

    Thanks! works fine for me

  7. #27
    Join Date
    Sep 2005
    Beans
    5

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

    The proposed "touchpadToggle" script was not working for my MacBook, so I did rewrite it.

    If it doesn't works, you may have to add the proper value for RECEIVER_ID or TRACKPAD_ID. You can find them running xinput -list (please post them here)


    Code:
    # !/bin/sh
    sleep 1
    
    # uncomment the following line and the last line to enable logging
    #(
    
    RECEIVER_ID='mouse|ps.2|usb|bluetooth|wireless|receiver'
    TRACKPAD_ID='appletouch|glidepoint|trackpad'
    
    TRACKPAD_DEVICE_ID=`xinput -list | egrep -i $TRACKPAD_ID | grep id= | sed -e 's/.*id=\([0-9]*\).*/\1/' -e T -e q`
    
    if [ -z "$TRACKPAD_DEVICE_ID" ]
    then
            echo "Device not found !"
            xinput -list | egrep -r "slave +pointer"
            echo "Edit $0 and add the required string to TRACKPAD_ID='$TRACKPAD_ID'"
            exit 1
    fi
    
    TRACKPAD_DEVICE_NAME=$(xinput -list-props $TRACKPAD_DEVICE_ID | grep Device.\' | cut -d "'" -f 2)
    echo Device detected: $TRACKPAD_DEVICE_NAME
    
    DEVICE_ENABLED=$(xinput -list-props $TRACKPAD_DEVICE_ID | grep "Device Enabled" | grep "1$")
    
    trackpad_enable() {
            if [ -z "$DEVICE_ENABLED" ]
            then
                    echo "enabling device"
                    xinput set-int-prop $TRACKPAD_DEVICE_ID "Device Enabled" 8 1
            else
                    echo "already enabled"
            fi
    }
    
    trackpad_disable() {
            if [ -z "$DEVICE_ENABLED" ]
            then
                    echo "already disabled"
            else
                    echo "disabling device"
                    xinput set-int-prop $TRACKPAD_DEVICE_ID "Device Enabled" 8 0
            fi
    }
    
    trackpad_auto() {
            RECEIVER_DETECTED=$(xinput -list | egrep -r "slave +pointer" | egrep -i $RECEIVER_ID)
    
            if [ -z "$RECEIVER_DETECTED" ]
            then trackpad_enable
            else trackpad_disable
            fi
    }
    
    usage() {
            echo "usage: `basename $0` [ on | off ]"
            exit 1
    }
    
    case "$1" in
            on) trackpad_enable ;;
            off) trackpad_disable ;;
            *) if [ -z "$1" ]
               then trackpad_auto
               else usage
               fi ;;
    esac
    
    #) >> /tmp/touchpadToggle.log
    Last edited by gnomicon; February 6th, 2012 at 10:50 PM.

  8. #28
    Join Date
    Jan 2010
    Location
    Mexico City
    Beans
    66
    Distro
    Ubuntu 14.04 Trusty Tahr

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

    Neat code! Mega thanx 2 brennydoogles, works fine in Dell XPS 13 corei5 running 64bit Precise (12.04) Ubuntu.

  9. #29
    Join Date
    Sep 2011
    Beans
    9

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

    Hi.

    The script is not working for me. xinput command shows that I have two touchpads, here's the output from terminal window:

    Code:
    Virtual core pointer                    	id=2	[master pointer  (3)]
    ⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
    ⎜   ↳ Logitech Gaming Mouse G400              	id=10	[slave  pointer  (2)]
    ⎜   ↳ X10 WTI RF receiver mouse               	id=11	[slave  pointer  (2)]
    ⎜   ↳ SynPS/2 Synaptics TouchPad              	id=14	[slave  pointer  (2)]
    ⎜   ↳ SynPS/2 Synaptics TouchPad              	id=15	[slave  pointer  (2)]
    ⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
        ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
        ↳ Power Button                            	id=6	[slave  keyboard (3)]
        ↳ Video Bus                               	id=7	[slave  keyboard (3)]
        ↳ Sleep Button                            	id=8	[slave  keyboard (3)]
        ↳ Bison Webcam                            	id=9	[slave  keyboard (3)]
        ↳ X10 WTI RF receiver                     	id=12	[slave  keyboard (3)]
        ↳ AT Translated Set 2 keyboard            	id=13	[slave  keyboard (3)]
    Can somebody please explain or point how can I delete one of two touchpads? Or maybe put some changes to the script so it can work with my configuration.

  10. #30
    Join Date
    Sep 2011
    Beans
    9

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

    bump

Page 3 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
  •