Skip to content

Hide the mouse cursor on a Raspberry Pi

The openHAB HABpanel we have in the kitchen runs on a Raspberry Pi and uses a touchscreen display. The browser starts in fullscreen mode, and shows a specific HABpanel screen for this display. That's all nice, but by default the mouse cursor is in the way. Let's get rid of it.


The Raspbian system which runs on the Pi comes with a package called "unclutter". This hides the curser after a few seconds. All I have to do is install the package, and start the app. Right?

Let's see if that can be automated. First I install the package, using Ansible:

- name: Install unclutter package
      - unclutter
    state: present

That part is easy. Starting it requires multiple steps. First I need a ".desktop" file containing additional information for the desktop manager:

[Desktop Entry]
Name=Hide Mouse
Comment=Hide the mouse after a few seconds
Exec=/usr/bin/unclutter -display :0 -idle 5 -root -noevents

This hides the mouse cursor after 5 seconds of inactivity. If someone moves the mouse, or touches the screen, the mouse cursor reappears again. The used LXDE provides a folder which will autostart elements in it, once the desktop starts. For that, you need to create a ".config/autostart" folder (not there by default) and place the .desktop file in it:

- name: Create LXDE autostart directory
    path: /home/pi/.config/autostart
    state: directory
    owner: pi
    group: pi
    mode: 0700

- name: Copy unclutter.desktop to autostart
    src: '{{ playbook_dir }}/files/unclutter.desktop'
    dest: '/home/pi/.config/autostart/unclutter.desktop'
    owner: pi
    group: pi
    mode: 0755

That's it. Next time the Pi starts, the mouse cursor disappears after a few seconds.


No Trackbacks


Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
Form options