Last active
May 31, 2024 16:53
-
-
Save jpsutton/ba3b40ae5d2e44b88bd6ce9a0f9971d6 to your computer and use it in GitHub Desktop.
Bash script to toggle the enabled status on your touchpad while running under KDE Plasma 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SERVICE="org.kde.KWin" | |
DBUS_PATH="/org/kde/KWin/InputDevice" | |
INTERFACE="org.kde.KWin.InputDevice" | |
METHOD_GET="org.freedesktop.DBus.Properties.Get" | |
METHOD_SET="org.freedesktop.DBus.Properties.Set" | |
function find_touchpad { | |
DM_INTERFACE="org.kde.KWin.InputDeviceManager" | |
DM_PROPERTY="devicesSysNames" | |
for sysname in $(qdbus "$SERVICE" "$DBUS_PATH" "$METHOD_GET" "$DM_INTERFACE" "$DM_PROPERTY"); do | |
is_touchpad=$(qdbus "$SERVICE" "${DBUS_PATH}/${sysname}" "$METHOD_GET" "$INTERFACE" touchpad) | |
if [ "$is_touchpad" == "true" ]; then | |
echo "$sysname" | |
break | |
fi | |
done | |
} | |
function toggle_touchpad { | |
DBUS_PATH="${DBUS_PATH}/$(find_touchpad)" | |
PROPERTY="enabled" | |
# Get the current status of the touchpad | |
status=$(qdbus "$SERVICE" "$DBUS_PATH" "$METHOD_GET" "$INTERFACE" "$PROPERTY") | |
# Flip the status | |
status=$([[ "$status" == "false" ]] && echo true || echo false) | |
# Set the new status | |
qdbus "$SERVICE" "$DBUS_PATH" "$METHOD_SET" "$INTERFACE" "$PROPERTY" "$status" | |
} | |
toggle_touchpad |
Hey, that's great! I'm glad it's useful to someone else.
Perfectly! It would be great to get a similar one for wireless.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this, this is a nice wayland solution to replace xinput stuff. I've incorporated it in my fusuma config to enable/disable my trackpad based on a gesture and/or timeout: https://gist.github.com/digitalsignalperson/34c1df16fdcd4b87c873aaba29d70b22