Add hs.application.hideOtherApplications() function#3863
Open
jake-edmonstone wants to merge 1 commit intoHammerspoon:masterfrom
Open
Add hs.application.hideOtherApplications() function#3863jake-edmonstone wants to merge 1 commit intoHammerspoon:masterfrom
hs.application.hideOtherApplications() function#3863jake-edmonstone wants to merge 1 commit intoHammerspoon:masterfrom
Conversation
Add a module-level function that hides all applications other than the frontmost one by calling `[[NSWorkspace sharedWorkspace] hideOtherApplications]`. This is the programmatic equivalent of Cmd+Opt+H (Hide Others) and provides a direct API for window management workflows that need to isolate a single application, without resorting to keystroke simulation via `hs.eventtap` or iterating all running applications.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
hs.application.hideOtherApplications()— a module-level function that hides all applications other than the frontmost one.This calls
[[NSWorkspace sharedWorkspace] hideOtherApplications]directly, providing the programmatic equivalent of Cmd+Opt+H (Hide Others).Motivation
Currently, hiding all other applications requires either:
hs.eventtap.keyStroke({"cmd", "alt"}, "h")— works but is indirecths.application.runningApplications()and callingapp:hide()on each — has race conditions with Safari Web Apps and is slowerA direct API call is cleaner, faster, and avoids edge cases with keystroke simulation.
Usage
Implementation
extensions/application/libapplication.mmoduleLibtable (module-level function, not instance method)