Manual hide the mouse cursor in full-screen

When I watch a movie in full-screen mode, I want to hide the mouse cursor. But by default it is visible with Qubes-OS. With the below procedure you will hide the mouse cursor with the Alt+F12 keyboard shortcut with the help of the unclutter command.

In dom0:

  • install the unclutter package : sudo qubes-dom0-update unclutter
  • create the toggle-unclutter.sh shell script :
mkdir $HOME/bin
cat << 'EOF' | tee $HOME/bin/toggle-unclutter.sh
#! /bin/sh
if pgrep unclutter &> /dev/null 2>&1
then
  killall unclutter
else
  unclutter -idle 1 &
fi
EOF
chmod +x $HOME/bin/toggle-unclutter.sh
  • add a keyboard shortcut to launch this script for hide/show the mouse cursor
  • for xfce : System Tools / Keyboard, Application Shortcuts, Add : browse to the above script → choose a shortcut (for example Alt-F12)

The first Alt-F12 hides the cursor, the second Alt-F12 shows the cursor.

Credits : vecna13 from the 2676 issue. In this issue you will find other solutions and some security concerns.

The shortcut added in the ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml file.

9 Likes

Upgraded script to automatically hide the cursor if the active window is in fullscreen and unhide it if the window is not in fullscreen.
You can toggle this to enable/disable by running the script with shortcut.

#!/bin/bash
shopt -s lastpipe
pgrep -f '^/bin/bash.*toggle-unclutter.sh$' 2>/dev/null | grep -v ^$$\$ | PIDS=$(cat)
if [ -n "$PIDS" ]
then
    kill $PIDS &>/dev/null
    killall -q unclutter
else
    while true
    do
        if xprop -id $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW 2>/dev/null | cut -f 2) _NET_WM_STATE 2>/dev/null | grep -q _NET_WM_STATE_FULLSCREEN
        then
            if ! pgrep -x unclutter &>/dev/null
            then
                unclutter --timeout 1 --fork
            fi
        else
            killall -q unclutter
        fi
        sleep 1
    done
fi

You can upgrade the script further and enable unclutter only for specific windows for which you’ve pressed the shortcut.
Get the window ID in the script and add/remove it in some temp file e.g. /run/unclutter-windows.
Check in the script if the windows in the file exist and remove from the file the windows that are closed.
Then check in infinite loop in the script whatever the active window is listed in this file and start unclutter if it is.

3 Likes

I get this error message in a pop up window:

Failed to launch shortcut “ALT F12”
Failed to execute child process “usr/bin/toggle-unclutter.sh” (Permission denied)

thx if you help :slight_smile:

I put the cursor in the bottom right corner, it’s good enough for me. Did you try?

I know it’s different from your script and less effective, but I wanted to share this “trick” as it may be useful for some readers, and requires no implementation.

3 Likes

In my case, this is not the right solution.

Here is my problem:

I have a Windows 11 HVM that I put in fullscreen mode for more comfort. However, my cursor (dom0) and the cursor from Windows are overlapping with a little latency. It’s not a big deal, but it is a bit annoying.

I prefer simple solution with no implementation too :wink: , but in this case, I haven’t found one.
This script seems to be the “simplest” solution if i can make it work…

Btw I haven’t tried the second script because I like the fact that I can choose to display the cursor or not

1 Like

EDIT: After making the .sh executable, which is better for sure, the shortcut starts the .sh but… nothing happens.

I don’t have the error anymore though

Step 1 : package presence

Is the unclutter package installed ? The dnf list --installed show you the installed packages :

[user@dom0 ~]$ dnf list --installed | grep unclutter
unclutter-xfixes.x86_64                           1.6-2.fc37                        @qubes-dom0-cached

Step 2 : unclutter

First try only the unclutter command without a shortcut, in a dom0 terminal, like this :

unclutter -idle 1

If the command hide the cursor after 1 second (-idle 1), so the unclutter command works. Launch killall unclutter to show again to show permanently again the cursor.

Step 3 : toggle-unclutter.sh

Note that I created the script in my homedir $HOME/bin, not in /usr/bin/.

Try the script in a dom0 terminal. first launch should hide the cursor, second launch shows it again.

Step 4 : keyboard shortcut

Try to configure the Alt-F12 shortcut to another command, for example xtem. Is it works ? Then map it to the script.

@oliviaw is this help you ? Which step don’t work for you ? An error message ?

2 Likes

Thanks a lot for your explanation!
Everything works fine now, I just didn’t paste the script in the correct directory!

Do I have any ideas of modifications to make to the script so that the cursor disappears all the time, even if I move my mouse?
I already have one in my Windows 11 HVM.

Thanks a lot for your very detailed explanation !

mkdir $HOME/bin
cat << 'EOF' | tee $HOME/bin/toggle-unclutter.sh
#! /bin/sh
if pgrep unclutter &> /dev/null 2>&1
then
  killall unclutter
else
  unclutter -idle 0 -root &
fi
EOF
chmod +x $HOME/bin/toggle-unclutter.sh

this is what i think is correct

EDIT: when i do that the cursor came back when i move my mouse

Glad that my explanations help you.

See all the available unclutter arguments in its man page (man unclutter) : timeout/idle, jitter, ignore-*. But the -idle 0 in your above script, may be already matches your needs…