houmain / keymapper

A cross-platform context-aware key remapper.
GNU General Public License v3.0
260 stars 22 forks source link

Mapping directly in context blocks #7

Closed Knyffen closed 2 years ago

Knyffen commented 2 years ago

In https://github.com/houmain/keymapper/issues/5 you referenced having enabled mapping directly in context blocks with the following example:

[system="Linux"]
A >> B
[system="Windows"]
A >> C

I've had trouble mapping the same reference twice, so my guess is that your example works specifically because you use separate operating systems.

To be more specific, while the old syntax works as intended

A >> tmp
[title="Firefox"]
tmp >> B
[title="Konsole"]
tmp >> C

the new syntax only registers the first occurrence

[title="Firefox"]
A >> B
[title="Konsole"]
A >> C

so A maps to B in Firefox, but is blocked everywhere else (including Konsole).

Regarding implementation, it might be worth keeping in mind an example such as

[title="Firefox"]
A >> B
[system="Linux"]
A >> C

where I would expect A being mapped to B in Firefox and to C everywhere else. This could maybe create trouble because of the overlap.

houmain commented 2 years ago

Thanks for the thorough report. It should be resolved with 23ad2c7cf254604d145f1d04e777afd73c06f6b1.

Azarattum commented 2 years ago

Thanks for the thorough report. It should be resolved with 23ad2c7.

Can confirm that it works as intended. Although a build error needed to be fixed https://github.com/houmain/keymapper/pull/10

Knyffen commented 2 years ago

For some reason I still can't make it work. :3

@Azarattum what is your setup/how do you make it work?

I still have exactly the same problem and I've double checked that if I change the order in the config, it works in Konsole and not in Firefox, so it shouldn't be a spelling mistake that is the cause.

And just to catch any stupid mistakes, I will explain how I installed it, if it turns out to be important. My first/old method was just reinstalling keymapper-git from AUR, which seems to fetch the newest version from the master branch. My second attempt, was to uninstall the AUR package, pull the git package with git clone git@github.com:houmain/keymapper.git, then create and start a root-level systemd service like

[Unit]
Description=Keymapper Daemon

[Service]
ExecStart=/home/knyffen/keymapper/keymapperd

[Install]
WantedBy=multi-user.target

and last, execute keymapper -u in userspace.

Azarattum commented 2 years ago

@Knyffen I compiled it from source on Windows. Worked fine for me on the first try. Haven't tested this particular feature on Linux yet.

Knyffen commented 2 years ago

Hmm, I guess it is Linux related then. I will try digging (but not today)

houmain commented 2 years ago

Yes, installing keymapper-git from the AUR installs the latest version. Maybe it could not replace the running executable? Only had this problem when I tried to manually copy the binaries to /usr/bin.

keymapper -h should currently output keymapper 1.5.0-27-g9ce6144.

Maybe in your second attempt, you started (an old) keymapper from /usr/bin, not the one from /home/knyffen/keymapper? Sorry, no idea otherwise.

Knyffen commented 2 years ago

So... uhm... I finally got around to debugging it again and it seems to just work... so nice, I guess. ;-) While it wasn't didn't show version g9ce6144, it did say 4849a95 which is after the relevant commit (23ad2c7) so that shouldn't have been the problem. Anyway, I just rebased and it works as intended, so I guess all is well. :)