Skittyblock / Dune

A free, open-source, iOS 13-like dark mode for iOS 11 and 12
GNU General Public License v3.0
74 stars 17 forks source link

Sync with Night Shift #15

Open rllbe opened 5 years ago

rllbe commented 5 years ago

It would be nice if auto enable/disable by sunrise/sunset is implemented, just like how iOS 13 does. I've managed to make it work by respecting night shift settings(that means no more CoreLocation stuff needed):

@interface CBBlueLightClient : NSObject typedef struct { int hour; int minute; } Time; typedef struct { Time fromTime; Time toTime; } Schedule; typedef struct { BOOL active; BOOL enabled; BOOL sunSchedulePermitted; int mode; Schedule schedule; unsigned long long disableFlags; BOOL available; } Status; -(CBBlueLightClient *)initWithClientObj:(id)arg1 ; @end

%hook CBBlueLightClient -(CBBlueLightClient *)initWithClientObj:(id)arg1 { CBBlueLightClient *client = %orig; void (^notificationBlock)() = ^() { Status status; [client getBlueLightStatus:&status]; if (status.mode == 1) { //mode 1 means sunset/sunrise mode if (status.enabled) notify_post(@"xyz.skitty.dune.enabled".UTF8String); else notify_post(@"xyz.skitty.dune.disabled".UTF8String); } }; [client setStatusNotificationBlock:notificationBlock]; return %orig; } %end

Skittyblock commented 5 years ago

Yes, I will add an option to sync with Night Shift. I'm planning to also add a separate automatic mode though so users can chose a different time or if they don't use Night Shift.