Skip to content

Instantly share code, notes, and snippets.

@elegos
Last active October 24, 2020 01:33
Show Gist options
  • Save elegos/6d4504032ad1a91dfc66c3ae414db3df to your computer and use it in GitHub Desktop.
Save elegos/6d4504032ad1a91dfc66c3ae414db3df to your computer and use it in GitHub Desktop.
Slimbook KDE 2020 touchpad enable/disable on Fedora (KDE Plasma + xbindkeys)
#!/usr/bin/env bash
# Ensure xbindkeys is installed
whichXbindkeys=$(which xbindkeys 2>/dev/null)
if [ "${whichXbindkeys}" == "" ]; then
sudo dnf install xbindkeys
fi
# Create the xbindkeys auto-start symlink
if ! [ -f ~/.config/autostart-scripts/xbindkeys ]; then
ln -s `which xbindkeys` ~/.config/autostart-scripts/xbindkeys
fi
# Install the switch script
mkdir -p ~/.local/bin
cat <<'EOF' >~/.local/bin/switch-touchpad-state
#!/usr/bin/env bash
id=$(xinput list|grep -i "touchpad"|grep -Poe "(?<=id=)(\d+)")
if [ "${id}" == "" ]; then
exit 0
fi
currentState=$(xinput list-props ${id}|grep "Device Enabled"|grep -Poe "\d+$")
if [ ${currentState} = 1 ]; then
xinput disable $id
else
xinput enable $id
fi
EOF
chmod +x ~/.local/bin/switch-touchpad-state
# Configure xbindkeys
if ! [ -f ~/.xbindkeysrc ] || [ "$(grep switch-touchpad-state ~/.xbindkeysrc)" == "" ]; then
echo \"${HOME}/.local/bin/switch-touchpad-state\" >> ~/.xbindkeysrc
echo " m:0x44 + c:93" >> ~/.xbindkeysrc
echo " Control+Mod4 + NoSymbol" >> ~/.xbindkeysrc
echo "" >> ~/.xbindkeysrc
fi
# (re)start xbindkeys
killall xbindkeys 2>/dev/null
xbindkeys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment