Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/artlasovsky/toggle-macos-dock-icon

This SwiftUI app demonstrates how to dynamically toggle the visibility of the dock icon in macOS.
https://github.com/artlasovsky/toggle-macos-dock-icon

activationpolicy appkit dock dock-icon icon macos swiftui

Last synced: about 7 hours ago
JSON representation

This SwiftUI app demonstrates how to dynamically toggle the visibility of the dock icon in macOS.

Awesome Lists containing this project

README

        

# Toggle Dock Icon App

## Overview
This SwiftUI app demonstrates how to dynamically toggle the visibility of the dock icon in macOS.

## Features
- Toggle dock icon visibility
- Persist app window even when dock icon is hidden

## Important
Do not forget to add `Application is agent (UIElement)` property with value `YES` to `Info.plist`

## Note
When running the app in debug mode, Xcode windows will take precedence over the app's windows.
As a result, even after calling NSApp.activate() or NSWindow.makeKeyAndOrderFront(), the app's windows will remain behind the Xcode windows.

However, this issue only occurs when Xcode is the active application behind our app.
If a different application is in the background, the app's windows will behave as expected.

## Usage
- Use "Hide/Show Dock Icon" button to toggle dock icon visibility
- Try to use Option + B shortcut to increment the counter, to make sure that window still handle keyboard events

## Demo Video
https://github.com/user-attachments/assets/8f513a66-45e1-440c-8a0a-ac6bd3e1efaf