-
Notifications
You must be signed in to change notification settings - Fork 594
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
adds hs.hotkey.assigned #1444
adds hs.hotkey.assigned #1444
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1444 +/- ##
==========================================
- Coverage 23.65% 23.63% -0.02%
==========================================
Files 127 129 +2
Lines 23686 23896 +210
Branches 2813 2838 +25
==========================================
+ Hits 5602 5649 +47
- Misses 17726 17881 +155
- Partials 358 366 +8 |
I don't have any objections, but I wonder if this could be implemented as a wrapper around |
@cmsj, as noted above, just because this function returns a table doesn't reliably determine whether or not Hammerspoon can override it. If this function returns Since Hamemrspoon can over-ride some of the combinations this returns a table for, do we really want to prevent it? And if we do add the check, how many existing user setups will break because of it? At the very least, if you do want the check added, there should be someway to tell |
@asmagill I didn't mean that we would bake this check into .new()/.bind(), more that .assigned() (or maybe .isAvailable() ?) would call .new() and see if it works or not, unbinding it if it did work. |
Because of the heavy additions made to hotkey.isAssignable = function(...)
local k = hotkey.new(...)
local prevLevel = hs.luaSkinLog.level
-- supress luaSkinLog error if binding fails
hs.luaSkinLog.level = 0
local status = k._hk:enable()
if status then k._hk:disable() end
hs.luaSkinLog.level = prevLevel
return status and true or false
end Should this be added instead? Or are both worth having? The earlier version could still be used to determine if the OS is using the hotkey combination -- just because someone can override some of these doesn't necessarily mean that they will want to. |
@asmagill yeah that's the kind of thing I meant :) |
Unless you object, I'm going to move the function which checks against system definitions to Should |
@asmagill hmm, that's a tough one. I think returning nil would definitely be more correct, but nobody is going to be checking the return type, so it might make a lot of things explode. I think it's probably better to move the API towards being useful though, so let's try it and see what happens :D |
If you really want to suppress the messages no matter what, either check with local prevLevel = hs.luaSkinLog.level
hs.luaSkinLog.level = 0
-- do hotkey assignments as usual
hs.luaSkinLog.level = prevLevel Note that in the future, it is hoped that these will be sent to a |
sort of addresses #1391
This isn't really a conclusive test (for example, both
Cmd-F5
andCtrl-1
are defined on my system and will return a table with this function; however, if I create a Hammerspoon hotkey forCmd-F5
, it works, while a Hammerspoon hotkey forCtrl-1
fails.)What's the group consensus? It's useful to see if you're trying to overwrite a system hotkey, but... it isn't a reliable way to tell if you can or not.