From c9966fad09b5b74210503295d82f5e9b4ecb4915 Mon Sep 17 00:00:00 2001 From: Dany Marcoux Date: Sun, 30 Jun 2024 20:29:22 +0200 Subject: [PATCH] Revert "Replace redshift by go-sct" This reverts commit ade34b361e8c695f74e4f837c3faa48bb9866ad0. I understand now why redshift wasn't working this time. See [this issue](https://github.com/NixOS/nixpkgs/issues/321121). --- home-manager/autorandr.nix | 2 +- home-manager/home.nix | 1 + home-manager/i3.nix | 3 --- home-manager/redshift.nix | 25 +++++++++++++++++++++++++ nixos/configuration.nix | 1 + nixos/packages.nix | 2 -- nixos/redshift.nix | 18 ++++++++++++++++++ 7 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 home-manager/redshift.nix create mode 100644 nixos/redshift.nix diff --git a/home-manager/autorandr.nix b/home-manager/autorandr.nix index 6cd0350..3717cb3 100644 --- a/home-manager/autorandr.nix +++ b/home-manager/autorandr.nix @@ -4,7 +4,7 @@ # Enable autorandr. Profiles are specific to hosts, so they're not defined here programs.autorandr.enable = true; - # Since I'm using sct, the gamma always varies. It's skipped when detecting changes and applying a profile. + # Since I'm using Redshift, the gamma always varies. It's skipped when detecting changes and applying a profile. xdg.configFile."autorandr/settings.ini".text = '' [config] skip-options=gamma diff --git a/home-manager/home.nix b/home-manager/home.nix index 37da3c9..2763806 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -33,6 +33,7 @@ ./pasystray.nix ./picom.nix ./playerctl.nix + ./redshift.nix ./ripgrep.nix ./rofi.nix ./ruby.nix diff --git a/home-manager/i3.nix b/home-manager/i3.nix index bdb5105..d15b05d 100644 --- a/home-manager/i3.nix +++ b/home-manager/i3.nix @@ -161,9 +161,6 @@ # Center floating windows in the workspace in which they appear for_window [floating] move position center - # Launc sct to control color temperature of the screen - exec --no-startup-id sct -dayTemp 5500 -nightTemp 3500 - # Launch terminal # Somehow, this alacritty instance has a bigger font size due to the `Window Scale Factor` being wrong. # This issue started to happen when I upgraded to NixOS 24.05 and I don't know why... following alacritty instances diff --git a/home-manager/redshift.nix b/home-manager/redshift.nix new file mode 100644 index 0000000..58f1719 --- /dev/null +++ b/home-manager/redshift.nix @@ -0,0 +1,25 @@ +# User configuration for redshift + +{ pkgs, options, ... }: + +{ + # Install redshift + home.packages = [ options.services.redshift.package.value ]; + + # Use redshift to adapt screen's color temperature depending on the time of day + services.redshift = { + enable = true; + + # Use GeoClue2 as location provider + provider = "geoclue2"; + + # Colour temperature to use at day/night, between 1000 and 25000 K + temperature = { + day = 5500; + night = 3500; + }; + + # Start the redshift-gtk tray applet + tray = true; + }; +} diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 3c1d9da..14c4535 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -38,6 +38,7 @@ ./packages.nix ./podman.nix ./printing.nix + ./redshift.nix ./udiskie.nix ./unclutter.nix ./vscode.nix diff --git a/nixos/packages.nix b/nixos/packages.nix index fe6b670..9359b67 100644 --- a/nixos/packages.nix +++ b/nixos/packages.nix @@ -46,8 +46,6 @@ go_1_21 # Go Language Server unstable.gopls - # Control color temperature of the screen based on location and time - go-sct # For the command make gnumake # Color picker diff --git a/nixos/redshift.nix b/nixos/redshift.nix new file mode 100644 index 0000000..238ae9e --- /dev/null +++ b/nixos/redshift.nix @@ -0,0 +1,18 @@ +# System configuration for redshift + +{ pkgs, ... }: + +{ + # Without this package, redshift-gtk doesn't have an icon. + environment.systemPackages = [ pkgs.hicolor-icon-theme ]; + + # Start GeoClue2 daemon + services.geoclue2.enable = true; + + # Enable location with GeoClue2 + services.geoclue2.appConfig.redshift = { + isAllowed = true; + isSystem = false; + }; + location.provider = "geoclue2"; +}