diff options
author | Teddy Wing | 2022-09-19 20:11:01 +0200 |
---|---|---|
committer | Teddy Wing | 2022-09-19 20:11:01 +0200 |
commit | 396ba133e421a12e6f523f14d7a18cade7fc94a3 (patch) | |
tree | 43a007ffb056294983626f889419201ba1486516 /keyboard_layout.lua | |
parent | 1dd8795c9bf02f3a9ce00c86ce6fddf9d995c585 (diff) | |
download | dothammerspoon-396ba133e421a12e6f523f14d7a18cade7fc94a3.tar.bz2 |
keyboard_layout: Try to change keyboard layout on keyboard device change
Try to detect when any keyboard is plugged in by looking at its
"productName" and checking to see if it contains the word "keyboard". If
so, change the keyboard layout between the preferred for internal and
external keyboards.
Diffstat (limited to 'keyboard_layout.lua')
-rw-r--r-- | keyboard_layout.lua | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/keyboard_layout.lua b/keyboard_layout.lua index 34404b7..9e6e1aa 100644 --- a/keyboard_layout.lua +++ b/keyboard_layout.lua @@ -25,6 +25,14 @@ keyboard_usb_watcher = hs.usb.watcher.new(function(event) return end + local product_name_contains_word_keyboard = string.find( + string.lower(event['productName']), + "keyboard" + ) + if not product_name_contains_word_keyboard then + return + end + if event['eventType'] == 'added' then hs.keycodes.setLayout('U.S.') elseif event['eventType'] == 'removed' then |