Use a shortcut to enable or disable the touchpad in Linux Mint

Touchpad is annoying

Is there a problem with the touchpad reacting while entering characters and causing incorrect typing? I have In most cases, Windows has a shortcut to enable / disable the touchpad, but Linux Mint doesn't seem to have it. It's annoying to write sentences and source code, so I wrote a shell for shortcuts and registered it as a shortcut. If you have any questions or improvements, please feel free to comment.

environment

OS LinuxMint 19.3 Cinamon PC ASUS E203

flow

① Prepare a shell ② Register to shortcut

① Prepare a shell

You can use an appropriate file name, so prepare an sh format file and copy and paste the following code into it. However, for the device name, obtain the device name of the touchpad by the method described later and replace it.

toggleTotchpad.sh


#!/bin/bash

#Enter the device name of the touchpad.
TOUCHPAD="(Device name)"

#If the value below is 1, the touchpad is valid. If it is 0, it is invalid. Put 1 at first
isTouchpadEnable=1

#Get the current state of the touchpad
touchpadStateStr=$(xinput list-props "$TOUCHPAD" | grep "Device Enabled")
touchpadStateStrLength=$((${#touchpadStateStr}-1))
touchpadState=${touchpadStateStr:$touchpadStateStrLength:1}

#The current state of the touchpad is valid (=1) is invalid (1)=Substitute 0 to make it 0)
if [ "$touchpadState" = "1" ];then 
    isTouchpadEnable=0
fi

#Enable / disable the touchpad
xinput set-prop "$TOUCHPAD" --type=int --format=8 "Device Enabled" $isTouchpadEnable

I did a lot of research, but the one using xinput was the easiest to understand, so I used it. It's a very powerful code, so I'd be happy if you could let me know if there are any corrections.

Get the device name of the touchpad

You can get the device name of the touchpad in the above shell with the following command. Even if you say acquisition, only a list of connected input devices will appear, so look for the one that ends with Touchpad.

xinput --list

The link below will be helpful. http://www7b.biglobe.ne.jp/~nishigo/linux/Disable_of_touchpad2.html

② Register to shortcut

Open the keyboard shortcut settings from the menu bar. Screenshot at 2020-05-06 17-28-13.png

Click Add and enter a name and command. The name can be anything you know. Enter the command as shown below.

bash (Absolute path of sh made in ①) 

Screenshot at 2020-05-06 17-28-39.png

I think that the registered shortcut is invalid, so click on it and register your favorite shortcut, and you're done. Screenshot at 2020-05-06 17-28-50.png I chose Windows Key + T. Screenshot at 2020-05-06 17-29-02.png This is a reference link. https://www.shangtian.tokyo/entry/2019/01/05/104136

Recommended Posts

Use a shortcut to enable or disable the touchpad in Linux Mint
How to use the __call__ method in a Python class
[Introduction to Python] How to use the in operator in a for statement?
[Linux] How to use the echo command
How to use the Linux grep command
[Linux] Command to get a list of commands executed in the past
How to use the C library in Python
Use the latest pip in a virtualenv environment
Use libsixel to output Sixel in Python and output a Matplotlib graph to the terminal.
Set a fixed IP in the Linux environment
How to create a shortcut command for LINUX
Use pygogo to get the log in json.
How to use any or all to check if it is in a dictionary (Hash)
A memorandum on how to use keras.preprocessing.image in Keras
Linux user addition, how to use the useradd command
How to use the exists clause in Django's queryset
Convenient to use matplotlib subplots in a for statement
How to use the model learned in Lobe in Python
(Remember quickly) How to use the LINUX command line
I want to use the R dataset in python
[Linux] How to put your IP in a variable
Completely disable mouse acceleration in the Linux desktop environment
[C / C ++] Pass the value calculated in C / C ++ to a python function to execute the process, and use that value in C / C ++.
Define a task to set the fabric env in YAML
How to use linux commands in Visual Studio Code terminal
Change the standard output destination to a file in Python
Use MeCab to translate sloppy sentences in a "slow" way.
Put the lists together in pandas to make a DataFrame
How to generate a query using the IN operator in Django
How to get the last (last) value in a list in Python
To write a test in Go, first design the interface
Notes on how to use marshmallow in the schema library
Assign a link-local address to Linux and use DNS-SD / SSDP
Put the process to sleep for a certain period of time (seconds) or more in Python
[Python] How to use the for statement. A method of extracting by specifying a range or conditions.
A super introduction to Linux
How to use the generator
Linux a summary shortcut key
How to use the decorator
Output the key list included in S3 Bucket to a file
How to display a specified column of files in Linux (awk)
[sh] How to store the command execution result in a variable
How to determine the existence of a selenium element in Python
Automatically acquire the operation log in the terminal when logging in to Linux
I want to use shortcut translation like DeepL app on Linux
How to get all the possible values in a regular expression
Build a Selenium environment on Amazon Linux 2 in the shortest time
How to make a string into an array or an array into a string in Python
How to check the memory size of a variable in Python
[Selenium] Use a while statement to repeatedly move to the "next page"
Use PyCaret to predict the price of pre-owned apartments in Tokyo!
How to use the asterisk (*) in Python. Maybe this is all? ..
How to check the memory size of a dictionary in Python
[Linux] How to disable the automatic update of the /etc/resolv.conf file (AmazonLinux2)
How to output the output result of the Linux man command to a file
How to get the vertex coordinates of a feature in ArcPy
What to do if you can't use the trash in Lubuntu 18.04.
Create a function to get the contents of the database in Go
I made a command to display a colorful calendar in the terminal
Attempt to extend a function in the library (add copy function to pathlib)
How to use the render function defined in .mako (.html) directly in mako