4

Is there a way to toggle touchpad on/off with a command/keyboard shortcut? I tried using this:

if $(gsettings get org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled); then gsettings set org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled false; else gsettings set org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled true; fi

But it didn't work at all.

PRATAP
  • 21,989
  • 8
  • 59
  • 121
personanongrata
  • 237
  • 2
  • 9
  • 1
    does your keyboard have toggle button/ key? – PRATAP Aug 13 '19 at 14:28
  • Unfortunately no, I want to bind te command to the shortcut. Most likely ctrl+shift+l – personanongrata Aug 13 '19 at 15:10
  • From what i see this question has already been answered, check [here](https://askubuntu.com/questions/67718/how-do-i-disable-a-touchpad-using-the-command-line) – APEric Aug 13 '19 at 15:27
  • 2
    Possible duplicate of [How do I disable a touchpad using the command line?](https://askubuntu.com/questions/67718/how-do-i-disable-a-touchpad-using-the-command-line) –  Aug 13 '19 at 15:46
  • I tried those, the problem is I have thinkpad T440p with touchpad combined with trackpoint buttons, if I disable trackpad buttons will be also disabled. If I turn off touchpad in gnome control center it works though. – personanongrata Aug 13 '19 at 16:10
  • 1
    https://askubuntu.com/q/1147496/739431 check this one/ – PRATAP Aug 13 '19 at 16:19

3 Answers3

4

Work Around:

with the help of this post https://askubuntu.com/a/1140700/739431

install the xdotool package if not yet installed, sudo apt install xdotool

  1. run xmodmap -pke | grep TouchpadToggle

example

pratap@i7:~$ xmodmap -pke | grep TouchpadToggle
keycode  71 = XF86TouchpadToggle NoSymbol XF86TouchpadToggle NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol XF86TouchpadToggle
keycode 199 = XF86TouchpadToggle NoSymbol XF86TouchpadToggle NoSymbol XF86TouchpadToggle
pratap@i7:~$ 
  1. run in terminal xdotool key XF86TouchpadToggle to check if the touchpad toggling is working?

enter image description here

  1. Create your own shortcut Shift+Ctrl+I with custom command xdotool sleep 1 key XF86TouchpadToggle sleep value 0.5 may also work.. try it with your comfort..

enter image description here

PRATAP
  • 21,989
  • 8
  • 59
  • 121
0

Yes. On my laptop I can toggle on/off the touch-pad using the key F5. try it on your laptop if it's not works then try pressing Fn + F5 (F5 or the key which your laptop use). look at the icons on your keyboard.

  • The OP's machine has no such shortcuts according to the comment above. –  Aug 13 '19 at 15:48
0
synclient TouchpadOff=$(synclient -l | grep -q 'TouchpadOff.*1'; echo $?)

and

tp=$(synclient -l | grep TouchpadOff | awk '{ print $3 }') && tp=$((tp==0)) && synclient TouchpadOff=$tp

both work for me in Xfce to toggle touchpad onn/off.

I use them with a shortcut associated with a script like

#!/bin/bash

synclient TouchpadOff=$(synclient -l | grep -q 'TouchpadOff.*1'; echo $?)

source - here

cipricus
  • 3,102
  • 1
  • 25
  • 70