I frequently type in french, so I need keys like caret and backtick to act as dead keys
But I also program and write markdown, so I need to type literal backticks quite frequently, but almost always in multiples of 2
On windows, when I press backtick twice, it inserts 2 backticks, which is convenient
(IIRC on MacOS as well)
Since I have moved to NixOS, pressing the backtick key twice only inserts a single backtick
This means to open a markdown code block, I need to press the backtick key 12 times !
(And sometimes that is in the middle of french text, so changing layout is not practical)
How can I make it work in the windows way ?
I was not able to find an answer on my own (even searching for linux more broadly) since the search results are saturated with many different flavours of “what are deadkeys ?”/“Why is this working like this ? (answer: deadkeys)”
The closest I have been able to find is this:
But it actually explains how to make dead keys not dead, not the specific behavior I am looking for
To replicate, easiest is to use the live nixos installer and set your keyboard layout to swiss french (for some reason it is under the german language). It’s a qwertz layout, so it should be almost familiar
Not the solution you’re looking for, but a potential workaround would be to configure a custom key/key combination to insert the grave symbol.
E.g. one way of doing so is via xkb.extraLayouts. I’ve tested with swiss german:
After some more testing I was able to figure out a solution. Again, I tested with the swiss german keyboard layout. If you are using home-manager, add this to e.g. home.nix:
home.file.".XCompose".text = ''
include "%L"
<dead_grave> <dead_grave> : "``"
'';
This would only work for X11 and not wayland, right ?
Also the behavior was more general, I should have been more precise:
“A dead diacritic key followed by a non-diacritic-able key would result in both being emitted.”
For example ^ followed by T would output ^T, ~ followed by / would output ~/
On NixOS (and IIRC linux more generally) I get different behaviour depending on the program:
This forum and Codium: ~/
Kitty: nothing, no character is typed
Konsole: /, the tilde character is ignored
And for the double backtick I get:
This forum, Kitty, Konsole, and Codium terminal: a single backtick
Codium text editor: double backtick
On windows I really don’t remember being surprised, everything worked using the above convention
To my understanding the two are not always mutually exclusive: Wayland may use packages or libraries originally made for X11. libxkbcommon is one of these, which implements Xcompose. For further reading see XKB, briefly - The Wayland Protocol and libxkbcommon: Compose and dead-keys support . I myself am using KDE plasma 6.5, which primarily uses Wayland.
As for the other undead character issues:
Most of them seem program specific - I’ve also noticed that even my double backtick solution doesn’t work on all (web) inputs. However it does work in most places (including this forum and the Konsole). VSCodium doesn’t seem to insert double ticks for me without the XCompose rule.
The Konsole probably handles characters a bit differently than other applications, but I do admit it does seem very arbitrary. It seems to me like it will ignore it if the following character isn’t space or a letter of the latin alphabet. Adding another rule to XCompose fixes that specific combination for me: <dead_tilde> <slash> : "~/"
I do agree that it seems a bit weird that it works for Windows but not Linux - if I have the time I might try to see if there are any answers to be found in the difference between how the two handle multi-key compositions, but no promises.
At the moment I can’t think of a good approach to fix all of the issues, but using XCompose can probably solve most of them - assuming it works on your system.
Thank you for your in-depth answer, I’ll give it a try !
I think it would make a lot of sense as the default behavior however (but I’m not sure where even to begin to contribute something like that)
I think what happens for me is actually only a single backtick is inserted, but it “closes” it and drops me in the middle, same as when I type ( or {
@DragoX I tried to add your changes, but I’m not sure how to do so
If I only do the part that worked for you .. ".XCompose".text ..., it doesn’t seem to do anything
So I’m assuming I also need to do some of the services.xserver.xkb, but not sure exactly what
Especially since the .XCompose file is not mentioned there
(I started looking at the docs you sent, but I had some trouble mapping the explanations back onto nixos)