1. 程式人生 > >Lxde新增觸控板雙擊功能、防誤觸

Lxde新增觸控板雙擊功能、防誤觸

前言

本文連結:https://www.cnblogs.com/hellxz/p/linux_touchpad_settings.html

這時簡單記錄一下最近兩天折騰Lxde的觸控板功能的設定,留待日後查閱

本文主要記錄一下APT系Linux開啟Lxde觸控板雙擊功能,以及一些關於觸控板防誤觸方面的設定

PS: Arch Linux可以直接參考官方wiki

解決Lxde沒有雙擊功能

安裝驅動包

sudo apt-get install xserver-xorg-input-synaptics

複製 /usr/share/X11/xorg.conf.d/etc/X11

sudo cp -R /usr/share/X11/xorg.conf.d /etc/X11/.
cd /etc/X11/xorg.conf.d
sudo vim 10-edev.conf #新增edev.conf配置檔案,新增自定義配置

新建/usr/share/X11/xorg.conf.d/10-edev.conf

sudo vim /usr/share/X11/xorg.conf.d/10-edev.conf #新增edev.conf配置檔案,新增自定義配置

檔案內容如下:

# To overwrite 70-synaptics.conf default configuration.
# The Options are useful for diy
Section "InputClass"  
        Identifier "evdev touchpad catchall"  
        MatchIsTouchpad "on"  
        MatchDevicePath "/dev/input/event*"  
        Driver "synaptics"  
        Option "TapButton1" "1"
        Option "TapButton2" "2"
        Option "TapButton3" "3"
EndSection

# if touchpad has duplicates, will ignore operation what you have done with touchpad.
Section "InputClass"
        Identifier "touchpad ignore duplicates"
        MatchIsTouchpad "on"
        MatchOS "Linux"
        MatchDevicePath "/dev/input/mouse*"
        Option "Ignore" "on"
EndSection

這裡開啟單擊、雙擊、三指的操作功能,如果不想再使用某一功能,可以設定其值為0或移除此Option

重啟系統

重啟系統後,我們會發現雙指操作可以正常使用了,但是我發現打字的時候,大拇指會碰到掌託,滑鼠亂跑,基本沒法正常打字,這樣也是不合需要的。所有有了下邊的打字等場景禁用觸控板的記錄

打字時禁用觸控板

這裡有三種方案,其一是開啟手掌探測,其二是打字時禁用觸控板,其三是直接禁用觸控板(提供切換指令碼)

檢視當前觸控板設定可以參考synclient -l

開啟手掌探測(Palm Detect)

以下為測試資料,可以使用如下引數在本次會話中測試,如果一切正常且滿足需要,可以新增到自啟指令碼中

synclient PalmDetect=1 #開啟手掌探測
synclient PalmMinWidth=8 # 手掌最小寬度
synclient PalmMinZ=100 #手掌用力最小力度(z座標軸方向)

以上的PalmMinWidthPalmMinZ的數值可以通過evtest軟體進行測試,使用方法如下圖

最後我們得到的引數,也可以新增到/usr/share/X11/xorg.conf.d/10-edev.conf中,接續在Option下方

例如剛才的配置應寫為:

Option "PalmDetect" "1"
Option "PalmMinWidth" "8"
Option "PalmMinZ" "100"

打字時禁用觸控板

syndaemon -m 300 -d  #300ms是暫停時間,更多詳情參考syndaemon -h

可以新增到自啟(auto_start)中,禁用時間可以按需調整,如果不寫-m指定毫秒數預設200ms,-i指定秒數,預設2s

禁用觸控板

實現思路是通過指令碼去切換當前禁用觸控板的狀態

建立shell指令碼

sudo vim /usr/local/bin/touchpad_toggle.sh 

內容如下:

#!/bin/bash

ts=`synclient -l|grep TouchpadOff`
ts=${ts#*= }

if [ "$ts" == 0 ]; then
    synclient TouchpadOff=1
else
    synclient TouchpadOff=0
fi

當然指令碼還可以簡寫為:

#!/bin/bash
synclient TouchpadOff=$(synclient -l | grep -c 'TouchpadOff.*=.*0')

引用文章:

Arch Linux Wiki

Ubuntu Wiki

Linux公社