Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module hyprland/language cannot be configured to be usable #2072

Open
alerque opened this issue Mar 28, 2023 · 6 comments
Open

Module hyprland/language cannot be configured to be usable #2072

alerque opened this issue Mar 28, 2023 · 6 comments

Comments

@alerque
Copy link
Contributor

alerque commented Mar 28, 2023

I started trying to configure the hyprland/language module and came up absolutely flat. The only string I can get out of it is the full long description from the keyboard layout, and that is useless

  • For two of the layouts I use it is so long as to take up half the bar
  • It includes spaces, dashes, and other characters that I can't seem to match in the config so I can't even add a per-layout override in the config file
  • There is no short option as in the sway equivalent
  • There is no flag option as in the sway equivalent

The final output I want is a flag, but the flag option probably won't help me even if implemented correctly because, for example, I want the Kazakh flag for my Russian layout. What I really need I think is just the short identifier used to set the layout in the first place. That's a simple code I can use in the config to add custom label string per-layout.

I looked into fixing it myself, but the C++ involved is going to be out of my league especially considering the comparable Sway module is also reported not to work properly so I can't just copy bits (#1501, #1909, #1536)

@alerque alerque changed the title Module hypeland/language cannot be configured to be usable Module hyprland/language cannot be configured to be usable Mar 28, 2023
@alerque
Copy link
Contributor Author

alerque commented Mar 28, 2023

Just a little more info looking into this, lets take one of my layouts as an example: My dvp layout (that's the short key used to set it, whether with setxkbmap or hyprctl) reports its full name as "USA - Programmer Dvorak`.

Since there are no options other than {} for the format string that's the only string I have to work with, but the format-* key that could be used to customize this is using the "brief" name behind the scenes. The brief layout is always being reported as an empty string by the hyprland/language module.

I can actually change the string with this:

        "format-": "DVP",

But that of course changes it for all of my layouts because they all parse to an empty string for brief.

@jficz
Copy link

jficz commented Sep 27, 2023

I ended up using a custom module with a very stupid script instead of the language module:

#!/bin/sh
echo "?"
nc -U /home/user/tmp/.hypr2.sock | while IFS='>,' read event noop dev layout; do
  if [ "$event" = "activelayout" ]; then
    case "$layout" in
      Czech*) echo "🇨🇿";;
      English*) echo "🇺🇸";;
    esac
  fi
done

it requires the hyprland ipc socket2 to be available at ~/tmp/.hypr2.sock (I link it there from the default location by other script). It could probably leverage IPC from waybar somehow but I haven't investigated that far, this works for me (tm)

@alerque
Copy link
Contributor Author

alerque commented Sep 27, 2023

Thanks for the hack. I might cobble something together for my use case too because this still isn't fixed and the status-quo is not usable in the slightest.

@dann-merlin
Copy link

This works for me:

    "hyprland/language": {
        "format": "{}",
        "format-en": "🇺🇸",
        "format-de": "🇩🇪",
    },

@jficz
Copy link

jficz commented Jun 21, 2024

So my ugly script stopped working some time ago so I gave the module a chance again and managed to configure it to behave as I want it to using this settings:

    "hyprland/language": {
      "format": "{}",
      "format-cs": "🇨🇿",
      "format-en": "🇺🇸",
      "keyboard-name": "at-translated-set-2-keyboard"
    },

Not sure if the keyboar-name key is needed and I had hard time figuring out the "short suffix" after format-. It's confusing, in hyprland config I've got us,cz(sic!)* layout but here for some reason I must use en for the US layout. Found out basically by trial and error :/

Maybe this is now more of a documentation issue? It would help to update the wiki, adding a way to find out what the "short" name for a layout is - I couldn't find it anywhere.

*) in fact my layouts in hyprland config are us_insert,cz_insert because I've got some custom key mapping. Which makes things even more confusing...

@alerque
Copy link
Contributor Author

alerque commented Jun 22, 2024

@jficz I've had the same issue with trial and error. I noticed after your comment that using waybar --log-level debug will show the correct matching keyboard name to use, but not the right short code to use in the language. I added some more debug outputs (and hence identified that my bespoke keyboard layouts don't even have short codes) that show a lot more about what is going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants