Skip to content

Instantly share code, notes, and snippets.

@supersational
Created December 13, 2023 13:13
Show Gist options
  • Save supersational/b3a59bb688c9cd551f7a24708ae5653c to your computer and use it in GitHub Desktop.
Save supersational/b3a59bb688c9cd551f7a24708ae5653c to your computer and use it in GitHub Desktop.
Hammerspoon unminimise shortcut
-- cmd + alt + m uniminimses last minimised app
hs.hotkey.bind({ "cmd", "alt" }, "m", function()
local script = [[
tell application "System Events" to tell process "Dock"
set dockUIElements to UI elements of list 1
repeat with i from (count dockUIElements) to 1 by -1
set anElement to item i of dockUIElements
if ((role description of anElement) as string) is equal to "minimised window dock item" then
click anElement
exit repeat
end if
end repeat
end tell
]]
-- show alert and dismiss when done running script
local alertID = hs.alert('unminimizing')
-- use hs.task to avoid blocking main thread
hs.task.new("/usr/bin/osascript", function()
hs.alert.closeSpecific(alertID)
end, function() return true end, { '-e', script }):start()
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment