by alexpovel · 2y ago · 0 comments
It grew out of a niche, almost historical need: using a QWERTY keyboard, but needing access to German Umlauts (ä, ö, ü, as well as ß). Switching keyboard layouts is possible but exhausting (it's much more pleasant sticking to one); using modifier keys is similarly tedious, and custom setups break and aren't portable.
So this tool can do:
$ echo 'Gruess Gott, Poeten und Abenteuergruetze!' | srgn --german
Grüß Gott, Poeten und Abenteuergrütze!
meaning it not only replaces Umlauts and Eszett, it also knows when not to (Poeten), and handles arbitrary compound words. Write your text, slap it all into the tool, it spits out results instantly. The original text can use alternative spellings (ou, ae, ue, ss), which is ergonomic. Combined with tools like AutohotKey, GUI integration through a single keyboard shortcut is possible. See [0] for a similar example.A niche need I haven't yet come across someone else having as well! (just the amount of text explaining what it's all about is saying a lot in terms of specificity...)
The tool now grew into a tree-sitter based (== language grammar-aware) text manipulation thing, mostly for fun. The bizarre German core is still there however.
[0]: https://github.com/alexpovel/betterletter/blob/c19245bf90589...
On macOS it's relatively easy to create using a tool called Ukulele (https://software.sil.org/ukelele/). You can also download my layout here: https://alex.kirk.at/USUmlaut.keylayout
The default behaviour of the Latvian layout in macOS is to make apostrophe a dead key, which really grinds my gears. So I made it alt+whatever letter instead. As a dev I use apostrophe way too much to be okay with typing '+space for it.
xkb_options grp:win_space_toggle,compose:caps
and then I can do compose ss for ß or compose SS for ẞ.I guess I have just nerdsniped myself into building a script/hack that can automatically edit the clipboard and/or selected text on button press. There goes my weekend, but thank you for building this part!
But this is a custom setup that's not portable?
And how is it less tedious to have to select previously typed text all the time? Is it mainly better because then you don't need to do anything on individual chars, but do it in a batch?
Caught me.
> And how is it less tedious to have to select previously typed text all the time?
This is tedious, but I have that automated (AutoHotKey). So a single, AHK-managed hotkey does the equivalent of:
CTRL + SHIFT + HOME
CTRL + C
feed into tool, paste back
CTRL + V
So once done writing, I press that single button and it's done (CTRL+SHIFT+HOME select all text from cursor to beginning). To me, that's a better tradeoff than fiddling with compose keys, which I find to break flow. For very short text, compose key is possibly better; but again, once in AHK, it's a single shortcut. So once more than 1 compose key combination is needed, it's "worth it". But you're right: this is a custom setup and might not work for everyone.Agree re. the potential to break flow part of the compose keys in general (all these grammar things should be automated away), though maybe in case of needing just a single diacritic the least fiddly alternative could be something like a hotstring in AHK ",u" to "ü" (comma + a letter without spaces, which doesn't happen in regular typing or a deadkey in keyboard layout with a similar effect)
Did you opt to blacklist words with vowel combinations that should not be transformed, or whitelist those that should? Or something else entirely?
[0]: https://github.com/alexpovel/srgn/blob/0008cce1c71f0d83f6a31...