Skip to content

Instantly share code, notes, and snippets.

@rwese
Created September 13, 2021 15:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwese/3377a761f796c54a2f11873858ceaaa3 to your computer and use it in GitHub Desktop.
Save rwese/3377a761f796c54a2f11873858ceaaa3 to your computer and use it in GitHub Desktop.
get the event device by name for a keyboard or mouse on linux
#!/bin/bash
# read the /proc/bus/input/devices and then parse out the proper event device
# this can be used in conjuction with kmonad *https://github.com/kmonad/kmonad)
DEVICE_NAME="Logitech MX Keys"
EVENT=$(grep "$DEVICE_NAME" /proc/bus/input/devices -A 4 | tail -n1 | grep -Eo 'event[0-9]+')
DEVICE="/dev/input/$EVENT"
echo "Found device at: $DEVICE"
@rwese
Copy link
Author

rwese commented Sep 13, 2021

Full kmonad start script example, dirty but gets the job done.

I also have split the configuration into multiple .lisps as I have separate use-cases, work/gaming.

#!/usr/bin/env bash
DEVICE_NAME="Logitech MX Keys"
EVENT=$(grep "$DEVICE_NAME" /proc/bus/input/devices -A 4 | tail -n1 | grep -Eo 'event[0-9]+')
DEVICE="/dev/input/$EVENT"

echo "Found device at: $DEVICE"

cat << EOF > .run_cfg.kbd
;; generated

(defcfg
  input  (device-file "$DEVICE")
  output (uinput-sink "My KMonad output" "/bin/setxkbmap -option && /bin/setxkbmap -layout \"us,us\" -variant \"altgr-intl,\"  -option \"ctrl:nocaps,terminate:ctrl_alt_bksp\" && /usr/bin/sleep 4")
  fallthrough true
  allow-cmd true
)
EOF

cat aliases_common.lisp \
    deflayers_common.lisp \
    >> .run_cfg.kbd
./kmonad-0.4.1-linux .run_cfg.kbd --log-level debug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment