Crates.io | nightlight |
lib.rs | nightlight |
version | 0.2.0 |
source | src |
created_at | 2020-04-27 22:33:19.344036 |
updated_at | 2020-06-22 04:11:18.979756 |
description | A CLI for configuring 'Night Shift' on macOS 🌕🌖🌗🌘🌑 |
homepage | |
repository | https://github.com/smudge/nightlight |
max_upload_size | |
id | 234804 |
size | 53,396 |
A CLI for configuring "Night Shift" on macOS 🌕🌖🌗🌘🌑
This crate also doubles as a Rust library. 🦀
The "Night Shift" feature on macOS is a convenient, built-in feature that can theoretically accomplish most of what third-party alternatives (like f.lux®) are capable of. However, as of now, there is no way to programmatically configure Night Shift (without entering the system preferences GUI), making its current usage more limited.
This nightlight
CLI aims to enable such access via a few simple commands.
(Or, alternatively, via library access for other Rust tools.)
brew tap smudge/smudge
brew install nightlight
Set up Rust/Cargo and install from crates.io by running:
cargo install nightlight
First, make sure you are running macOS Sierra or newer.
Turn Night Shift on (until tomorrow/sunrise):
nightlight on
Turn Night Shift off:
nightlight off
View current on/off status:
nightlight status
View current temperature setting:
nightlight temp
Set color temperature (a number from 0 to 100):
nightlight temp 70
View the current schedule:
nightlight schedule
Start schedule from sunset to sunrise:
nightlight schedule start
Start a custom schedule (in 12 or 24-hour time format):
nightlight schedule 19:45 6:00
nightlight schedule 7:45pm 6am
Stop the current schedule:
nightlight schedule off
In addition to a CLI, nightlight
can be pulled-in as a dependency for other Rust crates:
nightlight = "0.2.0"
Here's an example fn
that toggles Night Shift off,
changes the schedule and color temperature preference,
and then toggles the feature back on:
extern crate nightlight;
use nightlight::{NightLight, Schedule};
fn main() {
let night_light = NightLight::new();
if night_light.status().is_on() {
night_light.off().unwrap(),
}
println!("Setting schedule and temperature...");
night_light.set_schedule(Schedule::SunsetToSunrise).unwrap();
night_light.set_temp(70).unwrap();
println!("Turning Night Shift on...");
night_light.on().unwrap();
}
brew
)cargo build
) and functionality still works as expected.jenghis
for the (now archived) nshift repo/CLInightlight
is released under the MIT License.