This repository has been archived by the owner on May 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Suggestion: Switch from Yahoo API to Night Shift's internal schedule #7
Labels
enhancement
New feature or request
Comments
Amazing info @kirichkov thanks! I previously looked into using the night shift schedule and I could only find info on using the swift API, which would not benefit my bash script. Taking a look it seems like I'll just be able to use |
Done # Get Night Shift solar times (UTC)
riseT=$(/usr/bin/corebrightnessdiag nightshift-internal | grep nextSunrise | cut -d \" -f2)
setT=$(/usr/bin/corebrightnessdiag nightshift-internal | grep nextSunset | cut -d \" -f2)
# Convert to local time
riseTL=$(date -jf "%Y-%m-%d %H:%M:%S %z" "$riseT" +"%H:%M")
setTL=$(date -jf "%Y-%m-%d %H:%M:%S %z" "$setT" +"%H:%M")
# Store times in database
sqlite3 "$darkdir"/solar.db <<EOF
CREATE TABLE IF NOT EXISTS solar (id INTEGER PRIMARY KEY, time VARCHAR(5));
INSERT OR IGNORE INTO solar (id, time) VALUES (1, '$riseTL'), (2, '$setTL');
UPDATE solar SET time='$riseTL' WHERE id=1;
UPDATE solar SET time='$setTL' WHERE id=2;
EOF |
katernet
added a commit
that referenced
this issue
Sep 28, 2018
👍 👍 👍 Thanks! I'm closing it since you've implemented it in no time! |
UPDATE: It's working! Switched to dark mode in the evening, switched to light mode in the morning. |
Sweet! Thanks for the idea @kirichkov |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
As it appears MacOS will expose the night shift schedule as well as sunset/sunrise times on the command line using
/usr/bin/corebrightnessdiag nightshift-internal
.Benefits of this approach is that dependence on external services can be completely abandoned (finding lat/long and sunset/sunrise times). Also this could be used to switch to dark/light mode using the native Night Shift schedule.
One issue to keep in mind is that times returned by
corebrightnessdiag
are in GMT and not in local time. The local timezone can be extracted from/etc/localtime
.The text was updated successfully, but these errors were encountered: