myshov / xkbswitch-macosx

Console keyboard layout switcher for MacOS
218 stars 26 forks source link

Adding a new layout dynamically #9

Open mixn opened 6 years ago

mixn commented 6 years ago

This is a great and very useful tool, thank you for taking the time to create it! 👏😊

I was wondering if it would be useful/possible to allow adding a new layout dynamically, e.g.:

xkbswitch -se German

would then result in it being available and set.

screen shot 2018-09-04 at 12 33 57

Instead of getting this message (which totally makes sense, of course):

There is no active layout with name in the default prefix "German"
Trying with the org.unknown.keylayout prefix...
Unable to find an active layout with this name.

I think this would be a great addition since it’d really help with setting up preferred languages in dotfiles. I was/am trying to configure German/Serbian-Latin as my two only keyboard layouts by default and struggled finding a command-line-based solution that wasn’t too hacky. This tool is super clean but only allows for switching/reading, not adding.

Of course, it wouldn’t have to be via -se, it could also be done with its own flag, as long as it allows dynamically adding things. 🙂

I wonder if this feature hasn’t been implemented because of restrictions or something?

Would be a w e s o m e. 🤓

Thanks and let me know if I can help somehow. :)

myshov commented 6 years ago

@mixn hi! Thank you for your interest in my project!

I was wondering if it would be useful/possible to allow adding a new layout dynamically

I was thinking about it some time ago. The solution is to read the list of all available layouts in macOS at runtime. And actually, this feature has one of the biggest priorities for further development of xkbswitch.