updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / acpi-eeepc-generic / acpi-eeepc-generic-toggle-touchpad.sh
blobbc5a2e11b52fcad563029143548c7c53b30f4a57
1 #!/bin/bash
2 # Copyright 2009 Nicolas Bigaouette
3 # This file is part of acpi-eeepc-generic.
4 # http://code.google.com/p/acpi-eeepc-generic/
6 # acpi-eeepc-generic is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # acpi-eeepc-generic is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with acpi-eeepc-generic. If not, see <http://www.gnu.org/licenses/>.
19 . /etc/acpi/eeepc/acpi-eeepc-generic-functions.sh
21 # Make sure we run as root
22 if [[ $EUID -ne 0 ]]; then
23 me="`dirname $0`/`basename $0`"
24 ${SUDO} "${me}"
25 exit 1
28 # 0 means off, 1 means on
29 STATE_FILE="$EEEPC_VAR/states/touchpad"
31 if [ -e "$STATE_FILE" ]; then
32 TPSAVED=$(cat $STATE_FILE)
35 enable=`synclient -l 2>&1`
36 if [ "$enable" == "Can't access shared memory area. SHMConfig disabled?" ]; then
37 eeepc_notify "$enable" stop 10000
38 eeepc_notify "Ensure xorg.conf is properly configured." stop 10000
39 exit 1
42 function touchpad_toggle() {
43 if [ -S /tmp/.X11-unix/X0 ]; then
44 TOUCHPAD_OFF=`synclient -l | grep TouchpadOff | awk '{print $3}'`
45 if [ "$TOUCHPAD_OFF" = "0" ]; then
46 echo 0 > $STATE_FILE
47 synclient TouchpadOff=1
48 if [ $? ]; then
49 [ -e /usr/bin/unclutter ] && unclutter -idle 2 -root &
50 eeepc_notify "Touchpad Disabled" mouse
51 else
52 eeepc_notify "Unable to disable touchpad; Ensure xorg.conf is properly configured." stop
54 else
55 echo 1 > $STATE_FILE
56 synclient TouchpadOff=0
57 if [ $? ]; then
58 pkill unclutter
59 eeepc_notify "Touchpad Enabled" mouse
60 else
61 eeepc_notify "Unable to enable touchpad; Ensure xorg.conf is properly configured." stop
67 function touchpad_restore() {
68 if [ "$TPSAVED" = "0" ]; then
69 synclient TouchpadOff=1
70 else
71 synclient TouchpadOff=0
75 case $1 in
76 restore)
77 touchpad_restore
80 touchpad_toggle
82 esac