Skip to content

Repository files navigation

macOS Night Shift Sun Automation

A tiny, local macOS automation that turns Night Shift off at sunrise and turns it on two hours before sunset. It can also add a stronger red-screen effect by running Apple Shortcuts for the macOS Accessibility Color Filter at 20:00, then disabling it again at sunrise.

Useful if you are looking for automatic Night Shift, a sunset-based blue-light filter, a macOS red-light filter, or a lightweight launchd alternative to keeping an app open.

Features

  • Calculates sunrise and sunset locally from coordinates; no location or weather API
  • Starts automatically when you sign in
  • Checks every five minutes and consumes no resources between checks
  • Uses macOS's built-in Night Shift through the private CoreBrightness framework
  • Optional extra Color Filter through Apple Shortcuts

Requirements

  • macOS with Night Shift
  • Xcode Command Line Tools (xcode-select --install)
  • Python 3 at /usr/bin/python3

Install

Clone the repository, find approximate coordinates for your city, then run:

chmod +x install.sh uninstall.sh
./install.sh LATITUDE LONGITUDE

Example coordinates in config.example.json point to Berlin and are not used automatically.

For the optional extra red filter, create two shortcuts named Farbfilter Ein and Farbfilter Aus. Each should use the Shortcuts action that sets the Accessibility Color Filter on or off. Then copy the two color_filter_*_shortcut entries from config.example.json into the installed config.json.

Configuration and logs live in ~/Library/Application Support/NightShiftSun/. The launch agent is installed at ~/Library/LaunchAgents/com.nightshift-sun.plist.

Uninstall

./uninstall.sh

Notes

This project calls a private macOS framework, so a future macOS release may require changes. The code does not transmit coordinates or other data.

License

MIT

About

Lightweight macOS Night Shift and red color filter automation based on sunrise and sunset

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages