https://github.com/bouk/dark-mode-notify
Run a script whenever dark mode changes in macOS
https://github.com/bouk/dark-mode-notify
Last synced: about 1 year ago
JSON representation
Run a script whenever dark mode changes in macOS
- Host: GitHub
- URL: https://github.com/bouk/dark-mode-notify
- Owner: bouk
- License: mit
- Created: 2021-02-07T13:00:08.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-09-14T14:29:20.000Z (almost 4 years ago)
- Last Synced: 2025-04-01T00:11:23.913Z (about 1 year ago)
- Language: Swift
- Size: 9.77 KB
- Stars: 203
- Watchers: 6
- Forks: 33
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dark-mode-notify
This small Swift program will run a command whenever the dark mode status changes on macOS. You can use it to change your vim color config automatically for example.
## Usage
Use make to compile the program, then run directly:
```shell
.build/release/dark-mode-notify
```
Alternatively you can install it by doing `make install`.
The program will be run immediately when the command starts, and every time the OS goes from dark mode to light mode or back. The environment variable `DARKMODE` will be set to either `1` or `0`.
## Background agent
To keep this program running in the background, compile the binary to somewhere and create the following file at `~/Library/LaunchAgents/ke.bou.dark-mode-notify.plist`. Don't forget to replace the arguments and the path to the logs (which comes in handy for debugging)
```xml
Label
ke.bou.dark-mode-notify
KeepAlive
StandardErrorPath
----Path to a location----/dark-mode-notify-stderr.log
StandardOutPath
----Path to a location----/dark-mode-notify-stdout.log
ProgramArguments
/usr/local/bin/dark-mode-notify
--- Path to your script ---
```
Then `launchctl load -w ~/Library/LaunchAgents/ke.bou.dark-mode-notify.plist` will keep it running on boot.
## Credit
This script is a lightly modified version of https://github.com/mnewt/dotemacs/blob/master/bin/dark-mode-notifier.swift