You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
817 B

#!/usr/bin/env bash
set -o errexit
main() {
export RUNNING_AS="${RUNNING_AS:-me}"
export RUNNING_AS_ID="$(id -u "${RUNNING_AS}")"
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
# libinput Scroll Method Enabled (285)
/usr/bin/sudo -E -u "${RUNNING_AS}" \
/usr/sbin/xinput set-prop "${device_id}" 285 0 0 1
}
__get_device_id() {
/usr/bin/sudo -E -u "${RUNNING_AS}" /usr/sbin/xinput list |
awk '/Logitech USB Trackball/ { sub(/id=/, "", $6); print $6 }'
}
main "${@}"