houmain / keymapper

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

request: flag to allow changing config file #135

Closed kbilsted closed 2 months ago

kbilsted commented 2 months ago

Many times a day i switch config file - it would be great with a command line flag that allows changing the config rather than telling me an instance is already running ;)

ristomatti commented 2 months ago

How about just make a script to do this.

Strategies:

ristomatti commented 2 months ago

Based on a quick search, on Windows you should be able to do taskkill /F /IM keymapper.exe /T in a script. If the config files are static, perhaps you could swap them using a keybinding done in Keymapper itself? :grin:

If I needed to do that, I'd make ~/.config/keymapper.conf a symlink, then replace it with e.g.

Meta{F1} >> $(ln -sf path_to_config_a.conf ~/.config/keymapper.conf)
Meta{F2} >> $(ln -sf path_to_config_b.conf ~/.config/keymapper.conf)
kbilsted commented 2 months ago

Many thanks those a good work arounds. Id still prefer the tool to support it if easy to implement;)

ristomatti commented 2 months ago

I find it a bit unconventional for a running app to replace itself. Either you allow running multiple instances at the same time or not.

If @houmain likes the idea, I'd suggest this would feel more intuitive/correct if it were done through keymapperctl:

keymapperctl --replace-config <file>

Alternative verbs: set, swap, change. I think it should convey the running config will get flushed. Using keymapperctl would also avoid having to think if the --update or --verbose should be handled.

kbilsted commented 2 months ago

Yes its a matter of how portable it should be.. how many scripts etc to drag around.. anyway its just an idea :-)

houmain commented 2 months ago

I will try to add a keymapperctl --set-config <file>. I intend to keep the configurations in the cache, so they do not have to be parsed again and can be switched quickly.

kbilsted commented 2 months ago

parsing delay is not something I've noticed at all!

houmain commented 2 months ago

This is available in 4.1.3 and a really cool feature. Now I can quickly switch between my own configuration and the ones others want me to try out. Thanks!

kbilsted commented 2 months ago

Great

ristomatti commented 2 months ago

This is actually really convenient. Especially when combined with the new tray icon.

I just swapped the config to the repro on #138, but could not open an editor with the remapped keys. No problem, just disable the mappings from the tray icon, start the editor for testing and re-enable Keymapper.

ristomatti commented 2 months ago

While reverting back to my original config after doing the above, I noticed a small bug. To be able to type the path of the default config, I disabled Keymapper from the tray icon. This reversed the behavior of the tray icon. When the toggle is enabled, my config loads and vice versa.