Home Linux Tips & Tricks Auto Hide Mouse Pointer Using Unclutter After A Certain time

Auto Hide Mouse Pointer Using Unclutter After A Certain time

By sk
Published: Last Updated on 17.3K views

The kiosk devices runs a single application 24/7 without any user interaction. They don't even need keyboard or mouse most of the time. One common problem in kiosk devices is the mouse pointer. When a web app is running in Kiosk mode, the mouse pointer may distract the users or block the area the user looking at. Even if you remove the mouse, you will still see the mouse cursor. Luckily, we can auto hide mouse pointer using Unclutter application after a certain period of time when there is no mouse movement in Linux desktops.

What is Unclutter?

Unclutter is command line application that permanently runs in the background of an X11 session.

Unclutter monitors the mouse pointer position every few seconds. When it finds the mouse is not moved or no buttons on the mouse are pressed or the cursor is not in the root window, it hides the idle cursor image and prevents the cursor from getting in the way.

It is very useful in situations (E.g. tiling window managers) where you don't use mouse often. To bring back the mouse pointer, simply move the mouse or press any mouse button.

How Unclutter works

Technically speaking, the unclutter app hides the mouse pointer by creating a small sub-window as a child of the window the cursor is in. The new window installs a cursor of size 1x1 but a mask of all 0, i.e. an invisible cursor. Once created, the program waits for the pointer to leave the window and then destroys it, restoring the original situation. Button events are passed transparently through to the parent window. They will usually cause the cursor to reappear because an active grab will be made by the program while the button is down, so the pointer will apparently leave the window, even though its x, y position doesn't change.

Install Unclutter in Linux

Unclutter application is available in the default repositories of many Linux and Unix operating systems.

To install Unclutter in Arch Linux and its variants like Manjaro Linux, run:

$ sudo pacman -S unclutter

On Debian, Ubuntu, Linux Mint:

$ sudo apt install unclutter

On openSUSE:

$ sudo zypper install unclutter

Install unclutter-xfixes

Unclutter is very old and it has not been updated for a long time. If you don't want to use it, you can try its fork Unclutter-xfixes.

Unclutter-xfixes is the rewrite version of the original Unclutter utility. Unlike its predecessor, it doesn't use fake windows or pointer grabbing and hence causes less problems with window managers and/or applications.

To install unclutter-xfixes on Arch Linux and Manjaro Linux, simply run:

$ sudo pacman -S unclutter

On Fedora, you can install unclutter-xfixes via copr repository:

$ sudo dnf copr enable nbeernink/unclutter-xfixes
$ sudo dnf install unclutter-xfixes

unclutter-xfixes is also available in the AUR, so you can install it using any AUR helper programs like Yay.

$ yay -S unclutter-xfixes-git

On FreeBSD:

# pkg install unclutter-xfixes

On other Linux distributions, you can compile and install it from source. Make sure you have installed the development tools in your Linux box.

To install Unclutterpxfixes from source, run the following commands one by one:

$ git clone https://github.com/Airblader/unclutter-xfixes
$ cd unclutter-xfixes
$ make
$ sudo make install

Auto Hide Mouse Pointer Using Unclutter

To auto hide the mouse pointer or cursor after a specific time interval, for example 10 seconds, run:

$ unclutter -idle 10

Or, you can run it in the background like below:

$ unclutter -idle 10 &

If the mouse cursor has not moved for a given time i.e. 10 seconds, the unclutter app will auto hide the cursor from the screen. If you don't specify the timeout value, it will auto hide the cursor after 5 seconds by default.

To bring it back, simply move the mouse or press any mouse buttons.

Autostart Unclutter on system reboot

Instead of manually running the Unclutter on every reboot, just add the above command to your startup.

For example, I added the following line in my ~/.bashrc file:

unclutter &

For more details, refer the man pages.

$ man unclutter


Featured image by Liviu C. on Unsplash.

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More