Dynamically find relevant trackman marble prop ids
This commit is contained in:
parent
9bc084277b
commit
5d81ebd4fa
@ -4,27 +4,49 @@ set -o errexit
|
||||
main() {
|
||||
export RUNNING_AS="${RUNNING_AS:-me}"
|
||||
export RUNNING_AS_ID="$(id -u "${RUNNING_AS}")"
|
||||
export XINPUT_EXE="${XINPUT_EXE:=xinput}"
|
||||
|
||||
export XAUTHORITY="/home/${RUNNING_AS}/.Xauthority"
|
||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${RUNNING_AS_ID}/bus"
|
||||
export DISPLAY=:0
|
||||
export HOME="/home/${RUNNING_AS}"
|
||||
|
||||
|
||||
local device_id
|
||||
device_id="$(__get_device_id)"
|
||||
|
||||
# libinput Natural Scrolling Enabled (282)
|
||||
/usr/bin/sudo -E -u "${RUNNING_AS}" \
|
||||
/usr/sbin/xinput set-prop "${device_id}" 282 1
|
||||
local natscroll_enabled
|
||||
natscroll_enabled="$(
|
||||
__get_prop_id "${device_id}" 'Natural Scrolling Enabled'
|
||||
)"
|
||||
|
||||
# libinput Scroll Method Enabled (285)
|
||||
/usr/bin/sudo -E -u "${RUNNING_AS}" \
|
||||
/usr/sbin/xinput set-prop "${device_id}" 285 0 0 1
|
||||
local scrollmeth_enabled
|
||||
scrollmeth_enabled="$(
|
||||
__get_prop_id "${device_id}" 'Scroll Method Enabled'
|
||||
)"
|
||||
|
||||
__run_xinput_as set-prop "${device_id}" "${natscroll_enabled}" 1
|
||||
__run_xinput_as set-prop "${device_id}" "${scrollmeth_enabled}" 0 0 1
|
||||
}
|
||||
|
||||
__get_device_id() {
|
||||
/usr/bin/sudo -E -u "${RUNNING_AS}" /usr/sbin/xinput list |
|
||||
__run_xinput_as list |
|
||||
awk '/Logitech USB Trackball/ { sub(/id=/, "", $6); print $6 }'
|
||||
}
|
||||
|
||||
__get_prop_id() {
|
||||
local device_id="${1}"
|
||||
local propmatch="${2}"
|
||||
__run_xinput_as list-props "${device_id}" |
|
||||
awk -F: '/'"${propmatch}"' \([0-9]+\)/ {
|
||||
sub(/.+\(/, "", $1);
|
||||
sub(/\).*/, "", $1);
|
||||
print $1;
|
||||
}'
|
||||
}
|
||||
|
||||
__run_xinput_as() {
|
||||
sudo -E -u "${RUNNING_AS}" "${XINPUT_EXE}" "${@}"
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
|
Loading…
Reference in New Issue
Block a user