Skip to content

fix: prevent multiple instances of Hidden Bar from running simultaneously - #385

Open
bunnysayzz wants to merge 1 commit into
dwarvesf:developfrom
bunnysayzz:fix/single-instance
Open

fix: prevent multiple instances of Hidden Bar from running simultaneously#385
bunnysayzz wants to merge 1 commit into
dwarvesf:developfrom
bunnysayzz:fix/single-instance

Conversation

@bunnysayzz

Copy link
Copy Markdown

What & Why

Hidden Bar is a menu bar utility with no visible window, so launching it a second time silently spawns a duplicate instance instead of switching to the one already running. That leaves two identical status bar items and two preference windows — confusing and wasteful.

This adds an early guard in applicationDidFinishLaunching:

  • Scans NSWorkspace.shared.runningApplications for another instance with the same bundle ID (excluding the current process).
  • If one is found, it activates the existing instance and terminates the new one.

Changes

  • hidden/AppDelegate.swift: ensureSingleInstance() guard + call in applicationDidFinishLaunching (16 lines added, one file).

Testing

  • Parses cleanly with swiftc -parse.
  • Logic mirrors the standard macOS single-instance pattern for agent/menu bar apps (bundle-ID match + PID exclusion + activate/terminate).

Closes the intent of #376 (which was withdrawn — it targeted the stale master branch and lacked the actual code change).

…usly

Hidden Bar is a menu bar utility with no visible window, so relaunching
it silently spawned a second instance instead of switching to the one
already running. Guard applicationDidFinishLaunching: if another
instance with the same bundle ID is running, activate it and terminate
the new one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant