From cc53f7be1ccde78cc2d338297a00352b4fe545cf Mon Sep 17 00:00:00 2001 From: snailed Date: Thu, 9 Feb 2023 09:23:22 +0000 Subject: [PATCH] Clean up remapd I found a much better way of doing this, without a potentially too short sleep. This script waits for an input to be added, and then waits for a usb device to be bound. The remaps script can be run as soon as the USB device is bound. These changes should improve the reliability of the script and maybe even decrease latency. --- .local/bin/remapd | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.local/bin/remapd b/.local/bin/remapd index cf67428..f2edb4f 100755 --- a/.local/bin/remapd +++ b/.local/bin/remapd @@ -2,8 +2,10 @@ # Rerun the remaps script whenever a new input device is added. -while : ; do - remaps - dmesg -W -f kern | grep "input:" -q - sleep 1 +trap "rm -f /tmp/udev_pipe" HUP INT QUIT ILL TRAP BUS TERM +mkfifo -m 600 /tmp/udev_pipe +udevadm monitor -u -t seat -s input -s usb >>/tmp/udev_pipe & +while :; do + grep -q "add" /tmp/udev_pipe && grep -q " bind" /tmp/udev_pipe + remaps us:dvorak done