Manjaro Linux 自动禁用触摸板

2020-09-30

本博客所有文章采用的授权方式为 自由转载-非商用-非衍生-保持署名 ,转载请务必注明出处,谢谢。 声明:
本博客欢迎转发,但请保留原作者信息!
博客:游钓四方的博客
邮箱:haibao1027@gmail.com
内容系本人学习、研究和总结,如有雷同,实属荣幸!

安装

安装必要的函数库和驱动程序

$ sudo pacman -S libinput xf86-input-libinput xorg-xinput

编写Shell脚本

$ vim DisableTouchpad.sh

#!/bin/bash

declare -i ID
ID=`xinput list | grep -Eio '(touchpad|glidepoint)\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}'`
declare -i STATE
STATE=`xinput list-props $ID|grep 'Device Enabled'|awk '{print $4}'`
if [ $STATE -eq 1 ]
then
    xinput disable $ID
else
    xinput enable $ID
fi

赋予脚本读/写/执行权限

$ sudo chmod 0755 DisableTouchpad.sh

Systemd 自启动

$ cd /usr/lib/systemd/system
# 创建Systemd服务
$ sudo vim touchpad.service

[Unit]
Description=Touchpad control service

[Service]
Type=oneshot
ExecStart=/File/Self-starting/DisableTouchpad.sh

[Install]
WantedBy=multi-user.target

配置touchpad服务自启动

$ systemctl enable touchpad
章节列表