thompsonate / Shifty

☀️ A macOS menu bar app that gives you more control over Night Shift.
http://shifty.natethompson.io
GNU General Public License v3.0
1.24k stars 33 forks source link

Not in sync with System Preferences settings, won't stay enabled #61

Closed FoxBJK closed 5 years ago

FoxBJK commented 6 years ago

I have Shifty set to enabled for sunset to sunrise, but it doesn't work. If I go into system preferences to manually turn on night shift, it works. As soon as I close system preferences, the setting is lost.

I'm not using wifi, not sure if that affects this. The app just seems to force night shift to stay off unless I manually turn it on.

ghost commented 6 years ago

Same issue here. Shifty does not synchronise with "Sunset to Sunrise" system preferences.

Also, scheduled "Dark Mode" on the Night Shift schedule (Sunset to Sunrise), obviously does not work neither

macOS Mojave 10.14 (18A391) Shifty 1.0

screenshot 2018-10-12 at 18 56 05
choco commented 5 years ago

Whoever has this issue, can you post the output of this command corebrightnessdiag nightshift-internal ? You should execute it in the terminal app.

FoxBJK commented 5 years ago
Night Shift Status
{
    AutoBlueReductionEnabled = 1;
    BlueLightReductionAlgoOverride = 0;
    BlueLightReductionDisableScheduleAlertCounter = 3;
    BlueLightReductionSchedule =     {
        DayStartHour = 7;
        DayStartMinute = 0;
        NightStartHour = 22;
        NightStartMinute = 0;
    };
    BlueReductionEnabled = 0;
    BlueReductionMode = 1;
    BlueReductionSunScheduleAllowed = 1;
    Version = 1;
}
Night Shift Sunset/Sunrise
(null)
choco commented 5 years ago

Ok, it doesn't work because we are not able to obtain the sunset/sunrise times. It seems macOS populates those entries only when the is a Wifi connection, or at least wifi must be active. Without Shifty, does the sunrise/sunset Night Shift schedule work? If yes, when dos it turn on/off?

FoxBJK commented 5 years ago

Now that I think of it, no. NS doesn't work normally. Oftentimes I'm turning it on or off myself manually. Even those times in the status don't make any sense (Night does not start at 10:00 here. More like 5:00).

Wifi is not regularly enabled for me because my Mac is LAN-connected. Is there a way I can provide my location manually? I quickly turned on wifi, reran that first command and here's what I get now:

Night Shift Status
{
    AutoBlueReductionEnabled = 1;
    BlueLightReductionAlgoOverride = 0;
    BlueLightReductionDisableScheduleAlertCounter = 3;
    BlueLightReductionSchedule =     {
        DayStartHour = 7;
        DayStartMinute = 0;
        NightStartHour = 22;
        NightStartMinute = 0;
    };
    BlueReductionEnabled = 0;
    BlueReductionMode = 1;
    BlueReductionSunScheduleAllowed = 1;
    Version = 1;
}
Night Shift Sunset/Sunrise
{
    isDaylight = 1;
    nextSunrise = "2018-11-23 12:28:04 +0000";
    nextSunset = "2018-11-22 21:55:04 +0000";
    previousSunrise = "2018-11-21 12:25:44 +0000";
    previousSunset = "2018-11-20 21:56:23 +0000";
    sunrise = "2018-11-22 12:26:54 +0000";
    sunset = "2018-11-21 21:55:42 +0000";
}
choco commented 5 years ago

Yeah, we use the same data source that Night Shift uses; so if one works the other should too (Night Shift may fallback to some hardcoded value, but it doesn't seem to since you said that sometimes it doesn't work). Unfortunately that's a macOS issue, to determine your location they use the MAC address of Wifi networks around you (when an iPhone connects to a wifi, it sends to Apple the location and the corresponding MAC address, so they're later able to guess the location of devices which don't have a GPS but connect to the same Wifi network). One solution is to enable Wifi, but don't connect to any network.

There's now way to manually set the location for macOS, but an older version of Shifty used a GeoIP location service to determine the location, so maybe we could implement that as a fallback... but that a feature request for @thompsonate

FoxBJK commented 5 years ago

I've left wifi on since the last post. However, NS still doesn't come on automatically. I had to manually enable it just now. It's well past sunset already.

choco commented 5 years ago

You'll probably have to restart your Mac for Night Shift to notice that now you have sunset/sunrise data.

FoxBJK commented 5 years ago

I'll reboot tonight and watch this over the holiday. We'll see how it goes.

FoxBJK commented 5 years ago

100% this is because wifi was disabled. Closing this, since what I really want is a feature where my location is remembered (similar to f.lux)

thompsonate commented 5 years ago

I'm not sure why it would fail to get the sunset and sunrise times on LAN but work fine on Wi-Fi. @FoxBJK if you check the times using corebrightnessdiag nightshift-internal they should change every 24 hours. Can you see if that's happening still with your Mac just on LAN?

The issue with remembering the location is that Shifty doesn't know the location in the first place. It just gets the times from the system, so if I cache previous times they're just going to get more and more off. I'm tempted to say this is the result of a macOS bug.

ghost commented 5 years ago

My solution. I chose the custom timing.

FoxBJK commented 5 years ago

I've had wifi on all day, so I just turned it off and will report back in a couple days. In the meantime, command output gives:

Night Shift Status
{
    AutoBlueReductionEnabled = 1;
    BlueLightReductionAlgoOverride = 0;
    BlueLightReductionDisableScheduleAlertCounter = 3;
    BlueLightReductionSchedule =     {
        DayStartHour = 7;
        DayStartMinute = 0;
        NightStartHour = 22;
        NightStartMinute = 0;
    };
    BlueReductionEnabled = 1;
    BlueReductionMode = 1;
    BlueReductionSunScheduleAllowed = 1;
    Version = 1;
}
Night Shift Sunset/Sunrise
{
    isDaylight = 0;
    nextSunrise = "2018-12-01 12:36:57 +0000";
    nextSunset = "2018-11-30 21:51:15 +0000";
    previousSunrise = "2018-11-29 12:34:48 +0000";
    previousSunset = "2018-11-28 21:51:59 +0000";
    sunrise = "2018-11-30 12:35:53 +0000";
    sunset = "2018-11-29 21:51:36 +0000";
}
FoxBJK commented 5 years ago

The solution has become abundantly clear after more testing, so I'm going to close this out. No wifi, no night shift schedule because the sunrise/sunset times don't show up. This is just how mac OS is designed, nothing we can do about that. Shifty would have to do its own calculations, but I feel like that would defeat the point of this app.

thompsonate commented 5 years ago

Yeah, I actually tried to my own calculations at some point in the beta and it was kind of tedious and people didn't understand why it required their location.

It doesn't seem like that should be intended behavior on macOS's part. I'd suggest filing a bug report at bugreport.apple.com to make sure they know it's an issue.

FoxBJK commented 5 years ago

Well.... Apple might not agree with your classification as "bug"

https://superuser.com/a/636991

thompsonate commented 5 years ago

Oh, I didn't realize that Location Services wasn't designed to work without Wi-Fi. So I guess the solution is to leave Wi-Fi on but disconnected.