Created
January 6, 2026 15:56
-
-
Save dmgerman/efb6bf40e9dc106700a41cb70edb95dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| windowKeys = {} | |
| function wkeys_prompt_for_key() | |
| local w = hs.window.focusedWindow() | |
| local result = nil | |
| hs.application.get("Hammerspoon"):activate() | |
| local button, text = hs.dialog.textPrompt("Input number key", "Please enter a single numeric character:", "", "OK", "Cancel") | |
| if button == "OK" then | |
| result = text | |
| end | |
| if w then | |
| w:focus() | |
| end | |
| return result | |
| end | |
| function wkeys_attach_current_window_to_key() | |
| local w = hs.window.focusedWindow() | |
| if (w) then | |
| local key = wkeys_prompt_for_key() | |
| if key and tonumber(key) then | |
| print(string.format("key [%s]", key)) | |
| dmg_alert(string.format("attach key [%s] to window [%s]", key, w:title())) | |
| hs.hotkey.bind( | |
| {'alt'}, key, | |
| function () w:focus() end) | |
| else | |
| dmg_alert(string.format("Illegal key to attach a window [%s]", key)) | |
| end | |
| end | |
| end | |
| hs.hotkey.bind( | |
| {'alt'}, '0', | |
| function () wkeys_attach_current_window_to_key() end) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment