Skip to content

Instantly share code, notes, and snippets.

@kittinan
Created April 3, 2016 07:11
Show Gist options
  • Select an option

  • Save kittinan/43df9e5ed3afd8f616df22dddea8a0e7 to your computer and use it in GitHub Desktop.

Select an option

Save kittinan/43df9e5ed3afd8f616df22dddea8a0e7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get the device id of the Synaptics TouchPad
id=12
# Get the current state of the Device Enabled property
# The devString will look like: "Device Enabled (132): 0"
devString=$(xinput --list-props $id | grep "Device Enabled")
# Parse the devString into an array
read -a devString_array <<< "$devString"
# Save the current state of the Device Enabled property
# from the 4th element of devString_array
devEnabled=${devString_array[3]}
# Flip the state of the Device Enabled property
if [ $devEnabled -eq 1 ]; then
devEnabled=0
else
devEnabled=1
fi
# Set the "Device Enabled" property with the new value
xinput set-prop $id "Device Enabled" $devEnabled
# Push out a desktop notification of the new value
notify-send --icon computer "Synaptics TouchPad" "Device Enabled = $devEnabled"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment