https://github.com/rrroyal/automaticdocktile
Change the dock tile icon on theme switch ✨
https://github.com/rrroyal/automaticdocktile
macos nsdocktileplugin swift
Last synced: 10 months ago
JSON representation
Change the dock tile icon on theme switch ✨
- Host: GitHub
- URL: https://github.com/rrroyal/automaticdocktile
- Owner: rrroyal
- Created: 2020-11-13T21:42:36.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-14T01:13:42.000Z (over 5 years ago)
- Last Synced: 2025-03-26T14:04:26.383Z (about 1 year ago)
- Topics: macos, nsdocktileplugin, swift
- Language: Swift
- Homepage:
- Size: 84 KB
- Stars: 73
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AutomaticDockTile
A day after the Big Sur release, I've noticed that the icon of [Nova](https://nova.app) by [Panic](https://panic.com) changes colors when switching between light and dark mode. **Here's how it looks like:**

I [tweeted](https://twitter.com/destroystokyo/status/1327224712578142209) about it immediately, and few hours later looked up how to do this. There were no results about it, so I started tinkering around. I examined all of the `.car`'s and `.icns`'s, but there was nothing. So I checked how to update the dock icon and I've stumbled upon [NSDockTilePlugin](https://developer.apple.com/documentation/appkit/nsdocktileplugin) - bingo!
Unfortunately, it wasn't *that* easy - there's not much documentation on how to use it, but there's [one example project](https://github.com/CartBlanche/MacDockTileSample). It's in Objective-C (which I've never used) though - not optimal, but I can work with that.
After around two hours I've managed to successfully register the Swift-based plugin (**protip:** create new bundle, set the principal class and register the plugin in the host app with `NSDockTilePlugIn`. If something isn't working, console is your best friend). Now, let's do the theme-changing part.
While reverse-engineering the `NovaDockTile` plugin I saw some observer-related code. Basic publisher for `NSApp.effectiveAppearance` did the job just fine.
Ta-da! Icon's updating on theme change ✨.
