Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/artlasovsky/toggle-macos-dock-icon
- Owner: artlasovsky
- Created: 2024-08-25T16:16:34.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-08-25T17:22:13.000Z (about 1 month ago)
- Last Synced: 2024-08-26T17:53:21.408Z (about 1 month ago)
- Topics: activationpolicy, appkit, dock, dock-icon, icon, macos, swiftui
- Language: Swift
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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