kde5與archlinux環(huán)境下如何配置libinput-gestures多手勢操作

這篇文章主要講解了“kde5與archlinux環(huán)境下如何配置libinput-gestures多手勢操作”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“kde5與archlinux環(huán)境下如何配置libinput-gestures多手勢操作”吧!

創(chuàng)新互聯(lián)長期為近1000家客戶提供的網(wǎng)站建設(shè)服務(wù),團隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為阜平企業(yè)提供專業(yè)的成都網(wǎng)站設(shè)計、網(wǎng)站建設(shè),阜平網(wǎng)站改版等技術(shù)服務(wù)。擁有十載豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。

初衷

自己的筆記本是archlinux+kde plasma5的環(huán)境,看到同事的macbook pro支持很多手勢操作(gestures),自己也希望在archlinux和kde的環(huán)境下配置方便的手勢操作。

查詢資料后發(fā)現(xiàn)touchegg和libinput-gestures都可以滿足需求,但是在實際配置過程中,touchegg存在很多問題一直都沒能解決,而libinput-gestures基本沒有太大的問題。所以本文主要介紹如何配置libinput-gestures。

預(yù)備知識

  1. 計算機窗口管理器

  2. kde是X.Org桌面環(huán)境,aur上維護了一個基于X.Org Server的驅(qū)動xf86-input-libinput-git,很方便。它們間的關(guān)系如下:

    X11 client在我這里就是kde plasma5。

  3. 驅(qū)動程序libinput,linux生態(tài)提供了很多驅(qū)動,本文使用的驅(qū)動是libinput,它負責(zé)分析內(nèi)核從輸入設(shè)備得到的數(shù)據(jù),發(fā)送給桌面環(huán)境,桌面環(huán)境根據(jù)不同的數(shù)據(jù)進行反饋。

術(shù)語解釋

  • touchpad:通常意義上的觸摸板。

  • clickpad:指底部沒有按鈕的touchpad,參考clickpad。clickpad中通過不同手指數(shù)量的點擊行為來模擬鼠標(biāo)左鍵、中鍵、右鍵點擊。這些都可以配置或者關(guān)閉。

  • click:點擊,本文語境中之物理按鈕的“按壓”和“釋放”。

  • Clickpad software button behavior:clickpad上軟按鈕的行為,詳情見Clickpad software button behavior。

libinput

安裝

  1. install basic libinput and xf86-input-libinput

    sudo gpasswd -a $USER input
    sudo pacman -S libinput xf86-input-libinput

配置

libinput有兩種配置方式:

  • 使用配置文件的永久配置方式

  • 使用xinput命令行工具,針對運行時(runtime)進行實時配置,主要用來調(diào)試。

配置文件

libinput安裝后默認(rèn)的配置文件在/usr/share/X11/xorg.conf.d目錄下,如何你安裝多個驅(qū)動,會存在多個文件:

?  xorg.conf.d ll
total 12K
-rw-r--r-- 1 root root 1.4K Aug 14 05:40 10-quirks.conf
-rw-r--r-- 1 root root  964 May  5 20:24 40-libinput.conf
-rw-r--r-- 1 root root 1.8K Nov 18  2016 70-synaptics.conf

筆者這里安裝了3個驅(qū)動,所以有3個配置文件,默認(rèn)情況下,kde會根據(jù)文件前綴數(shù)字的大小決定優(yōu)先使用哪個配置文件,數(shù)字越大,優(yōu)先級越高。

我們需要把默認(rèn)配置文件復(fù)制到/etc/X11/xorg.conf.d/目錄下:

sudo cp /usr/share/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/40-libinput.conf

下面是文件中touchpad部分的配置:

Section "InputClass"
        Identifier "touchpad"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
        Option "Tapping" "on"
        Option "ButtonMapping" "1 3 0 4 5 6 7"
        Option "TappingButtonMap" "lmr"
        Option "DisableWhileTyping" "on"
        Option "TappingDrag" "on"
EndSection

詳細參數(shù)和解釋見libinput man page: based on X.Org input dirver,解釋下幾個重要的配置參數(shù):

  • Option “Tapping” “on”:手指點擊touchpad發(fā)送鼠標(biāo)點擊事件

  • Option “TappingButtonMap” “l(fā)mr”:1個手指點擊對應(yīng)鼠標(biāo)左鍵,2個手指點擊對應(yīng)鼠標(biāo)中鍵,3個鼠標(biāo)點擊對應(yīng)鼠標(biāo)右鍵。

  • Option “ButtonMapping” “1 3 0 4 5 6 7”,按鈕映射,詳情見libinput#Button_Mapping,這里筆者關(guān)閉了3指對應(yīng)的左鍵。

  • Option “DisableWhileTyping” “on”:打字時不檢測touchpad事件,防止用戶不小心觸碰touchpad引起不必要的影響。

  • Option “TappingDrag” “on”:開啟點擊拖拽。

調(diào)試
  1. 確定touchpad設(shè)備

    ?  ~ xinput list
    ? Virtual core pointer                          id=2    [master pointer  (3)]
    ?   ? Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
    ?   ? SynPS/2 Synaptics TouchPad                id=13   [slave  pointer  (2)]
    ?   ? TPPS/2 IBM TrackPoint                     id=16   [slave  pointer  (2)]
    ......
  2. 查看touchpad的詳細配置

    ?  ~ xinput list-props "SynPS/2 Synaptics TouchPad"
    Device 'SynPS/2 Synaptics TouchPad':
         Device Enabled (142):   1
         Coordinate Transformation Matrix (144): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
         libinput Tapping Enabled (295): 1
         libinput Tapping Enabled Default (296): 0
         libinput Tapping Drag Enabled (297):    1
         libinput Tapping Drag Enabled Default (298):    1
         libinput Tapping Drag Lock Enabled (299):       0
         libinput Tapping Drag Lock Enabled Default (300):       0
         libinput Tapping Button Mapping Enabled (301):  0, 1
         libinput Tapping Button Mapping Default (302):  1, 0
         libinput Accel Speed (277):     0.000000
         libinput Accel Speed Default (278):     0.000000
         libinput Natural Scrolling Enabled (282):       0
         libinput Natural Scrolling Enabled Default (283):       0
         libinput Send Events Modes Available (262):     1, 1
         libinput Send Events Mode Enabled (263):        0, 0
         libinput Send Events Mode Enabled Default (264):        0, 0
         libinput Left Handed Enabled (284):     0
         libinput Left Handed Enabled Default (285):     0
         libinput Scroll Methods Available (286):        1, 1, 0
         libinput Scroll Method Enabled (287):   1, 0, 0
         libinput Scroll Method Enabled Default (288):   1, 0, 0
         libinput Click Methods Available (303): 1, 1
         libinput Click Method Enabled (304):    1, 0
         libinput Click Method Enabled Default (305):    1, 0
         libinput Middle Emulation Enabled (291):        0
         libinput Middle Emulation Enabled Default (292):        0
         libinput Disable While Typing Enabled (306):    1
         libinput Disable While Typing Enabled Default (307):    1
         Device Node (265):      "/dev/input/event10"
         Device Product ID (266):        2, 7
         libinput Drag Lock Buttons (293):       <no items>
         libinput Horizontal Scroll Enabled (294):       1

    這里面有一個值很重要Device Node (265):      “/dev/input/event10”,后面使用libinput命令行時會用到這個路徑。

  3. 使用libinput debug-events 監(jiān)控touchpad事件

    ?  ~ libinput debug-events --device /dev/input/event10
    -event10  DEVICE_ADDED     SynPS/2 Synaptics TouchPad        seat0 default group1  cap:pg  size 100x56mm tap(dl off) left scroll-nat scroll-2fg-edge click-buttonareas-clickfinger dwt-on
    event10  GESTURE_SWIPE_BEGIN  +2.82s   3
    event10  GESTURE_SWIPE_UPDATE  +2.82s  3  0.00/ 0.44 ( 0.00/ 3.63 unaccelerated)
    event10  GESTURE_SWIPE_UPDATE  +2.84s  3  0.00/ 3.43 ( 0.00/19.38 unaccelerated)
    event10  GESTURE_SWIPE_UPDATE  +2.87s  3  0.00/ 5.00 ( 0.00/19.38 unaccelerated)
    event10  GESTURE_SWIPE_UPDATE  +2.89s  3  0.00/ 3.33 ( 0.00/10.90 unaccelerated)
    event10  GESTURE_SWIPE_UPDATE  +2.92s  3  0.00/ 2.74 ( 0.00/ 8.48 unaccelerated)
  4. 使用libinput debug-gui 監(jiān)控touchpad事件

    ?  ~ libinput debug-gui --device /dev/input/event10
    info: event10 SynPS/2 Synaptics TouchPad     added

    這時會出現(xiàn)一個GUI畫面幫助檢測。

  5. kde5與archlinux環(huán)境下如何配置libinput-gestures多手勢操作

libinput-gestures

配置好touchpad和手勢后,下面利用libinput-gestures來解析touchpad的數(shù)據(jù),然后執(zhí)行相關(guān)的操作。這里主要用到xdotool,xdotool是模擬鍵盤/鼠標(biāo)輸入和窗口管理等的命令行工具。libinput-gestures依賴xdotool。

libinput-gestures安裝后會有默認(rèn)的配置,位置在/etc/libinput-gestures.conf,用戶可以在~/libinput-gestures.conf配置自己的配置。筆者根據(jù)自己的需要修改了相關(guān)配置,如下:

# Switch to next desktop
gesture swipe right 4   xdotool key ctrl+F1
# Switch to prev desktop
gesture swipe left 4 xdotool key ctrl+F2

# Present windows (current desktop)
gesture swipe down 3 xdotool key ctrl+F9
# Present windows (all desktop)
gesture swipe down 4 xdotool key ctrl+F10

# Show desktop
gesture swipe up 3 xdotool key super+d
# Show desktops grid
gesture swipe up 4 xdotool key ctrl+F8

主要思想是針對不同的手勢觸發(fā)相關(guān)的快捷鍵,快捷鍵的配置則可以在系統(tǒng)偏好設(shè)置→快捷鍵中設(shè)置。下圖是筆者在plasma5中的切換桌面的快捷鍵配置:

kde5與archlinux環(huán)境下如何配置libinput-gestures多手勢操作

Demo

  1. 四指橫向滑動切換桌面:

    kde5與archlinux環(huán)境下如何配置libinput-gestures多手勢操作

TODOs

  • 通過捏和(pinch in/pinch out)來放大/縮小網(wǎng)頁(對標(biāo)macbook)

  • 網(wǎng)頁的前進/后退(對標(biāo)macbook)

  • 待添加…

總結(jié)

本文從想法到配置好前前后后花了大約1個月時間,大部分時間用在了理解輸入驅(qū)動、配置驅(qū)動以及配置調(diào)試toucgegg和libinput-gestures上了。

筆者在配置好自己的archlinux 手勢后,機緣巧合用了一個星期的macbook pro,體會了蘋果下面的手勢操作??傮w感覺蘋果的手勢操作更流暢,識別更準(zhǔn)確。畢竟蘋果是自己的生態(tài)系統(tǒng),可以針對自己的macOS系統(tǒng)進行封裝和調(diào)試。而在Linux生態(tài)中,因為存在多個Linux發(fā)行版和桌面環(huán)境,手勢操作很難兼容所有發(fā)行版,這就要求用戶要有較強的動手能力和理解能力??梢哉f兩者都能實現(xiàn)豐富的手勢操作,而且Linux的擴展性更強一些,但是需要更專業(yè)的知識和動手能力。

感謝各位的閱讀,以上就是“kde5與archlinux環(huán)境下如何配置libinput-gestures多手勢操作”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對kde5與archlinux環(huán)境下如何配置libinput-gestures多手勢操作這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!

文章標(biāo)題:kde5與archlinux環(huán)境下如何配置libinput-gestures多手勢操作
轉(zhuǎn)載注明:http://bm7419.com/article48/goeeep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計、電子商務(wù)、服務(wù)器托管品牌網(wǎng)站建設(shè)、外貿(mào)建站、網(wǎng)頁設(shè)計公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營