mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-06 16:57:03 +00:00
wluma: init module (#6463)
This commit is contained in:
parent
9f74e14a2d
commit
e512de4722
3 changed files with 114 additions and 0 deletions
|
@ -2074,6 +2074,16 @@ in {
|
|||
See https://github.com/artemsen/swayimg for more.
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2025-02-16T17:00:00+00:00";
|
||||
message = ''
|
||||
A new module is available: 'services.wluma'.
|
||||
|
||||
Wluma is a tool for Wayland compositors to automatically adjust
|
||||
screen brightness based on the screen contents and amount of ambient light around you.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -420,6 +420,7 @@ let
|
|||
./services/window-managers/wayfire.nix
|
||||
./services/window-managers/xmonad.nix
|
||||
./services/wlsunset.nix
|
||||
./services/wluma.nix
|
||||
./services/wob.nix
|
||||
./services/xcape.nix
|
||||
./services/xembed-sni-proxy.nix
|
||||
|
|
103
modules/services/wluma.nix
Normal file
103
modules/services/wluma.nix
Normal file
|
@ -0,0 +1,103 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.services.wluma;
|
||||
format = pkgs.formats.toml { };
|
||||
configFile = format.generate "config.toml" cfg.settings;
|
||||
in {
|
||||
meta.maintainers = with lib.maintainers; [ _0x5a4 ];
|
||||
|
||||
options.services.wluma = {
|
||||
enable = lib.mkEnableOption
|
||||
"Enable wluma, a service for automatic brightness adjustment";
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = pkgs.wluma;
|
||||
defaultText = lib.literalExpression "pkgs.wluma";
|
||||
description = "Package providing {command}`wluma`.";
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = format.type;
|
||||
default = { };
|
||||
example = {
|
||||
als.iio = {
|
||||
path = "";
|
||||
thresholds = {
|
||||
"0" = "night";
|
||||
"20" = "dark";
|
||||
"80" = "dim";
|
||||
"250" = "normal";
|
||||
"500" = "bright";
|
||||
"800" = "outdoors";
|
||||
};
|
||||
};
|
||||
};
|
||||
description = ''
|
||||
Configuration to use for wluma. See
|
||||
<https://github.com/maximbaz/wluma/blob/main/config.toml>
|
||||
for available options.
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.enable = lib.mkOption {
|
||||
description = "Wluma systemd integration";
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
systemd.target = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = config.wayland.systemd.target;
|
||||
defaultText = lib.literalExpression "config.wayland.systemd.target";
|
||||
example = "sway-session.target";
|
||||
description = ''
|
||||
The systemd target that will automatically start the Wluma service.
|
||||
|
||||
When setting this value to `"sway-session.target"`,
|
||||
make sure to also enable {option}`wayland.windowManager.sway.systemd.enable`,
|
||||
otherwise the service may never be started.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
(lib.hm.assertions.assertPlatform "services.wluma" pkgs
|
||||
lib.platforms.linux)
|
||||
];
|
||||
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
xdg.configFile = lib.mkIf (cfg.settings != { }) {
|
||||
"wluma/config.toml".source = configFile;
|
||||
};
|
||||
|
||||
systemd.user.services.wluma = lib.mkIf cfg.systemd.enable {
|
||||
Unit = {
|
||||
Description =
|
||||
"Automatic brightness adjustment based on screen contents and ALS ";
|
||||
After = [ cfg.systemd.target ];
|
||||
PartOf = [ cfg.systemd.target ];
|
||||
ConditionEnvironment = "WAYLAND_DISPLAY";
|
||||
X-Restart-Triggers = lib.mkIf (cfg.settings != { }) [ "${configFile}" ];
|
||||
};
|
||||
|
||||
Install.WantedBy = [ cfg.systemd.target ];
|
||||
|
||||
Service = {
|
||||
ExecStart = lib.getExe cfg.package;
|
||||
Restart = "always";
|
||||
|
||||
# Sandboxing.
|
||||
LockPersonality = true;
|
||||
MemoryDenyWriteExecute = true;
|
||||
NoNewPrivileges = true;
|
||||
PrivateUsers = true;
|
||||
RestrictNamespaces = true;
|
||||
SystemCallArchitectures = "native";
|
||||
SystemCallFilter = "@system-service";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue