用命令行xinput list可以查看到touchpad的序号,比如12,然后用命令可以禁止掉touchpad
xinput set-prop 12 "Device Enabled" 0
但是如果笔记本上插入其他USB设备,会导致touchpad序号变化,因此下面用一段newlisp脚本进行正则表达式匹配,自动适应变化的序号:
disable_touchpad.lsp
#!/usr/bin/newlisp (set 'r (exec "xinput list")) (set 'm (r (find "TouchPad" r 1))) (regex {\tid=(\d\d)} m) (set 'cmd (format "xinput set-prop %s \"Device Enabled\" 0" $1)) (exec cmd) (exit)
enable_touchpad.lsp
#!/usr/bin/newlisp (set 'r (exec "xinput list")) (set 'm (r (find "TouchPad" r 1))) (regex {\tid=(\d\d)} m) (set 'cmd (format "xinput set-prop %s \"Device Enabled\" 1" $1)) (exec cmd) (exit)原文链接:https://www.f2er.com/regex/361988.html