3

Laptop support in Ubuntu is rather disappointing. It's like Ubuntu and Kubuntu are two different worlds. Is there a script to disable touchpad while running full screen applications? I tried to write it myself but no success at the end. My guess is to combine xdotool with xinput.

Any different approach as well as suggestions of similar scripts are much welcomed.

And no, I'm not interested in setting shortcuts! Script should automatically disable touchpad when full screen application is active.

1 Answer 1

3

After some research I have managed to write a functional script. It will automatically disable touchpad while full screen application is active and mouse is connected. So it is suitable for full screen gameing.

What you need to do is copy the text into Gedit and save file as e. g. : .auto_disable_touchpad.sh (Since it got . in front of name it is hidden file, but you can name it whatever you want.). Then: right click/properties/permissions/allow executing file as program. To add it to startup open Startup applications and add the folowing command your/script/folder/.auto_disable_touchpad.sh .

#!/bin/bash

SC1=$(xdpyinfo | grep dimensions)
SC2="${SC1#*dimensions: }"
SC3="${SC2%% pixels*}"

while :
do
    TP=$(xinput list --name-only | grep -i Touchpad)
    TPS1=$(xinput --list-props "$TP" | grep -i "device enabled")
    TPS2="${TPS1#*:}"

    MO=$(xinput list --name-only | grep -i mouse)

if [ ! -z "$MO" ];then
    WN1=$(xdotool getactivewindow getwindowgeometry)
    WN2="${WN1#*Geometry: }"

    WNN=$(xdotool getactivewindow getwindowname)

    case ${WNN,,} in
        desktop|*vlc*|*smplayer*|*mozilla*firefox*) WNN=1;;
        *) WNN=0;;
    esac

        if [ $SC3 == $WN2 ] && [ $WNN == 0 ]; then
                xinput -disable "$TP"
        elif [ $TPS2 == 0 ]; then
                xinput -enable "$TP"
        fi
else sleep 2
fi  
sleep 1
done

If you are watching films or full screen youtube video it will also disable touchpad while the mouse is present. So, you might want to add exceptions. I have already added some for: desktop, firefox (plugin-container), VLC and SMPlayer.

When you want touchpad active while full screen application running then add name of the application to this line:

desktop|*vlc*|*smplayer*|*mozilla*firefox*) WNN=1;;

E.G. to add Ubuntu's default video player Videos to exceptions add |*videos* before
) WNN=1;; so it will look like this:

desktop|*vlc*|*smplayer*|*mozilla*firefox*|*videos*) WNN=1;;

Note that name of the application is case sensitive so you must use lowercases only (smplayer but not SMPlayer).

1
  • Additionally, if you want to automatically disable touchpad while typing insert the following line before while command: syndaemon -i 1.5 -K -d. The delay is 1.5 seconds.
    – VRR
    May 19, 2015 at 14:41

You must log in to answer this question.

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