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

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

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