1
0
mirror of https://github.com/nix-community/home-manager synced 2024-07-01 02:48:30 +02:00
home-manager/modules/services/sctd.nix
Emily 36a53d9f26 treewide: convert all option docs to Markdown
This process was automated by [my fork of `nix-doc-munge`]. All
conversions were automatically checked to produce the same DocBook
result when converted back, modulo minor typographical/formatting
differences on the acceptable-to-desirable spectrum.

To reproduce this commit, run:

  $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
    nix shell nixpkgs#coreutils \
    -c find . -name '*.nix' \
    -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
    {} +
  $ ./format

[my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
2023-07-17 18:40:56 +01:00

72 lines
1.9 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
{
meta.maintainers = [ maintainers.somasis ];
options = {
services.sctd = {
enable = mkEnableOption (lib.mdDoc "sctd");
baseTemperature = mkOption {
type = types.ints.between 2500 9000;
default = 4500;
description = lib.mdDoc ''
The base color temperature used by sctd, which should be between 2500 and 9000.
See
{manpage}`sctd(1)`
for more details.
'';
};
};
};
config = mkIf config.services.sctd.enable {
assertions =
[ (hm.assertions.assertPlatform "services.sctd" pkgs platforms.linux) ];
systemd.user.services.sctd = {
Unit = {
Description =
"Dynamically adjust the screen color temperature twice every minute";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
};
Install.WantedBy = [ "graphical-session.target" ];
Service = {
ExecStart = "${pkgs.sct}/bin/sctd ${
toString config.services.sctd.baseTemperature
}";
ExecStopPost = "${pkgs.sct}/bin/sct";
Restart = "on-abnormal";
SuccessExitStatus = 1;
Environment = let
# HACK: Remove duplicate messages in the journal; `sctd` calls
# both `logger -s` (which outputs the message to stderr)
# *and* outputs to stderr itself. We can at least silence
# `logger`'s output without hiding sctd's own stderr.
logger = pkgs.writeShellScriptBin "logger" ''
exec 2>/dev/null
exec ${pkgs.util-linux}/bin/logger "$@"
'';
in [
"PATH=${
lib.makeBinPath [
pkgs.bash
pkgs.coreutils
pkgs.gnused
pkgs.which
pkgs.sct
logger
]
}"
];
};
};
};
}