From 649757fde2d8874e9544be2ac1deefde27215b18 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Mon, 7 Mar 2016 12:16:48 +0100 Subject: Add toggle option to touchpad control --- touchpad.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/touchpad.sh b/touchpad.sh index 9bb6f6f..c05462b 100755 --- a/touchpad.sh +++ b/touchpad.sh @@ -1,5 +1,7 @@ #!/usr/bin/env sh +STATE_FILE="/tmp/touchpad-disabled" + case $1 in "enable") ACTION="enable" @@ -7,6 +9,13 @@ case $1 in "disable") ACTION="disable" ;; + "toggle") + if [ -e "$STATE_FILE" ]; then + ACTION="enable" + else + ACTION="disable" + fi + ;; *) echo "Invalid action." echo "Usage: $0 enable|disable" @@ -14,6 +23,12 @@ case $1 in ;; esac +if [ "$ACTION" = "enable" ]; then + rm -f "$STATE_FILE" +else + touch "$STATE_FILE" +fi + DEVICES=$(xinput list --name-only | grep -i touchpad) if [ -z "$DEVICES" ]; then -- cgit v1.2.3