如何切换 xinput 设备道具

yuv*_*uvi 9 touchpad bash

我可以禁用这样的设备:

xinput set-prop 13 "Device Enabled" 0
Run Code Online (Sandbox Code Playgroud)

但我想实际设置一个自定义快捷方式,在 0\1 之间切换。我的 bash 技能有点生疏,所以我该怎么做?没有 get-prop 命令,我做到了这一点:

xinput list-props 13 | grep "Device Enabled"
Run Code Online (Sandbox Code Playgroud)

哪个正确打印出来

Device Enabled (135):   1
Run Code Online (Sandbox Code Playgroud)

但我不知道接下来要做什么。帮助?

小智 17

使用以下 bash 脚本打开或关闭 xinput 设备。

#!/bin/bash

device=13
state=$(xinput list-props "$device" | grep "Device Enabled" | grep -o "[01]$")

if [ $state == '1' ];then
  xinput --disable "$device"
else
  xinput --enable "$device"
fi
Run Code Online (Sandbox Code Playgroud)