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.
8 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.
2 Likes