linuxmint / cinnamon

A Linux desktop featuring a traditional layout, built from modern technology and introducing brand new innovative features.
GNU General Public License v2.0
4.49k stars 730 forks source link

Add checkbox/option to make keyboard layouts, which are in evdev.extras.xml, accessible from the keyboard layouts GUI #5697

Closed NikoKrause closed 6 years ago

NikoKrause commented 8 years ago

Hey,

there are some keyboard layouts defined in /usr/share/X11/xkb/rules/base.extras.xml respectively /usr/share/X11/xkb/rules/evdev.extras.xml But I can't find them under the keyboard settings. Is there a way to get them?

Here's a definition of what the base.extras.xml file is for (https://www.freedesktop.org/wiki/Software/XKeyboardConfig/Rules/)

For the layouts/variants that are "exotic", it is recommended to use base.extras.xml.in instead of base.xml.in. The word "exotic" is used in statistical sense only.

There is no formal definition of "exotic", because in most cases it is not possible to prove the actual number of users. There are several "usual suspects" for the "exotic" section:

The layouts for endangered/extinct languages/scripts. The statistics can be taken from http://www.ethnologue.com/. The potential candidates are languages with <100K speakers. If the number of speakers is <10K, the language most probably belongs to "extras"

The languages that are used most frequently with layouts made for other languages. If most of the texts using the language L1 are typed using layouts made for L2 (more popular), the own layout for L1 may be considered as exotic, even if the language L1 itself is popular. That is the a possible scenario for national minorities using the languages with the alphabet similar to the alphabet used by the language of the larger nation in the same country.

The exotic layouts for popular languages. If some relatively small group of people are using some variant suitable for their needs. Typical examples: variants for programmers, for typography, for particular group of sciences, for sacred texts etc.

That's typical, but not the only possible scenarios for putting layout/variants into the "extras" section.

The maintainer of xkeyboard-config typically questions the popularity of newly submitted layouts/variants. If no conclusive proof of number of users is provided, the layout can be put into the extras section (the maintainer reserves that right).

Putting layout/variant into the extras section is just a representation of the fact that layout is not popular enough to be included into the main section. The GUI tools can use any approach to displaying (or not displaying) "extras" - this issue is out of scope of xkeyboard-config.

JosephMcc commented 7 years ago

This isn't really a support forum for these types of questions. You would be better off looking for help in the forums, on #linuxmint-help or maybe even #linuxmint-dev on IRC. If you would like them to be accessible from the keyboard layouts GUI, fix your title to represent that and I'll mark it as a feature request.

NikoKrause commented 7 years ago

So I discussed this feature request with @clefebvre on IRC. To make the work easier for people, who (in the far far future) are willing to try to implement this, I'll post a copy of our conversation, so they can benefit from the findings regarding this problem:

IRC (irc.spotchat.org #linuxmint-dev) chat with Clem about extra keyboard layouts in Cinnamon:

{NikoKrause} I have a question about keyboard layouts gui. There is a file "/usr/share/X11/xkb/rules/base.extras.xml", which has extra layouts and which aren't shown in the gui. I tried gsettings set org.gnome.desktop.input-sources show-all-sources true and gsettings set org.cinnamon.desktop.input-sources show-all-sources true, but still nothing in the GUI. Is there a command, which tells the keyboard layout GUI to update the layouts?

{clem} hi NikoKrause {clem} it should be org.cinnamon.desktop.input-sources show-all-sources false

{NikoKrause} clem: But the layouts in base.extras.xml still don't show up.

{clem} NikoKrause: check the source {clem} NikoKrause: you know where the settings are in github?

{NikoKrause} No, where? {NikoKrause} to you mean cs_keyboard.py {NikoKrause} Do you mean cs_keyboard.py?

{clem} NikoKrause: yes, hold on {clem} there are two kinds of configuration modules {clem} at the beginning Cinnamon started as a fork of GNOME {clem} so the settings were in C and part of cinnamon-control-center {clem} it is still the case for some of them: https://github.com/linuxmint/cinnamon-control-center/tree/master/panels {clem} network, display etc.. for instance {clem} most of them were rewritten from scratch in Python though and they're now part of cinnamon itself {clem} https://github.com/linuxmint/Cinnamon/tree/master/files/usr/share/cinnamon/cinnamon-settings/modules {clem} the keyboard one as you said is cs_keyboard.py https://github.com/linuxmint/Cinnamon/blob/master/files/usr/share/cinnamon/cinnamon-settings/modules/cs_keyboard.py {clem} as you can see it doesn't use show-all-sources

{NikoKrause} So at the time, there is no chance to get the extra layouts?

{clem} no {clem} looking at gnome-control-center, I can see it mentioned in their NEWS/Changelog, but not in their code {clem} looking at our code, it looks like cs_keyboard.py also uses ccc's region panel {clem} https://github.com/linuxmint/cinnamon-control-center/tree/master/panels/region

{NikoKrause} I think it won't be easy to implement that

{clem} could be an option in xkb somewhere, I don't know

{NikoKrause} Yeah, I asked the xkb guy Sergey Udaltsov a while ago. He offers the extras files, how to get them is the problem of the OS respectively the userinterface. "Could you please open a bug on Ubuntu so they would provide a way to list layouts from extras? May be there is one already." {NikoKrause} That was his response {NikoKrause} Thanks for your help anyway

{clem} NikoKrause: did you tell him you were a developer?

{NikoKrause} No. I created two layouts and wanted them to be in base.xml, but he wanted it to be in base.extras.xml. That's totally pointless for me, if there is no way to use them. {NikoKrause} clem: The extras layouts problem isn't only a problem in Cinnamon. I think it's in Ubuntu too. And probably more Linux derivatives. At least I get the layouts working in LinuxMint and Ubuntu, when I'm copying them from base.extras.xml into base.xml. In ElementaryOS even this way doesn't work. I think that's a general problem of XKB. I see the point why there is an extras file for layouts, which aren't used by many people. But {NikoKrause} the lack of support of getting this layouts activated, if wanted, makes the whole effort pointless. At least in my eyes.

{clem} NikoKrause: which part of the code reads that xml file though? {clem} base.xml I mean {clem} isn't that internal to the xkb library?

{NikoKrause} I think it's the same as evdev.xml {NikoKrause} clem: I looked into it. base.extras.xml and evdev.extras.xml are the same {NikoKrause} The same holds for evdev.xml and base.xml

{clem} NikoKrause: yes but I mean... we don't read base.xml in cinnamon, we ask xbk to give a list of layouts, right? {clem} if we can tell xkb to also read the extra file, say by specifying an argument or clalling xkb a different way, we can consider it {clem} otherwise it's an xbk issue {clem} xkb sorry

{NikoKrause} I don't now how xkb is calling evdev.xml? It's mentioned here: https://github.com/linuxmint/cinnamon-desktop/blob/2b56f69d10c9036283880ed3f3e3223931f849a5/libcinnamon-desktop/gnome-xkb-info.c {NikoKrause} XKB_RULES_FILE "evdev"

{clem} NikoKrause: you're onto something here.. {clem} here we specify evdev.xml ourselves https://github.com/linuxmint/cinnamon-desktop/blob/2b56f69d10c9036283880ed3f3e3223931f849a5/libcinnamon-desktop/gnome-xkb-info.c#L573 {clem} and a few lines later we look at org.gnome.desktop.input-sources show-all-sources {clem} if that's true we go on looking for evdev.extras.xml {clem} line 585

{NikoKrause} Sorry for misunderstanding. I talked about base.xml, but actually it's evdev.xml. I thought it makes no difference, because the content is the same. I looked into my layout files. I put them into evdev.xml. Not base.xml

{clem} looking at the code, it looks like setting org.gnome.desktop.input-sources show-all-sources should be enough to parse evdev.extras.xml {clem} I'm not sure that's called though..

{NikoKrause} I tried setting that true. But it had no effect for me

{clem} it doesn't look like the region panel in ccc is using cinnamon-destkop's gnome-xkb {clem} omg, the code is awful :)

{NikoKrause} :)

{clem} it looks like we're getting the layouts from libxklavier {clem} https://github.com/linuxmint/cinnamon-control-center/blob/master/panels/region/cinnamon-region-panel-xkbltadd.c#L442 {clem} I'd be happy to put all that in the bin if you ask me, and rewrite it in python using cinnamon-desktop's gnome-kbd API {clem} it's a lot of work though

{NikoKrause} I had no intention to make you so much work. It's not something that is important. I just came here with the hope, that an easy gsettings command would do the trick. {NikoKrause} If you nevertheless consider in the far far future (Mint 19, 20 or 21 ;) to rewrite it, please keep the extras in mind. {NikoKrause} For me I can live with the workaround. I just copy the layouts from evdev.extras.xml into evdev.xml.

{NikoKrause} There is already an Issue report on Github I made some time ago: https://github.com/linuxmint/Cinnamon/issues/5697

{clem} yes, I never looked into it {clem} I wouldn't fix it personally {clem} I usually encourage modules to be rewritten from scratch

{NikoKrause} Should I add this conversation as a reminder for the future?

{clem} there's only a few left which are still in C and inherited from gnome-control-center {clem} yes if you want

marmistrz commented 7 years ago

Under Arch, Polish Colemak resides under: /usr/share/X11/xkb/symbols/pl and /usr/share/X11/xkb/rules/{base,evdev}.extras.xml

// Polish Colemak
// by Tomek Piotrowski <>
//
partial alphanumeric_keys
xkb_symbols "colemak" {
    include "us(colemak)"
    name[Group1]= "Polish (Colemak)";

    key <AB01> { [            z,            Z,       zabovedot,        Zabovedot ] };
    key <AB02> { [            x,            X,          zacute,           Zacute ] };
    key <AB03> { [            c,            C,          cacute,           Cacute ] };
    key <AC01> { [            a,            A,         aogonek,          Aogonek ] };
    key <AC03> { [            s,            S,          sacute,           Sacute ] };
    key <AC07> { [            n,            N,          nacute,           Nacute ] };
    key <AC08> { [            e,            E,         eogonek,          Eogonek ] };
    key <AC10> { [            o,            O,          oacute,           Oacute ] };
    key <AD07> { [            l,            L,         lstroke,          Lstroke ] };

    include "level3(ralt_switch)"
};

Unfortunately, it's not shown by the keyboards layout selection dialog. KDE detects it, OTOH.

marmistrz commented 7 years ago

A workaround right now. I copy-pasted the following section

        <variant>
          <configItem>
            <name>colemak</name>
            <description>Polish (Colemak)</description>
          </configItem>
        </variant>

into the relevant <variantList> in base.xml and evdev.xml. Now the layout is detected (no surprise).

I guess patching only evdev.xml would suffice, right?

NikoKrause commented 6 years ago

The solution is:

gsettings get org.gnome.libgnomekbd.desktop load-extra-items 
NikoKrause commented 6 years ago

Please add a checkbox to set this key in Cinnamon keyboard layout settings.

JosephMcc commented 6 years ago

Many thanks for contributing to Cinnamon. Your suggestion was reviewed.

For more information on our workflow and feature requests, read https://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/faq.html.

mtwebster commented 6 years ago

https://github.com/linuxmint/cinnamon-control-center/commit/d961517fd248f62dc1dc8040731c48822dd68891