4

I would like to have a way to script enabling and disabling night shift on macOS. I am using macOS Ventura 13.4.

I am a heavy Terminal user so I live within the terminal whole day. Having a command or script that I can run to enable/disable night shift is going to be very helpful to me.

I read Enable or disable Night Shift via Terminal but strangely the answers there don't address how to enable/disable night shift from the terminal. They do address another problem though that was asked in the question.

So is there some way to enable/disable night shift using command or script?

5
  • 2
    You could use nightlight. After installing just type "nightlight on" / "nightlight off" into terminal. Jun 19, 2023 at 10:55
  • When do you enable and disable it? Surely, it will disable itself 'outside' of night time anyway. Do you sometimes want it disabled at night, and enabled during the day?
    – benwiggy
    Sep 9, 2023 at 17:58
  • @benwiggy I want it always enabled. For that reason I have set a custom schedule to keep it enabled from 04:00 to 03:59. So it remains enabled throughout the day. The only time it gets disabled is in the early hours of morning between 03:59 and 04:00. But sometimes while doing graphics work I may want to enable and disable it temporarily and having a script to do it is going to be useful. Oct 27, 2023 at 10:09
  • Do you just want a tint all the time? (Wouldn't you want accurate colour for graphics work...?)
    – benwiggy
    Oct 27, 2023 at 10:16
  • @benwiggy That's actually beyond the scope of this question though. In this question I want to find out if there is a way to enable or disable night shift using a command or script. Now going out of scope, yes, I need accurate color for graphics work and that's when I disable night shift completely. Oct 27, 2023 at 10:21

2 Answers 2

3

There is a shortcut action to turn NightShift on or off; and shortcuts can be triggered with the Terminal command shortcuts.

enter image description here

You can also toggle the status with a single action, which may be more useful.

% shortcuts
OVERVIEW: Command-line utility for running shortcuts.

USAGE: shortcuts <subcommand>

OPTIONS:
  -h, --help              Show help information.

SUBCOMMANDS:
  run                     Run a shortcut.
  list                    List your shortcuts.
  view                    View a shortcut in Shortcuts.
  sign                    Sign a shortcut file.

  See 'shortcuts help <subcommand>' for detailed help.
1

Apparently there is no way to do this with an ootb terminal command or native applescript API (emulating mouse clicks on system prefs dialog panes doesn't count). But there is nshift — although it has not been updated in a while it still works with latest MacOS versions (eg ventura) and can be compiled to run on apple silicon M1/M2 if you have xcode or xcode tools installed.

Usage:

# Enable night shift:
./nshift 100

# Disable night shift:
./nshift 0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .