Backtick dead key, but pressing it twice inserts two of them

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

Any help is appreciated !

1 Like

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:

services.xserver.xkb = {
    extraLayouts.cch = {
        description = "CH with custom grave";
        languages = [ "ger" ];
        symbolsFile = pkgs.writeText "ch-custom" ''
          xkb_symbols "basic" {
            include "ch(basic)"
            key <AE12> { [ dead_circumflex, dead_grave, asciitilde, grave ] };
          };
       '';
    };
    layout = "cch";
  };

On my keyboard this would make my top right key output the grave symbol with shift + altgr modifiers, but dead_grave with just shift modifier.

See x.org for more information on xkb.extraLayouts configuration.

1 Like

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> : "``"
  '';

Thank you for your help !

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:

  1. This forum and Codium: ~/
  2. Kitty: nothing, no character is typed
  3. Konsole: /, the tilde character is ignored

And for the double backtick I get:

  1. This forum, Kitty, Konsole, and Codium terminal: a single backtick
  2. Codium text editor: double backtick

On windows I really don’t remember being surprised, everything worked using the above convention