1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2024-12-14 11:57:55 +00:00

sctd: add module

This adds a module for enabling the `sctd` daemon, as well as setting
the preferred base temperature.
This commit is contained in:
Kylie McClain 2022-05-18 21:46:53 -04:00 committed by Robert Helgesson
parent 72a135b093
commit 0ca0b91088
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 85 additions and 0 deletions

2
.github/CODEOWNERS vendored
View file

@ -478,3 +478,5 @@ Makefile @thiagokokada
/modules/programs/ion.nix @jo1gi
/modules/services/plex-mpv-shim.nix @starcraft66
/modules/services/sctd.nix @somasis

View file

@ -575,6 +575,14 @@ in
A new module is available: 'programs.pistol'.
'';
}
{
time = "2022-06-26T19:29:25+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.sctd'.
'';
}
];
};
}

View file

@ -246,6 +246,7 @@ let
./services/redshift-gammastep/redshift.nix
./services/rsibreak.nix
./services/screen-locker.nix
./services/sctd.nix
./services/spotifyd.nix
./services/stalonetray.nix
./services/status-notifier-watcher.nix

74
modules/services/sctd.nix Normal file
View file

@ -0,0 +1,74 @@
{ config, lib, pkgs, ... }:
with lib;
{
meta.maintainers = [ maintainers.somasis ];
options = {
services.sctd = {
enable = mkEnableOption "sctd";
baseTemperature = mkOption {
type = types.ints.between 2500 9000;
default = 4500;
description = ''
The base color temperature used by sctd, which should be between 2500 and 9000.
See
<citerefentry>
<refentrytitle>sctd</refentrytitle>
<manvolnum>1</manvolnum>
</citerefentry>
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
]
}"
];
};
};
};
}