Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Night Shift schedule #1046

Open
DimitarNestorov opened this issue Aug 25, 2024 · 1 comment
Open

Night Shift schedule #1046

DimitarNestorov opened this issue Aug 25, 2024 · 1 comment

Comments

@DimitarNestorov
Copy link

DimitarNestorov commented Aug 25, 2024

It would be awesome if nix-darwin could schedule Night Shift. The preferences are located in /var/root/Library/Preferences/com.apple.CoreBrightness.plist

Some scripts I found online that set the Night Shift schedule:

https://gist.github.com/thomasfinch/14bd3181799734c872d2ad3b207cc01c#file-nightshiftcontrol-sh

https://github.com/LukeChannings/dotfiles/blob/7cb3171b5354761c9aef7b6f1094019ef8701a17/install.macos#L413-L433


EDIT: I think I figured it out but it would be awesome if I didn't have to figure out the user UUID myself:

{
  system.defaults = {
    CustomSystemPreferences = {
      "/var/root/Library/Preferences/com.apple.CoreBrightness.plist" = let
        userId = builtins.readFile (pkgs.runCommand "user-id" {} "/usr/bin/dscl . -read /Users/dimitar GeneratedUID | /usr/bin/sed 's/GeneratedUID: //' | /usr/bin/tr -d \\\\n > $out");
      in {
        "CBUser-${userId}" = {
          CBBlueLightReductionCCTTargetRaw = "3433.05";
          CBBlueReductionStatus = {
            AutoBlueReductionEnabled = 1;
            BlueLightReductionAlgoOverride = 0;
            BlueLightReductionDisableScheduleAlertCounter = 3;
            BlueLightReductionSchedule = {
              DayStartHour = 7;
              DayStartMinute = 0;
              NightStartHour = 22;
              NightStartMinute = 0;
            };
            BlueReductionAvailable = 1;
            BlueReductionEnabled = 0;
            BlueReductionMode = 1;
            BlueReductionSunScheduleAllowed = 1;
            Version = 1;
          };
          CBColorAdaptationEnabled = 1;
        };
      };
    };
  };
}
@kimjongbing
Copy link

this would be amazing to add

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants