I know that I can check if the touchpad is active with

gconftool-2 --get /desktop/gnome/peripherals/touchpad/touchpad_enabled 

and I can set it disabled / enabled with

gconftool-2 --set --type boolean /desktop/gnome/peripherals/touchpad/touchpad_enabled true

With lsusb I can see all connected USB-devices. Which is for my mouse:

Bus 003 Device 002: ID 046d:c00e Logitech, Inc. M-BJ58/M-BJ69 Optical Wheel Mouse

More information with lsusb -v:

Bus 005 Device 002: ID 046d:c00e Logitech, Inc. M-BJ58/M-BJ69 Optical Wheel Mouse
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x046d Logitech, Inc.
  idProduct          0xc00e M-BJ58/M-BJ69 Optical Wheel Mouse
  bcdDevice           11.10
  iManufacturer           1 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower               98mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      52
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              10

And here is the information from tail -n 10 -f /var/log/messages:

Aug 27 08:36:47 pc08 kernel: [ 1795.936583] usb 5-2: USB disconnect, address 3
Aug 27 08:36:55 pc08 kernel: [ 1804.208042] usb 5-2: new low speed USB device using uhci_hcd and address 4
Aug 27 08:36:56 pc08 kernel: [ 1804.384272] usb 5-2: configuration #1 chosen from 1 choice
Aug 27 08:36:56 pc08 kernel: [ 1804.400743] input: Logitech USB-PS/2 Optical Mouse as /devices/pci0000:00/0000:00:1d.0/usb5/5-2/5-2:1.0/input/input13
Aug 27 08:36:56 pc08 kernel: [ 1804.400923] generic-usb 0003:046D:C00E.0004: input,hidraw0: USB HID v1.10 Mouse [Logitech USB-PS/2 Optical Mouse] on usb-0000:00:1d.0-2/input0

And even more information:

$ udevadm info --query=all --name=/dev/input/mouse1
P: /devices/pci0000:00/0000:00:1d.0/usb5/5-2/5-2:1.0/input/input15/mouse1
N: input/mouse1
S: char/13:33
S: input/by-id/usb-Logitech_USB-PS_2_Optical_Mouse-mouse
S: input/by-path/pci-0000:00:1d.0-usb-0:2:1.0-mouse
E: DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb5/5-2/5-2:1.0/input/input15/mouse1
E: DEVNAME=/dev/input/mouse1
E: ID_VENDOR=Logitech
E: ID_MODEL=USB-PS_2_Optical_Mouse
E: ID_MODEL_ENC=USB-PS\x2f2\x20Optical\x20Mouse
E: ID_SERIAL=Logitech_USB-PS_2_Optical_Mouse
E: ID_TYPE=hid
E: ID_BUS=usb
E: ID_PATH=pci-0000:00:1d.0-usb-0:2:1.0
E: DEVLINKS=/dev/char/13:33 /dev/input/by-id/usb-Logitech_USB-PS_2_Optical_Mouse-mouse /dev/input/by-path/pci-0000:00:1d.0-usb-0:2:1.0-mouse

How can I use this to automatically deactivate my touchpad when a USB-mouse is connected and activate it again as soon as the USB-mouse disappears?


5 Answers 5


This project appears to be no longer maintained.

For natty there is a touchpad indicator app. it can be set to disable/enable the touchpad when a mouse is plugged in or out. I have no idea if it might also work for older Ubuntu versions.


sudo add-apt-repository ppa:atareao/atareao
sudo apt-get update
sudo apt-get install touchpad-indicator
  • 1
    That tool does not seem to work for Ubuntu 14.04 LTS. Gnome shell tested.
    – NobbZ
    May 27, 2015 at 11:36
  • Also not working in my Unity Ubuntu 14.04.3. Dec 2, 2015 at 17:29
  • that works while typing, but not the disable touchpad when mouse is connected. Jan 26, 2016 at 15:21
  • Worked just fine for me on Ubuntu 14.04 LTS (Unity). Thank you! Jan 30, 2016 at 1:34
  • Also working fine on 15.04
    – timonsku
    Feb 12, 2016 at 13:05

You can set up udev rules to disable/enable touchpad. ArchLinux wiki has these rules for toggling a Synaptic touchpad from udev:

ACTION=="add", SUBSYSTEM=="input", KERNEL=="mouse[1-9]", ENV{DISPLAY}=":0.0", 
ENV{XAUTHORITY}="/home/USERNAME/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/usr/bin/synclient TouchpadOff=1"

ACTION=="remove", SUBSYSTEM=="input", KERNEL=="mouse[1-9]", ENV{DISPLAY}=":0.0", 
ENV{XAUTHORITY}="/home/USERNAME/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/usr/bin/synclient TouchpadOff=0"
  • I couldn't get it working. I added /etc/udev/rules.d/10-local.rules with ACTION=="add", SUBSYSTEMS=="input", KERNELS=="mouse[1-9]", RUN+="gconftool-2 --set --type boolean /desktop/gnome/peripherals/touchpad/touchpad_enabled false" ACTION=="remove", SUBSYSTEMS=="input", KERNELS=="mouse[1-9]", RUN+="gconftool-2 --set --type boolean /desktop/gnome/peripherals/touchpad/touchpad_enabled true" and then sudo service udev reload; sudo udevadm trigger; sudo service udev restart but nothing happened. Aug 27, 2011 at 7:11

I'm not sure if all the laptops use Synaptiks, but you could try to use it. In case you haven't installed, write in a terminal: $sudo apt-get install kde-config-touchpad, then $synaptiksand finally in the menu «Touchpad management» check:

  • Automatically start at logon
  • Automatically switch off touchpad, if a mouse is plugged

I hope this information has been valuable for you!


You can create a script, and execute it when you want to disable/enable touchpad.



declare -i ID
ID=`xinput list | grep -Eio 'touchpad\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}'`
declare -i STATE
STATE=`xinput list-props $ID|grep 'Device Enabled'|awk '{print $4}'`

if [ $STATE -eq 1 ]
    xinput disable $ID
    # echo "Touchpad disabled."
    # notify-send 'Touchpad' 'Disabled' -i /usr/share/icons/Adwaita/48x48/devices/input-touchpad.png
    xinput enable $ID
    # echo "Touchpad enabled."
    # notify-send 'Touchpad' 'Enabled' -i /usr/share/icons/Adwaita/48x48/devices/input-touchpad.png
  • This works like a treat!
    – aggsol
    Jul 11, 2016 at 11:28
  • Work like a charm !!! Dec 2, 2016 at 4:28

This is a more lengthy answer of similar one by realhu.

Script to toggle Touchpad on/off with screen notification

Partial credit to this post (Enable/disable touchpad)

Create toggle-touchpad script

Create a new directory /home/USER/bin and then use gedit /home/USER/bin/toggle-touchpad. NOTE: Replace USER with your user ID. Copy and paste these lines into your editor:


# NAME: toggle-touchpad
# PATH: /home/$USER/bin
# DESC: Update pulseaudio output device when HDMI TV plugged / unplugged
# CALL: called from Keyboard Shortcut `Super`+`T`
# DATE: Created Dec 23, 2016.
# NOTE: Written for AU question: http://askubuntu.com/questions/863746/keyboard-shortcut-to-disable-the-laptop-touchpad/863750?noredirect=1#comment1333958_863750

# Use device number matching touchpad, in this case 14
if [[ $(xinput list 14 | grep -Ec "disabled") -eq 1 ]]; then
    xinput enable 14
    DISPLAY=:0 notify-send --urgency=critical --icon=/usr/share/icons/gnome/256x256/status/user-available.png "Touchpad enabled"
    xinput disable 14
    DISPLAY=:0 notify-send --urgency=critical --icon=/usr/share/icons/gnome/256x256/status/user-busy.png "Touchpad disabled"

exit 0

Mark toggle-touchpad script as executable

Save the file and exit the editor. Now flag the file as executable using

chmod +x /home/USER/bin/toggle-touchpad

Assign toggle-touchpad script to keyboard shortcut

Open up System SettingsKeyboardShortcutsCustom Shortcuts+

This screen appears:


Fill in the Custom Shortcut fields like this:

  • Name = Toggle Touchpad
  • Command = /home/USER/bin/toggle-touchpad

Click Apply button to save.

The new entry appears with status Disabled. Right click on Disabled and use Super+Z (or any other unused shortcut combination). I wanted to use Super+T but that is already assigned to Nautilus Trashcan.

Modify toggle-touchpad script to different device number

The default device number is set at 14. To find out what your device number is use the following:

USER@host:~/bin$ xinput
⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Logitech Performance MX                   id=10   [slave  pointer  (2)]
⎜   ↳ Logitech K800                             id=11   [slave  pointer  (2)]
⎜   ↳ AlpsPS/2 ALPS GlidePoint                  id=14   [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)]
    ↳ Power Button                              id=8    [slave  keyboard (3)]
    ↳ Sleep Button                              id=9    [slave  keyboard (3)]
    ↳ Laptop_Integrated_Webcam_HD               id=12   [slave  keyboard (3)]
    ↳ Dell WMI hotkeys                          id=15   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=13   [slave  keyboard (3)]

You can pick any device you like, ie Touchpad = 14, Webcam = 12, etc.

Which ever device number you use, simply open your /home/USER/bin/toggle-touchpad script and replace 14 with that device number.

Modify toggle-touchpad script to use different icons

When the "Touchpad enabled" / "Touchpad disabled" notification bubble is displayed, an icon is displayed left of the text. Stock icons are used from /usr/share/icons/gnome/256x256/status/ but you can change them.

For enabling touchpad this is displayed:

user available

For disabling touchpad this is displayed:

user busy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.