fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5{ 6meta . maintainers = [ maintainers . somasis ]; 7 8options = { 9services . sctd = { 10enable = mkEnableOption "sctd" ; 11 12baseTemperature = mkOption { 13type = types . ints . between 2500 9000 ; 14default = 4500 ; 15description = '' 16The base color temperature used by sctd, which should be between 2500 and 9000. 17See 18{manpage}`sctd(1)` 19for more details. 20'' ; 21}; 22}; 23}; 24 25config = mkIf config . services . sctd . enable { 26assertions = 27[ ( hm . assertions . assertPlatform "services.sctd" pkgs platforms . linux ) ]; 28 29systemd . user . services . sctd = { 30Unit = { 31Description = 32"Dynamically adjust the screen color temperature twice every minute" ; 33After = [ "graphical-session-pre.target" ]; 34PartOf = [ "graphical-session.target" ]; 35}; 36 37Install . WantedBy = [ "graphical-session.target" ]; 38 39Service = { 40ExecStart = " ${ pkgs . sct } /bin/sctd ${ 41toString config . services . sctd . baseTemperature 42} " ; 43ExecStopPost = " ${ pkgs . sct } /bin/sct" ; 44Restart = "on-abnormal" ; 45SuccessExitStatus = 1 ; 46 47Environment = let 48# HACK: Remove duplicate messages in the journal; `sctd` calls 49# both `logger -s` (which outputs the message to stderr) 50# *and* outputs to stderr itself. We can at least silence 51# `logger`'s output without hiding sctd's own stderr. 52logger = pkgs . writeShellScriptBin "logger" '' 53exec 2 > /dev/null 54exec ${ pkgs . util-linux } /bin/logger " $ @" 55'' ; 56in [ 57"PATH= ${ 58lib . makeBinPath [ 59pkgs . bash 60pkgs . coreutils 61pkgs . gnused 62pkgs . which 63pkgs . sct 64logger 65] 66} " 67]; 68}; 69}; 70}; 71}