Assign every window and empty rectangle a sigil for quick access.
A letter or digit is rendered in the titlebar of every window (or empty space), and actions can be bound inside the sigil mode and triggered with different modifiers.
For example, with no modifiers, a sigil key can focus the window. If the 'enter' action is bound to control-w, then 'control-w c' will focus the window with sigil 'c'. The action is a function which accepts a window, or in the case of an empty space, a window-like object which reponds to 'id', 'frame', and 'setFrame'.
The keys 'h', 'j', 'k', and 'l' are reserved for the window west, south, north, and east of the currently focused window in standard Vi-like fashion, and so are not assigned as sigils.
By default, two keys (other than the sigils) are bound in the mode: escape leaves the mode without doing anything, and '.' sends the sigil key to the focused window. This allows sending 'control-w' to the underlying window by typing 'control-w .'.
Download: https://github.com/Hammerspoon/Spoons/raw/master/Spoons/WindowSigils.spoon.zip
Usage example:
local function ignore_notification()
-- ...
end
local function paste_as_keystrokes()
hs.eventtap.keyStrokes(hs.pasteboard.readString())
end
local function rerun_last_command()
hs.execute("kitty @ --to unix:/Users/jfelice/.run/kitty send-text --match=title:kak_repl_window '\x10\x0d'", true)
end
local function focus_window(window)
window:focus()
if hs.window.focusedWindow() ~= window then
-- Some cases with apps having windows on multiple monitors require
-- us to try again (?)
window:focus()
end
end
local function swap_window(window)
local focused_frame = hs.window.focusedWindow():frame()
local selected_frame = window:frame()
hs.window.focusedWindow():setFrame(selected_frame, 0)
window:setFrame(focused_frame, 0)
end
local function stack_window(window)
local frame = window:frame()
hs.window.focusedWindow():setFrame(frame, 0)
end
sigils = hs.loadSpoon("WindowSigils")
sigils:configure({
hotkeys = {
enter = {{"control"}, "W"}
},
mode_keys = {
[{{'shift'}, 'i'}] = ignore_notification,
[{{}, 'v'}] = paste_as_keystrokes,
[{{}, ','}] = rerun_last_command,
},
sigil_actions = {
[{}] = focus_window,
[{'ctrl'}] = stack_window,
[{'alt'}] = swap_window,
}
})
sigils:start()
Signature | WindowSigils.logger |
---|---|
Type | Variable |
Description | Logger object used within the Spoon. Can be accessed to set the default log level for the messages coming from the Spoon. |
Source | Source/WindowSigils.spoon/init.lua line 88 |
Signature | WindowSigils:bindHotkeys(mapping) |
---|---|
Type | Method |
Description | Binds hotkeys for WindowSigils |
Parameters |
|
Returns | |
Source | Source/WindowSigils.spoon/init.lua line 99 |
Signature | WindowSigils:bindModeKey(mods, key, action) |
---|---|
Type | Method |
Description | Bind an extra action to be triggered by a key in the sigil mode. |
Parameters |
|
Returns | |
Source | Source/WindowSigils.spoon/init.lua line 149 |
Signature | WindowSigils:bindSigilAction(mods, action) |
---|---|
Type | Method |
Description | Bind an action to be triggered in the sigil mode when a window's sigil key is pressed. |
Parameters |
|
Returns | |
Source | Source/WindowSigils.spoon/init.lua line 175 |
Signature | WindowSigils:configure(configuration) |
---|---|
Type | Method |
Description | Configures the spoon. |
Parameters |
|
Returns | |
Source | Source/WindowSigils.spoon/init.lua line 120 |
Signature | WindowSigils:orderedWindows() |
---|---|
Type | Method |
Description | A list of windows, in the order sigils are assigned. |
Parameters |
|
Returns | |
Source | Source/WindowSigils.spoon/init.lua line 279 |
Signature | WindowSigils:refresh() |
---|---|
Type | Method |
Description | Rerender all window sigils. |
Parameters |
|
Returns | |
Source | Source/WindowSigils.spoon/init.lua line 411 |
Signature | WindowSigils:start() |
---|---|
Type | Method |
Description | Starts rendering the sigils and handling hotkeys |
Parameters |
|
Returns | |
Source | Source/WindowSigils.spoon/init.lua line 200 |
Signature | WindowSigils:stop() |
---|---|
Type | Method |
Description | Stops rendering the sigils and handling hotkeys |
Parameters |
|
Returns | |
Source | Source/WindowSigils.spoon/init.lua line 237 |
Signature | WindowSigils:window(sigil) |
---|---|
Type | Method |
Description | Find the window with the given index or sigil. |
Parameters |
|
Returns | |
Source | Source/WindowSigils.spoon/init.lua line 302 |