1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +01:00

dunst: implement settings parameter

This commit is contained in:
Nikita Uvarov 2017-10-09 11:20:12 +02:00 committed by Robert Helgesson
parent 420a3f4a01
commit 3160c03843
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86

View file

@ -2,6 +2,22 @@
with lib; with lib;
let
cfg = config.services.dunst;
toDunstIni = generators.toINI {
mkKeyValue = key: value:
let
value' =
if isBool value then (if value then "yes" else "no")
else if isString value then "\"${value}\""
else toString value;
in
"${key}=${value'}";
};
in
{ {
meta.maintainers = [ maintainers.rycee ]; meta.maintainers = [ maintainers.rycee ];
@ -10,29 +26,53 @@ with lib;
enable = mkEnableOption "the dunst notification daemon"; enable = mkEnableOption "the dunst notification daemon";
settings = mkOption { settings = mkOption {
type = types.attrs; type = types.attrsOf types.attrs;
default = {}; default = {};
description = "Configuration written to ~/.config/dunstrc"; description = "Configuration written to ~/.config/dunstrc";
example = literalExample ''
{
global = {
geometry = "300x5-30+50";
transparency = 10;
frame_color = "#eceff1";
font = "Droid Sans 9";
};
urgency_normal = {
background = "#37474f";
foreground = "#eceff1";
timeout = 10;
};
};
'';
}; };
}; };
}; };
config = mkIf config.services.dunst.enable { config = mkIf cfg.enable (
home.file.".local/share/dbus-1/services/org.knopwob.dunst.service".source = mkMerge [
"${pkgs.dunst}/share/dbus-1/services/org.knopwob.dunst.service"; {
home.file.".local/share/dbus-1/services/org.knopwob.dunst.service".source =
"${pkgs.dunst}/share/dbus-1/services/org.knopwob.dunst.service";
systemd.user.services.dunst = { systemd.user.services.dunst = {
Unit = { Unit = {
Description = "Dunst notification daemon"; Description = "Dunst notification daemon";
After = [ "graphical-session-pre.target" ]; After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ]; PartOf = [ "graphical-session.target" ];
}; };
Service = { Service = {
Type = "dbus"; Type = "dbus";
BusName = "org.freedesktop.Notifications"; BusName = "org.freedesktop.Notifications";
ExecStart = "${pkgs.dunst}/bin/dunst"; ExecStart = "${pkgs.dunst}/bin/dunst";
}; };
}; };
}; }
(mkIf (cfg.settings != {}) {
home.file.".config/dunst/dunstrc".text = toDunstIni cfg.settings;
})
]
);
} }