分页: 1 / 1

根据外接鼠标自动屏蔽笔记本触摸板的办法

发表于 : 2011-01-17 15:58
hubert_star
A

可以使用我截图中标明的工具和选项来实现这个功能:
1.png
B

另外一个办法就是用udev规则

代码: 全选

ACTION=="add", SUBSYSTEM=="input", ENV{ID_CLASS}="mouse", RUN+="/usr/bin/synclient TouchpadOff=1"
ACTION=="remove", SUBSYSTEM=="input", ENV{ID_CLASS}="mouse", RUN+="/usr/bin/synclient TouchpadOff=0"
参考:

https://wiki.archlinux.org/index.php/To ... 8.E6.9D.BF



C

完全一点的解决方案:

把这个脚本保存到/usr/local/bin下面,脚本名字可以写成:synapticsautooff,当然其他的也行,不过你需要改下面脚本对应的内容。

需要安装 inotify-tools

代码: 全选


#!/bin/bash
#
# Script: synapticsautooff
#
# Description:
#   This script monitors /dev for device changes. If something changed, then check /proc/bus/usb/devices
#   to find out the appearance of a mouse. Then turn touchpad off, or turn touchpad on.
#
# Requirement:
#   inotify-tools

trap "" SIGTERM # For the next command
killall synapticsautooff
trap - SIGTERM # Reset to original disposition

###########
# Constants

devfile=/proc/bus/usb/devices
synclient=/usr/bin/synclient

####################
# Check requirements

# Check device list file

if [ ! -e $devfile ]
then
    echo "Can not find $devfile"
    exit 0
fi

# Check inotifywait

notify=`whereis inotifywait -b | awk '{ print $2 }'`

if [ ${#notify} -eq 0 ]
then
    echo "This script needs inotify-tools"
    exit 0
fi

# Check synclient

synclient=`whereis synclient -b | awk '{ print $2 }'`

if [ ${#synclient} -eq 0 ]
then
    echo "This script needs synaptics"
    exit 0
fi

#################
# Check USB mouse
CheckMouse ()
{
    grep -i "mouse" $devfile > /dev/null
    if [ $? -eq 0 ]
    then
        # Has usb mouse, so turn off touchpad
        $synclient TouchpadOff=1
    else
		grep -i "USB Receiver" $devfile > /dev/null
		if [ $? -eq 0 ]
		then
			$synclient TouchpadOff=1
		else
			# No usb mouse, so turn on touchpad
			$synclient TouchpadOff=0
		fi
        
    fi
}

CheckMouse # Check at first

##############
# Waiting Loop

while true
do
	$notify -q -e create -e delete /dev/
    # Device changes
    CheckMouse
done

exit 0

把这个脚本加入到自动启动里面,这个方法比较纯粹,如果上面的工具解决不了这个问题可以用这个脚本

Re: 根据外接鼠标自动屏蔽笔记本触摸板的办法

发表于 : 2011-01-17 22:16
TeliuTe
存下备用

Re: 根据外接鼠标自动屏蔽笔记本触摸板的办法

发表于 : 2011-01-17 22:22
momova
这个,可以。
我好像也用了个什么,也可以实现这样的功能

Re: 根据外接鼠标自动屏蔽笔记本触摸板的办法

发表于 : 2011-01-17 23:45
eexpress
总结的。支持下。方法集中好。
软件咋没说明包的名字。

Re: 根据外接鼠标自动屏蔽笔记本触摸板的办法

发表于 : 2011-01-21 14:48
xcz
A 办法貌似只能在10.10里用
其他的试下去

Re: 根据外接鼠标自动屏蔽笔记本触摸板的办法

发表于 : 2011-01-21 15:03
leeaman
触控板是加载的psmouse控制的话,这个办法似乎不行的