Last active
June 30, 2023 06:52
-
-
Save p3nj/74a746df417aca243a249be2ad556ead to your computer and use it in GitHub Desktop.
A script suspose to work with udev, check out https://benij.ltd/disable-internal-keyboard-when-external-keyboard-is-connected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When HHKB is connected | |
ACTION=="add", SUBSYSTEM=="usb", ENV{XAUTHORITY}="/home/user/.Xauthority", ENV{DISPLAY}=":0", ATTRS{idVendor}=="0853", ATTRS{idProduct}=="0100", RUN+="/home/user/bin/hhkb add" | |
# When HHKB is disconnected. | |
ACTION=="remove", SUBSYSTEM=="usb", ENV{XAUTHORITY}="/home/user/.Xauthority", ENV{DISPLAY}=":0", ATTRS{idVendor}=="0853", ATTRS{idProduct}=="0100", RUN+="/home/user/bin/hhkb remove" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# use $ xinput list to check your keyboard name | |
deviceName="Asus Keyboard" | |
# awk is the command to split return the string which is greped with command grep. | |
# In '{print $4 }', $n is the number of column of the string. | |
# You should be test it before put this into command down below. | |
builtInId=$(xinput list | grep $deviceName | awk '{ print $4 }' | grep -Eo '[0-9]{1,2}' | sort | head -n 1) | |
case $1 in | |
add) | |
xinput disable $builtInId | |
# dbus-launch is needed for send notification. | |
dbus-launch notify-send "HHKB Connected..." \ "Internal keyboard disabled !";; | |
remove) | |
xinput enable $builtInId | |
dbus-launch notify-send "HHKB Disconnected..." \ "Internal keyboard enabled !";; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment