我有一个G700鼠标连接到我的电脑。Linux (Ubuntu)中这个鼠标的问题是灵敏度很高。我也不喜欢鼠标加速,所以我做了一个脚本来关闭它。剧本看上去像这样
#!/bin/bash
# This script removes mouse acceleration, and lowers pointer speed
# Suitable for gaming mice, I use the Logitech G700.
# More info: http://www.x.org/wiki/Development/Documentation/PointerAcceleration/
xinput set-prop 11 'Device Accel Profile' -1
xinput set-prop 11 'Device Accel Constant Deceleration' 2.5
xinput set-prop 11 'Device Accel Velocity Scaling' 1.0
xinput set-prop 12 'Device Accel Profile' -1
xinput set-prop 12 'Device Accel Constant Deceleration' 2.5
xinput set-prop 12 'Device Accel Velocity Scaling' 1.0G700鼠标的另一个问题是它在xinput中显示为两个不同的设备。这很可能是因为鼠标有一个无线适配器,而且通常也是通过usb电缆连接(用于充电)。这是我来自xinput --list的输出(参见id 11和12):
$ xinput --list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=8 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=9 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:4003 id=10 [slave pointer (2)]
⎜ ↳ Logitech G700 Laser Mouse id=11 [slave pointer (2)]
⎜ ↳ Logitech G700 Laser Mouse id=12 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Power Button id=7 [slave keyboard (3)]这通常不是问题,因为id通常是相同的。但有时鼠标的id会改变,这就是我的问题所在。
编写脚本/程序的最简单方法是在xinput --list的输出中找到属于两个清单Logitech G700 Laser Mouse的id,然后使用这两个id在最上面的脚本中运行命令?
发布于 2013-09-12 06:31:11
你可以做下面这样的事情。
if [ "$SEARCH" = "" ]; then
exit 1
fi
ids=$(xinput --list | awk -v search="$SEARCH" \
'$0 ~ search {match($0, /id=[0-9]+/);\
if (RSTART) \
print substr($0, RSTART+3, RLENGTH-3)\
}'\
)
for i in $ids
do
xinput set-prop $i 'Device Accel Profile' -1
xinput set-prop $i 'Device Accel Constant Deceleration' 2.5
xinput set-prop $i 'Device Accel Velocity Scaling' 1.0
done因此,您首先找到与搜索模式$SEARCH匹配的所有ID,并将它们存储在$ids中。然后遍历ID并执行三个xinput命令。
您应该确保$SEARCH与很多不匹配,因为这可能导致不想要的行为。
发布于 2018-04-29 17:40:50
如果设备名称总是相同的,在本例中是Logitech G700 Laser Mouse,则可以通过运行
xinput list --id-only 'Logitech G700 Laser Mouse'发布于 2016-10-01 09:06:47
我的2分钱一个罗技游戏鼠标G502
#!/bin/sh
for id in `xinput --list|grep 'Logitech Gaming Mouse G502'|perl -ne 'while (m/id=(\d+)/g){print "$1\n";}'`; do
# echo "setting device ID $id"
notify-send -t 50000 'Mouse fixed'
xinput set-prop $id "Device Accel Velocity Scaling" 1
xinput set-prop $id "Device Accel Constant Deceleration" 3
done https://stackoverflow.com/questions/18755967
复制相似问题