Attempt to udev better

This commit is contained in:
Dan Buch 2023-01-23 10:48:07 -05:00
parent 4c5e73305f
commit ebb5b6db13
Signed by: meatballhat
GPG Key ID: A12F782281063434
3 changed files with 26 additions and 7 deletions

View File

@ -1,3 +1,5 @@
SUDO ?= sudo
TOP_SOURCES := $(shell git ls-files | grep -vE 'README|Makefile|^config|^\.git|^\.travis' | grep -v /) TOP_SOURCES := $(shell git ls-files | grep -vE 'README|Makefile|^config|^\.git|^\.travis' | grep -v /)
CONFIG_SOURCES := $(shell git ls-files config) CONFIG_SOURCES := $(shell git ls-files config)
LOCAL_BIN_SOURCES := $(shell git ls-files local/bin) LOCAL_BIN_SOURCES := $(shell git ls-files local/bin)
@ -5,7 +7,9 @@ TARGETS := \
$(patsubst %,$(HOME)/.%,$(TOP_SOURCES)) \ $(patsubst %,$(HOME)/.%,$(TOP_SOURCES)) \
$(patsubst %,$(HOME)/.%,$(CONFIG_SOURCES)) \ $(patsubst %,$(HOME)/.%,$(CONFIG_SOURCES)) \
$(patsubst %,$(HOME)/.%,$(LOCAL_BIN_SOURCES)) \ $(patsubst %,$(HOME)/.%,$(LOCAL_BIN_SOURCES)) \
$(HOME)/.config/i3/config $(HOME)/.config/i3/config \
/etc/udev/rules.d/90-trackman-marble.rules \
/usr/local/bin/handle-trackman-marble
$(HOME)/.%: % $(HOME)/.%: %
$(RM) '$@' && mkdir -p $(dir $@) && ln -svf '$(PWD)/$^' '$@' $(RM) '$@' && mkdir -p $(dir $@) && ln -svf '$(PWD)/$^' '$@'
@ -19,6 +23,12 @@ $(HOME)/.config:
$(HOME)/.local/bin: $(HOME)/.local/bin:
mkdir -p $@ mkdir -p $@
/etc/udev/rules.d/90-trackman-marble.rules: udev/rules.d/90-trackman-marble.rules
$(SUDO) install -m 0644 -v udev/rules.d/90-trackman-marble.rules $@
/usr/local/bin/handle-trackman-marble: udev/handle-trackman-marble
$(SUDO) install -m 0644 -v udev/handle-trackman-marble $@
.PHONY: echo .PHONY: echo
echo: echo:
@echo TOP_SOURCES=$(TOP_SOURCES) @echo TOP_SOURCES=$(TOP_SOURCES)

View File

@ -1,14 +1,17 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o errexit set -o errexit
set -o pipefail
main() { main() {
export RUNNING_AS="${RUNNING_AS:-me}" export RUNNING_AS="${RUNNING_AS:-dan}"
export RUNNING_AS_ID="$(id -u "${RUNNING_AS}")" RUNNING_AS_ID="$(id -u "${RUNNING_AS}")"
export XINPUT_EXE="${XINPUT_EXE:=xinput}" export RUNNING_AS_ID
export XAUTHORITY="/home/${RUNNING_AS}/.Xauthority" export XINPUT_EXE="${XINPUT_EXE:=xinput}"
export XAUTHORITY="/run/user/${RUNNING_AS_ID}/gdm/Xauthority"
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${RUNNING_AS_ID}/bus" export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${RUNNING_AS_ID}/bus"
export DISPLAY=:0 : "${DISPLAY:=0}"
export DISPLAY
export HOME="/home/${RUNNING_AS}" export HOME="/home/${RUNNING_AS}"
@ -25,8 +28,14 @@ main() {
__get_prop_id "${device_id}" 'Scroll Method Enabled' __get_prop_id "${device_id}" 'Scroll Method Enabled'
)" )"
local scrollbutton
scrollbutton="$(
__get_prop_id "${device_id}" 'Button Scrolling Button'
)"
__run_xinput_as set-prop "${device_id}" "${natscroll_enabled}" 1 __run_xinput_as set-prop "${device_id}" "${natscroll_enabled}" 1
__run_xinput_as set-prop "${device_id}" "${scrollmeth_enabled}" 0 0 1 __run_xinput_as set-prop "${device_id}" "${scrollmeth_enabled}" 0 0 1
__run_xinput_as set-prop "${device_id}" "${scrollbutton}" 8
} }
__get_device_id() { __get_device_id() {

View File

@ -1 +1 @@
ACTION=="bind", SUBSYSTEM=="usb", ENV{ID_VENDOR}=="Logitech", ENV{ID_SERIAL}=="Logitech_USB_Trackball", RUN:="/usr/local/bin/handle-trackman-marble" ACTION=="bind", SUBSYSTEM=="usb", ENV{NAME}=="Logitech USB Trackball", MODE="0660", TAG+="uaccess", RUN:="/usr/local/bin/handle-trackman-marble"