mirror of
https://github.com/pentoo/pentoo-overlay
synced 2026-05-09 04:51:27 +02:00
x11-misc/toggle-touchpad: toggles TP on/off
This commit is contained in:
parent
d7bedbdee6
commit
9b6714b670
4 changed files with 109 additions and 0 deletions
3
x11-misc/toggle-touchpad/Manifest
Normal file
3
x11-misc/toggle-touchpad/Manifest
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
AUX toggle-touchpad 1720 SHA256 d0beaa9d7d5b3e961258edf0f5a0a6fa5d6766b6bdff4a0d3c6f8c16af247b0f SHA512 0b8e9545b03852de2ec4db9a531e3e55a82783cf043d9cbbc2a51ee9d037c159eeb40ec7ee434b4342f9884924f5757e931650af30603dff90cd932d13a4044e WHIRLPOOL 7971d87795a5d7bb06a501e6b7d43589d03b0cc36f14a3bb563af18a0288fad08378f446e982d9eea08fce7a7598cea47b112a6510f1c0973ef89ca8633693ed
|
||||
EBUILD toggle-touchpad-0.1.ebuild 562 SHA256 dc77074c8b8dfa2aa72311daef2c45abf87b3ea786cbb2915402d92ea710a562 SHA512 659099647557d69a450901e6df1e2471a968fa06b3692e4fe5b30a047b4679f4d794d515eb0a89a5d44c150b26ee48a1576691b035f17eaa9251414a307ebef1 WHIRLPOOL f5c150c82737a71b48bd5e66ece33df428b1042d9fd8024cc4b0c5a36686ccba28f61465ae9e9ac93dac7bd39de9edb24c032b44c71ef51a21d5930d095cb7a7
|
||||
MISC metadata.xml 253 SHA256 470f53045b3e70749d1eceeb55eaeae92ee8c360b2c8ac63c7b9ad406b7a06e9 SHA512 d9413157e1cc5114be563c873fd19e89cbc8905dd688bf50211b0fde87d9bf17715a74331aa0103371c5ba32a82282ea8bf71a81a884b8dada4c7d9accb7b14a WHIRLPOOL af125975da69bd187d3148f20a38762e1d6770aecf84ec4715f98aecfe208c899fde103d038e1f9cae679b92066edd94ae3b44038146b25cbcddbdf0aa1dbe21
|
||||
70
x11-misc/toggle-touchpad/files/toggle-touchpad
Executable file
70
x11-misc/toggle-touchpad/files/toggle-touchpad
Executable file
|
|
@ -0,0 +1,70 @@
|
|||
#!/bin/bash
|
||||
# Author: Stefan Kuhn <woudan@pentoo.ch>
|
||||
#
|
||||
# toggles touchpads on/off
|
||||
# Supported are both Synaptics and Elantech touchpads
|
||||
|
||||
# error handling
|
||||
exiterror() {
|
||||
if [ "$1" == "" ]; then
|
||||
echo "Error: Something went wrong!"
|
||||
else
|
||||
echo "$1"
|
||||
fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
# xinput: extract the device id for the supplied touch device name
|
||||
xi_getTouchDeviceId() {
|
||||
xinput list | sed -nr "s|.*$1.*id=([0-9]+).*|\1|p"
|
||||
}
|
||||
|
||||
# xinput: toggle touchpad on/off
|
||||
xi_toggletouchpad() {
|
||||
# Get the xinput device number and enabling property for the touchpad
|
||||
local xinputnum=$(getTouchDeviceId "SynPS/2 Synaptics TouchPad")
|
||||
local enableprop="Synaptics Off"
|
||||
if [ -z "$xinputnum" ]; then
|
||||
xinputnum=$(getTouchDeviceId "PS/2 Elantech Touchpad")
|
||||
enableprop="Device Enabled"
|
||||
fi
|
||||
|
||||
# if we failed to get an input, exit
|
||||
[ -z "$xinputnum" ] && exiterror
|
||||
|
||||
# get the current state of the touchpad
|
||||
local tpstatus=$(xinput list-props $xinputnum | awk "/$enableprop/ { print \$NF }")
|
||||
|
||||
# if getting the status failed, exit
|
||||
[ -z "$tpstatus" ] && exiterror
|
||||
|
||||
if [ $tpstatus = 0 ]; then
|
||||
xinput set-prop $xinputnum "$enableprop" 1
|
||||
else
|
||||
xinput set-prop $xinputnum "$enableprop" 0
|
||||
fi
|
||||
}
|
||||
|
||||
# synclient: toggle touchpad on/off
|
||||
sc_toggletouchpad() {
|
||||
# get the status
|
||||
local tpstatus=$(synclient | grep TouchpadOff | sed 's/^\s*TouchpadOff\s*=\s*//')
|
||||
|
||||
# if getting the status failed, exit
|
||||
[ -z "$tpstatus" ] && exiterror
|
||||
|
||||
if [ $tpstatus = 0 ]; then
|
||||
synclient TouchpadOff=1
|
||||
else
|
||||
synclient TouchpadOff=0
|
||||
fi
|
||||
}
|
||||
|
||||
# sanity check
|
||||
if [ -x /usr/bin/synclient ]; then
|
||||
sc_toggletouchpad
|
||||
elif [ -x /usr/bin/xinput ]; then
|
||||
xi_toggletouchpad
|
||||
else
|
||||
exiterror "Error: /usr/bin/synclient and /usr/bin/xinput not found.\nOne of them must be installed!"
|
||||
fi
|
||||
6
x11-misc/toggle-touchpad/metadata.xml
Normal file
6
x11-misc/toggle-touchpad/metadata.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
|
||||
<pkgmetadata>
|
||||
<longdescription lang="en">Toggles touchpads on/off. Supports Synaptics and Elantech touchpads</longdescription>
|
||||
</pkgmetadata>
|
||||
|
||||
30
x11-misc/toggle-touchpad/toggle-touchpad-0.1.ebuild
Normal file
30
x11-misc/toggle-touchpad/toggle-touchpad-0.1.ebuild
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Copyright 1999-2012 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: $
|
||||
|
||||
EAPI=4
|
||||
|
||||
DESCRIPTION="Toggles touchpads on/off. Supports Synaptics and Elantech touchpads"
|
||||
HOMEPAGE="http://pentoo.ch"
|
||||
SRC_URI=""
|
||||
|
||||
LICENSE="GPL-2"
|
||||
SLOT="0"
|
||||
KEYWORDS="~amd64 ~x86"
|
||||
IUSE=""
|
||||
|
||||
DEPEND=""
|
||||
# todo: find out what happens when both are installed
|
||||
RDEPEND="${DEPEND} || (
|
||||
x11-drivers/xf86-input-synaptics
|
||||
x11-apps/xinput )"
|
||||
|
||||
S="${WORKDIR}"
|
||||
src_prepare() {
|
||||
cp ""${FILESDIR}/${PN} .
|
||||
}
|
||||
|
||||
src_install() {
|
||||
exeinto /usr/bin
|
||||
doexe "${PN}"
|
||||
}
|
||||
Loading…
Reference in a new issue