Giter Club home page Giter Club logo

disable_touchpad_on_typing_linux's Introduction

disable_touchpad_on_typing_linux

Disables the touchpad and touchpad buttons during typing.

Aren't there already working solutions for that?

Not in my case. The Gnome setting was not even available no me in the GUI. Changes in some config files didn't work.
There is an application called "touchpad-indicator", which was triggered with a huge delay and also didn't disable the touchpad buttons.
This was causing me lots of headaches. BUT NO MORE!

This code is minimal, optimized and should work on any Xorg or Wayland supported Linux distribution.

Building

Xorg

gcc xorg_touchpad.c -o disable_touchpad_while_typing

With optimization:
gcc xorg_touchpad.c -O3 -o disable_touchpad_while_typing

Wayland

gcc wayland_touchpad.c $(pkg-config --libs --cflags glib-2.0) -o disable_touchpad_while_typing

You need the package libglib2.0-dev. Install it with sudo apt-get install libglib2.0-dev

Usage

By using the standard parameters and autodetection of your keyboard and touchpad, use
./disable_touchpad_while_typing

There are 3 additional flags:

  • -e: ID of the keystroke event file which can be found in /dev/input/. By not providing this argument, the program tries to find the ID automatically. However, if it doesn't succeed, then you have to provide it by yourself with this flag.
    E.g. -e 12
  • -h: Helper message
  • -t: Timeout: Timeout in milliseconds between the last keystroke and re-enabling the touchpad. Default value is 1000. E.g. -t 1000

Start application after booting

Place the block-touchpad.desktop file into /home/<user>/.config/autostart and adapt the directory in this file to the one pointing to the binary file. This directory only exists if you're using Gnome as your desktop environment.

Memory Leaks

Valgrind shows no memory leaks:

valgrind -s --leak-check=full --show-leak-kinds=all ./disable_touchpad_while_typing_xorg

==17595== HEAP SUMMARY:
==17595==     in use at exit: 0 bytes in 0 blocks
==17595==   total heap usage: 16 allocs, 16 frees, 15,315 bytes allocated
==17595== 
==17595== All heap blocks were freed -- no leaks are possible
==17595== 
==17595== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

------------------------------------------------
valgrind -s --leak-check=full --show-leak-kinds=all ./disable_touchpad_while_typing_wayland

==8297== HEAP SUMMARY:
==8297==     in use at exit: 0 bytes in 0 blocks
==8297==   total heap usage: 10 allocs, 10 frees, 34,260 bytes allocated
==8297== 
==8297== All heap blocks were freed -- no leaks are possible
==8297== 
==8297== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

disable_touchpad_on_typing_linux's People

Contributors

masskro0 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.