Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring HS to always use a specific keyboard layout #2378

Open
roeybiran opened this issue May 30, 2020 · 3 comments
Open

Configuring HS to always use a specific keyboard layout #2378

roeybiran opened this issue May 30, 2020 · 3 comments

Comments

@roeybiran
Copy link

roeybiran commented May 30, 2020

Hello!

I’m using two keyboard layouts on my Mac. The main one is English, and all of my Hammerspoon keybindings are specified using English letters. When I switch to the non-English layout and invoke one of the keybindings — it works, but the console shows this:
2020-05-30 13:03:50: 13:03:50 ** Warning:hs.keycode: key 'l' not found in active keymap; using ANSI-standard US keyboard layout as fallback, returning '37’
To me, keybindings being oblivious to the current layout is definitely the desired behavior. However, I was wondering if there's a way to configure HS to always the ANSI-standard US keyboard layout, or, at least, silence those warnings?

Thanks!

@latenitefilms
Copy link
Contributor

latenitefilms commented May 30, 2020

Try:

hs.keycodes.log:setLogLevel("error")

See hs.logger for more information.

@roeybiran
Copy link
Author

Hi @latenitefilms, thanks for the reply!
I pasted into the console precisely what you wrote, and I’m getting the weirdest bug:

loglevel must be a string or a number
stack traceback:
	[C]: in function 'error'
	...oon.app/Contents/Resources/extensions/hs/logger/init.lua:19: in upvalue 'toLogLevel'
	...oon.app/Contents/Resources/extensions/hs/logger/init.lua:236: in function <...oon.app/Contents/Resources/extensions/hs/logger/init.lua:236>
	(...tail calls...)
	[C]: in function 'xpcall'
	...app/Contents/Resources/extensions/hs/_coresetup/init.lua:467: in function <...app/Contents/Resources/extensions/hs/_coresetup/init.lua:447>

Putting a number instead of a string doesn’t help either.

Anyway, regardless of being able to silence those messages, I was hoping to just tell HS to use a specific layout and avoid the overhead involved with looking for the missing keys (but, perhaps, it isn’t possible and there’s no overhead in the first place?).

Thanks!

@latenitefilms
Copy link
Contributor

Opps, my bad - try:

hs.keycodes.log.setLogLevel("error")

The reason why is explained here:

the logger instance created by this method is not a regular object, but a plain table with "static" functions; therefore, do not use the colon syntax for so-called "methods" in this module (as in mylogger:setLogLevel(3)); you must instead use the regular dot syntax: mylogger.setLogLevel(3)

Regarding:

I was hoping to just tell HS to use a specific layout and avoid the overhead involved with looking for the missing keys (but, perhaps, it isn’t possible and there’s no overhead in the first place?).

To be honest, I'm not sure off the top of my head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants