#Copyright 2016 Grady Moran #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. #You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 #Unless required by applicable law or agreed to in writing, software #distributed under the License is distributed on an "AS IS" BASIS, #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #See the License for the specific language governing permissions and #limitations under the License. # !/bin/bash trackpadName="Elantech Touchpad" #Modify this to whatever the name of the trackpad is. Can be read from output of the xinput command. mouseIdNumber=$(xinput | grep "$trackpadName" | sed 's/ETPS\/2//g' | sed 's/([0-9]*)//g'| sed 's/[^0-9]//g') #logic of this is basically output xinput, get line with Elantech Touchpad in it, remove this string at the beginning that contains a number, remove another number later that happens to be in parenthesis, then remove anything that is NOT a number, thus leaving only the part of the string that is the mouse's id num mouseState=$(xinput --list-props $mouseIdNumber | grep "Device Enabled" | sed 's/([0-9]*)//g' | sed 's/[^0-9]//g') #similar regex logic to above. equal to 1 when device enabled, 0 when not xinput set-prop $mouseIdNumber "Device Enabled" $(($mouseState ^ 1)) #Quickest way I thought to get state mouse is NOT in, $mouseState ^ 1 returns opposite (0->1, 1->0)