11

I have a kiosk application running on Ubuntu Server 14.04.3 with Google Chrome and X display (xorg and xsession).

Currently I have some script to hide the mouse after 2 seconds of being idle and when the user attempts to move the mouse it appears. I simply leverage the cursor:none on an injected invisible overlay and remove that overlay when needed.

It seems like when I boot up the kiosk the code executes as expected and I can see the overlay inserted but since the mouse was just "loaded" it won't disappear until I make even a minor movement with it. It seems like the browser doesn't detect the mouse until I make even a minor movement with it which results in the mouse being shown at the middle of the screen. Since the problem isn't related to my code as it seems to execute just fine.

What I want to do is that if the mouse hasn't been moved for 2 seconds, hide it. When the user attempts to move the mouse, show it once again. The solution has to work immediately after booting the X display, so when I boot the X display the mouse is at the middle of the screen and even if I don't touch it at boot it will disappear after 2 seconds of being idle. I guess I need to achieve this by tinkering with the X display instead of relying on my code since the mouse isn't detected when the kiosk is freshly booted.

Is it possible doing such a thing with X display?

1

2 Answers 2

17
+50

There is an application called unclutter that will do it. Install it by typing in the following at a terminal window:

sudo apt-get install unclutter

after it is installed, you can change the timeout to 2 seconds in the following file:

/etc/default/unclutter

and change the following line:

EXTRA_OPTS="-idle 1 -root"

to

EXTRA_OPTS="-idle 2 -root"

this also auto-starts when the system boots up.

To have it start now without the system restarting, type in the following:

nohup unclutter -idle 2 &

EDIT:

If it is not found for install, edit your /etc/apt/sources.list file and make sure that the following lines are not commented # out:

deb http://us.archive.ubuntu.com/ubuntu/ trusty universe
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty universe
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe

If they are commented out, remove the # on the front of the line, then run sudo apt-get update to update the repositories, then rerun the sudo apt-get install unclutter.

If I run the following commands, we can see that the unclutter application comes from the trusty universe repositories.

:~$ apt-cache showpkg unclutter
Package: unclutter
Versions: 
8-19 (/var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_trusty_universe_binary-amd64_Packages) (/var/lib/dpkg/status)
 Description Language: 
                 File: /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_trusty_universe_binary-amd64_Packages
                  MD5: f0e9ff67c42a9d3dc35bb595d2f84a7b
 Description Language: en
                 File: /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_trusty_universe_i18n_Translation-en
                  MD5: f0e9ff67c42a9d3dc35bb595d2f84a7b

:~$ dpkg -s unclutter
Package: unclutter
Status: install ok installed
Priority: optional
Section: x11
Installed-Size: 76
Maintainer: Ubuntu Developers <[email protected]>
Architecture: amd64
Version: 8-19
Depends: debconf (>= 0.5) | debconf-2.0, libc6 (>= 2.3.4), libx11-6
Conffiles:
 /etc/X11/Xsession.d/90unclutter 9b47a483264cfc6a155fbd65cd8a3e6e
Description: hides the mouse cursor in X after a period of inactivity
 unclutter hides your X mouse cursor when you don't need it, to prevent it
 from getting in the way. You have only to move the mouse to restore the
 mouse cursor.
Original-Maintainer: Axel Beckert <[email protected]>
Homepage: ftp://ftp.x.org/contrib/utilities/

Hope this helps!

10
  • I will check it out! I can't believe such a simple solution was right under my nose :) Btw, when you say "create a startup" you mean create a file within the init.d folder?
    – kfirba
    Commented Oct 12, 2015 at 15:33
  • @kfirba Updated for autostart abilities.
    – Terrance
    Commented Oct 12, 2015 at 15:41
  • thanks for editing that! I will get back to you shortly with the results :)
    – kfirba
    Commented Oct 12, 2015 at 16:09
  • @kfirba Glad I could be of help for you! =)
    – Terrance
    Commented Oct 12, 2015 at 16:18
  • I can't install unclutter for some reason... I type sudo apt-get install unclutter and it says that there is no unclutter package. Any ideas how I can fix this?
    – kfirba
    Commented Oct 14, 2015 at 15:48
0

I'm using the unclutter-xfixes package on X11 and it seems to work better. On the standard unclutter package, there were some annoying quirks like scrolling was disabled until the cursor would reappear.

According to the description:

Description-en: hide the X mouse cursor after a period of inactivity, using XFixes unclutter-xfixes is a rewrite of the popular tool unclutter, but using the x11-xfixes extension. It has fewer bugs when used with modern applications and window managers.

The following command example will start it up and run it in the background with a timeout of 2 seconds while ignoring scrolling:

unclutter --timeout 2 --ignore-scrolling & disown

You can use that command as a script at startup but it will not start up automatically on its own.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .