You are not logged in.
Save as file, exec chmod a+x <name of file> then, and put it in autostart
#!/bin/bash
# Use lsusb to find the id, then place them here
MOUSE_ID="045e:00cb"
while true; do
TOUCHPAD_STATE=`gsettings get org.gnome.desktop.peripherals.touchpad send-events`
MOUSE_PRESENT=`lsusb | grep "$MOUSE_ID"`
if [ "$MOUSE_PRESENT" ] && [ "$TOUCHPAD_STATE" = "'enabled'" ]; then
echo "Disable touchpad."
gsettings set org.gnome.desktop.peripherals.touchpad send-events disabled
elif [ -z "$MOUSE_PRESENT" ] && [ "$TOUCHPAD_STATE" = "'disabled'" ]; then
echo "Enable touchpad."
gsettings set org.gnome.desktop.peripherals.touchpad send-events enabled
fi
sleep 1
done
exit 0
Last edited by KoboldDresden (2018-02-02 19:40:22)
Offline
Is there a reason for not simply using an udev rule to run the gsettings command when you plug/unplug the mouse?
Running an infinite looping bash script is extremely ugly solution for this imho.
Offline
Arch now uses libinput for touchpad too, so we can't use synclient to switch the touchpad on/off. And gsettings must run in user mode. That is, why I use a bash script.
Offline
I would be unpleasantly surprised if GNOME didn't have some sort of setting for this. Have you thought of just unloading the driver module for your touchscreen? (in an udev rule)
Offline
gsettings get org.gnome.desktop.peripherals.touchpad send-events
so something like
#!/bin/bash
key="org.gnome.desktop.peripherals.touchpad"
val="send-events" ;curr="$key $val"
if [ "$(gsettings get $curr)" == "'enabled'" ]
then
gsettings set $key $val disabled
else
gsettings set $key $val enabled
fi
should be good enough.
EDIT: Duh, I've just realized you need a script to do it on mouse being plugged in. Still, might help with that too, gsettings is the way.
Last edited by Xabre (2018-02-02 23:17:09)
Offline
And gsettings must run in user mode.
I believe you could use 'su' in the user script to run gsettings as user, similarily to this.
However Xabre hinted an even better solution for your case.
EDIT: Xabre edited his post.
I think you could just use 'disabled-on-external-mouse' value for 'org.gnome.desktop.peripherals.touchpad send-events', and not use any scripts.
Last edited by ooo (2018-02-02 23:22:48)
Offline
Thank you so much, your solution with 'disabled-on-external-mouse' is the right way.
Offline