diff options
author | Teddy Wing | 2023-11-08 19:56:53 +0100 |
---|---|---|
committer | Teddy Wing | 2023-11-08 20:02:28 +0100 |
commit | 9464388e078d4641b720fb695a19518f86692a5b (patch) | |
tree | 8fda20767fa84412757757e66b666555a0182f1d | |
parent | ebea1dc3c0b29ac5b4aa9f2f51cc70ff43191377 (diff) | |
download | dothammerspoon-9464388e078d4641b720fb695a19518f86692a5b.tar.bz2 |
keyboard_layout_select: Add shortcuts to select keyboard layout
I had to upgrade to Mac OS 14 Sonoma, which in addition to adding a
useless software Caps Lock indicator, also royally screwed up the way
that changing keyboard layouts used to work (it worked perfectly fine).
I decided to make a unique keyboard shortcut to switch to each keyboard
layout to put some order to the madness.
-rw-r--r-- | init.lua | 3 | ||||
-rw-r--r-- | keyboard_layout_select.lua | 48 |
2 files changed, 50 insertions, 1 deletions
@@ -1,4 +1,4 @@ --- Copyright (c) 2019, 2021 Teddy Wing +-- Copyright (c) 2019, 2021, 2023 Teddy Wing -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ require('application_switch') require('catalina_brightness_bullshit') require('gdrive_mouseover_item') require('keyboard_layout') +require('keyboard_layout_select') require('meet') require('mouse') require('terminal_tab_hotkeys') diff --git a/keyboard_layout_select.lua b/keyboard_layout_select.lua new file mode 100644 index 0000000..e87f5d7 --- /dev/null +++ b/keyboard_layout_select.lua @@ -0,0 +1,48 @@ +-- Copyright (c) 2023 Teddy Wing +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <https://www.gnu.org/licenses/>. + + +-- Shortcuts to change keyboard layouts. +-- +-- Mac OS 14 Sonoma so completely borked switching keyboard layouts that this +-- became a necessity. Since Mac OS 14, pressing Control-Space inconceivably no +-- longer reorders the list of keyboard layouts based on the most recently used +-- layout, meaning you can no longer press Control-Space-Space to go to the +-- one-indexed third layout, then press Control-Space to go back to the +-- previous layout. Instead, the Control-Space in the second step brings you to +-- a completely different layout. Yet another hostile change by Apple to make +-- Mac OS unusable. + + +local layouts = { + "U.S.", + "French – Numerical", + "QWAZERTY2", + "Dvorak" +}; + +keyboard_layout_select_bindings = {} + +for i = 1, #layouts do + local key = tostring(i) + + keyboard_layout_select_bindings[i] = hs.hotkey.bind( + {"ctrl", "alt"}, + key, + function() + hs.keycodes.setLayout(layouts[i]) + end + ) +end |