39aldo39 / klfc

Keyboard Layout Files Creator
GNU General Public License v3.0
216 stars 12 forks source link

understanding the customDeadKeys entry #6

Closed ninrod closed 7 years ago

ninrod commented 7 years ago

hi @39aldo39,

I'm trying to fix the cedilla (ć) in my custom layout using klfc. For this I'm trying to use the customDeadKeys entry, like so:

$ klfc --from-json qwerty.json deadkeys.json --xkb $DIST

qwerty.json is just a standard qwerty layout. deadkeys.json is as follows:

{
  "singletonKeys": [
    ["Alt_R", "Control"],
    ["CapsLock", "Escape"]
  ],
  "shiftlevels": [ "None", "Shift" ],
  "customDeadKeys": [
    {
      "name": "cedilhaFix",
      "baseChar": "'",
      "stringMap": ["c", "ç"]
    }
  ],
  "keys": [
    { "pos": "~", "letters": [ "grave", "tilde" ] },
    { "pos": "6", "letters": [ "6", "circumflex" ] },
    { "pos": "'", "letters": [ "acute", "\"" ] }
  ]
}

I'm getting the error:

  klfc: parse fail in deadkeys.json: Error in $.customDeadKeys[0].stringMap[0]: expected (a, b), encountered String

but I cannot pinpoint my error following the documentation. Am I doing something wrong or maybe this is a bug?

I'm using the version that comes with the AUR as of 2017.07.20

thanks in advance for any help

39aldo39 commented 7 years ago

The error message says that there is a type error in $.customDeadKeys[0].stringMap[0]. The first element of "customDeadKeys" is the dead key "cedlhaFix" and the first element of "stringMap" is "c". It expects a tuple, but the "c" is a string. This is because "stringMap" contains a list of tuples, not just one tuple. You just need to add one more pair of square brackets. (See altgr_colemak.json for example.) You also need to reference to the custom dead key, so you probably want to replace acute with cdk:cedilhaFix.

ninrod commented 7 years ago

Ah! yes I forget the tuples.

Ok, so instead of writing "baseChar": "'",, as I configured ' to be my deadkey acute, I need to really write baseChar: "acute". Is that what you are saying?

39aldo39 commented 7 years ago

No, your file should look like

{
  "singletonKeys": [
    ["Alt_R", "Control"],
    ["CapsLock", "Escape"]
  ],
  "shiftlevels": [ "None", "Shift" ],
  "customDeadKeys": [
    {
      "name": "cedilhaFix",
      "baseChar": "'",
      "stringMap": [
        ["c", "ç"]
      ]
    }
  ],
  "keys": [
    { "pos": "~", "letters": [ "grave", "tilde" ] },
    { "pos": "6", "letters": [ "6", "circumflex" ] },
    { "pos": "'", "letters": [ "cdk:cedilhaFix", "\"" ] }
  ]
}
ninrod commented 7 years ago

Ah, yes! Perfect. Will test that.

ninrod commented 7 years ago

@39aldo39, this configuration actually breaks composing ' + c. With the above configuration you posted, if I run the generated dist/run-session.sh and then fireup google-chrome, the acute ' char does not behave as a deadkey: ' + c = 'c. If I change the cdk:cedilhaFix to acute, then it starts working again. But it generates a ć and not a ç as I wanted.

Also, the configuration portrayed in altgr_colemak does not use a baseChar field in the customDeadKeys entry. How does klfc knows what deadkey will produce the designed combinations?

Hum, am I wonder what am I doing wrong.

39aldo39 commented 7 years ago

The custom dead key does not work in Chrome because it uses GTK. It should work in xterm. By default, GTK uses a hard-coded Compose file and ignores custom ones. You need to add export GTK_IM_MODULE=xim to ~/.profile or ~/.bash_profile to make it work. See this KDE page.

Furthermore, a custom dead key creates a completely new dead key. It basically makes the baseChar a new dead key. So, in your case it will make acute a new dead key, which is different from the existing dead key dead_acute. Currently, it cannot based of an existing dead key, although I may add as a possibility. It is also possible to omit baseChar, in that case a Unicode character from the private use area is used.

ninrod commented 7 years ago

hum, no success with the GTK_IM_MODULE hack. I tried the profile, bash_profile and even the /etc/environment aproach. my st terminal is behaving nicely though: ' + c produces ç. EDIT: update, adding these lines to /etc/environment solves the problem:

GTK_IM_MODULE=cedilla
QT_IM_MODULE=cedilla

EDIT2: I was wrong: do not use the cedilla module hack above as it breaks programs like thunar, darktable and inkscape. See the comments below.

Just to be sure: when klfc generates the dist folder, I have to execute both the install_system.sh script and the install_xcompose.sh script, right?

39aldo39 commented 7 years ago

It's weird that setting GTK_IM_MODULE to xim doesn't work. Setting it to cedilla does solve this case, but it doesn't if you want to add more bindings.

And yes, you have to execute both install-system.sh (as root) and install-xcompose.sh (as user). When you run install-system.sh as root, it will tell you to also execute install-xcompose.sh as user.

ninrod commented 7 years ago

@39aldo39, actually I was plain wrong: the GTK_IM_MODULE=xim does fix the problem perfectly: I thought that restarting the x server was sufficient, but I had to actually reboot my machine for the new environment settings to kick in. Sorry for the confusion.

I believe the issue is settled, then. Thanks so much for all your help and for the program.