#!/bin/bash
# scroll-speed-adjuster.sh
echo "Linux滚动速度调整工具"
echo "======================"
# 安装依赖
sudo apt install -y libinput-tools
# 获取触摸板尺寸
echo "正在测量触摸板尺寸..."
DIMENSIONS=$(sudo libinput measure touchpad-size 100x100 | grep -o '[0-9]*\.[0-9]*x[0-9]*\.[0-9]*' | head -1)
echo "检测到的触摸板尺寸: $DIMENSIONS"
# 询问用户期望的速度
read -p "请输入期望的滚动速度因子 (0.1-3.0, 1.0为默认): " SPEED_FACTOR
# 计算新尺寸
WIDTH=$(echo $DIMENSIONS | cut -d'x' -f1 | cut -d'.' -f1)
HEIGHT=$(echo $DIMENSIONS | cut -d'x' -f2 | cut -d'.' -f1)
NEW_WIDTH=$(echo "$WIDTH * $SPEED_FACTOR" | bc | cut -d'.' -f1)
NEW_HEIGHT=$(echo "$HEIGHT * $SPEED_FACTOR" | bc | cut -d'.' -f1)
echo "正在生成新配置..."
sudo libinput measure touchpad-size ${NEW_WIDTH}x${NEW_HEIGHT}
echo "配置完成!请重启计算机使更改生效。"