EDIT: Solved! Check this comment!

I use a keyboard with an american layout. I find it much better for coding and actually love this keyboard to pieces. However, I still need to write in portuguese.

The dead keys in Microsoft Windows worked perfectly for me but the Linux ones do not. Some characters are not available and are replaced by characters that don’t exist in the portuguese language.

In X11 I fixed this by using an .XCompose file with the keybinds just like in Windows. Source here, it works perfectly.

In Wayland, the .XCompose file works for pretty much all apps. Firefox is fine, kitty is fine, Vivaldi is fine. Unfortunately electron apps with the --ozone-platform-hint=wayland ignores the .XCompose file and I get the default keybinds. Since I own an nvidia card I really need these flags, otherwise the electron apps will aggressively flicker and/or eat letters while I’m typing.

I’ve searched far and wide, there are several open bugs in chromium, electron and wayland repositories. Everyone seems to be pointing fingers at each other for years and no workaround to make .XCompose work seems to be available.

I’m wondering if there is an alternative way to customize the dead keys under Wayland. Thanks in advance.

  • jntesteves@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    10 months ago

    I’m using GNOME Wayland on Fedora 39 and I don’t have the problem you describe. I just go to settings and select my keyboard layouts:

    • English (US, intl., with dead keys)
    • English (intl., with AltGr dead keys)

    And everything just works. I specially like the second one because it doesn’t interfere with keybindings in games, which can be a problem in GNOME Wayland.

    Oh, I think I get the issue you’re having, you can’t find the Çç character on the Linux layout 😅 I always have to explain this to people migrating from Windows, it’s AltGr+, (right Alt key plus Comma). I like this shortcut better than the Windows layout, but I understand some people might not like it. Unfortunately, I can’t answer your question, as I too don’t know how to customize the keyboard layout. I just got used to the Linux layout.

    • pathief@lemmy.worldOP
      link
      fedilink
      arrow-up
      4
      ·
      edit-2
      10 months ago

      Yes, I’m using the US international with dead keys layout. I also used it in Microsoft Windows. Here’s a couple of annoying examples:

      • ' + c-> result: ć; expectation: ç
      • ' + m -> result: ḿ; expectation: 'm (particularly annoying when typing in english; workaround: ' + space key + m)
      • ' + t -> result: nothing happens; expectation: 't (particularly annoying when typing in english; workaround: ' + space key + t)

      Right Alt + Comma does work for ç so at least I have that going for me. It’s still weird to have a different layout for electron apps :/

      • jntesteves@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        10 months ago

        You should be able to type ç the way I described for all apps, so you could just remove your custom layout. I highly recommend the English (intl., with AltGr dead keys) layout, it’s perfect for coding and writing in English. It’s a bit more work to write in Portuguese, though, so it took me a while to get used to it, but it’s worth it if coding is what you’re doing most of the time. In this layout, you must hold AltGr to get the dead keys, otherwise it’s a normal English layout.

        You can also use two layouts — one for English/coding, one for Portuguese — and the keyboard shortcut Super+Space to switch between them. I always have two layouts setup like this, but I never switch anymore because I just learned to love the English (intl., with AltGr dead keys) layout — and I use very little Portuguese nowadays.

        • pathief@lemmy.worldOP
          link
          fedilink
          arrow-up
          2
          ·
          10 months ago

          Thank you! It’s not exactly what I wanted but at this point I’m just happy to have a solid workaround to my problem that works everywhere.

  • Lupec@lemm.ee
    link
    fedilink
    arrow-up
    3
    ·
    10 months ago

    My situation is remarkably similar to yours down to the language, and I happen to have been considering a US keyboard as well so that’s disheartening to hear. I have nothing to add right now but will let you know if I come across anything helpful!

    • pathief@lemmy.worldOP
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      10 months ago

      I love US keyboards for coding, it really improves the experience. Typing in portuguese, however, is not a good experience. The default american layout has the ~ key in a really bad spot. Typing à or ã is REALLY uncomfortable/weird. Fortunately, my keyboard has that key on the right side of the keyboard instead of the left, which greatly improves the experience.

      The .XCompose file I linked in the main post is perfect and works great on X11. If you’re not yet on Wayland you can use it and have a great experience.

      • Lupec@lemm.ee
        link
        fedilink
        arrow-up
        2
        ·
        10 months ago

        Right, that all makes sense. I’ll definitely keep that .XCompose file in mind, wasn’t aware it even was a thing before your post. Also, do you mind sharing the specific keyboard you’re using for reference?

        Side note, I’ve started using vim/helix a few months ago and the pt layout makes things a lot more awkward than I expected, that’s half the reason I’m considering a US keyboard lol

        • pathief@lemmy.worldOP
          link
          fedilink
          arrow-up
          2
          ·
          10 months ago

          I’m using an Happy Hacking Keyboard Professional 2. Not most people’s cup of tea but I’ve grown used to it and it’s hard for me to swap to anything else now :P

          • Lupec@lemm.ee
            link
            fedilink
            arrow-up
            1
            ·
            10 months ago

            I can see why it’d be divisive with topre keys, no key markings and a pretty non standard layout but man does it look nice. Really appreciate what they’re going for there.

            Anyway, thanks and hope you find a solution, I’ll drop by if I come across anything useful!

  • pathief@lemmy.worldOP
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    10 months ago

    I’m very happy to report that I found a solution to the problem: keyd. It’s amazing.

    Instructions on the github project are crystal clear, but I’ll leave some instructions below for Arch Users

    yay -S keyd

    sudo systemctl enable keyd && sudo systemctl start keyd

    Now you can configure the /etc/keyd/default.conf file to your hearts desire. keyd is very feature rich, check the man page to see everything you can do. You can even add layers to your keyboard. Very sweet.

    My personal configuration so far (I will definitely expand it later when I bump into more problems)

    [ids]
    *
    
    [main]
    ' = oneshotm(apostrophe, ')
    
    [apostrophe]
    a = a
    b = macro(space backspace apostrophe space b)
    c = macro(backspace G-,)
    d = macro(space backspace apostrophe space d)
    e = e
    f = macro(space backspace apostrophe space f)
    g = macro(backspace apostrophe space g)
    h = macro(space backspace apostrophe space h)
    i = i
    j = macro(space backspace apostrophe space j)
    k = macro(backspace apostrophe space k)
    l = macro(backspace apostrophe space l)
    m = macro(backspace apostrophe space m)
    n = macro(backspace apostrophe space n)
    o = o
    p = macro(space backspace apostrophe space p)
    q = macro(space backspace apostrophe space q)
    r = macro(backspace apostrophe space r)
    s = macro(backspace apostrophe space s)
    t = macro(backspace apostrophe space t)
    u = u
    v = macro(space backspace apostrophe space v)
    w = macro(backspace apostrophe space w)
    x = macro(space backspace apostrophe space x)
    y = macro(backspace apostrophe space y)
    z = macro(backspace apostrophe space z)
    
    

    After editing /etc/keyd/default.conf make sure you run sudo keyd reload

  • Orac@feddit.nl
    link
    fedilink
    arrow-up
    1
    ·
    10 months ago

    Not an answer to you actual question, but: I stopped using dead keys long ago because I found it irritating to have to hit space whenever I needed to break out. Instead I mapped my CapsLock to be a Compose-key which lets me make almost any symbol I ever need in a very intuitive wsy. It works everywhere (incl. Wayland).

    • pathief@lemmy.worldOP
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      10 months ago

      I rarely had to hit space, honestly. My keyboard doesn’t have a key specifically for caps lock, a control key is there instead. I quite like it.

      I’ve been trying to make a switch for the compose key but it’s hard to kick decades-old muscle memory heh