aboutsummaryrefslogtreecommitdiff
path: root/modules/services/dunst.nix
diff options
context:
space:
mode:
authorNikita Uvarov <uv.nikita@gmail.com>2017-10-09 11:20:12 +0200
committerRobert Helgesson <robert@rycee.net>2017-10-09 14:51:07 +0200
commit3160c0384370f7a8dc340cf341c67066daf9c81e (patch)
treeb84c608bf281af9250d1b8047036bcdf0f49a060 /modules/services/dunst.nix
parent420a3f4a01f58ac6d504435b1641106cb59588c1 (diff)
dunst: implement settings parameter
Diffstat (limited to 'modules/services/dunst.nix')
-rw-r--r--modules/services/dunst.nix74
1 files changed, 57 insertions, 17 deletions
diff --git a/modules/services/dunst.nix b/modules/services/dunst.nix
index 659425b116c..22a7d216340 100644
--- a/modules/services/dunst.nix
+++ b/modules/services/dunst.nix
@@ -2,6 +2,22 @@
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 ];
@@ -10,29 +26,53 @@ with lib;
enable = mkEnableOption "the dunst notification daemon";
settings = mkOption {
- type = types.attrs;
+ type = types.attrsOf types.attrs;
default = {};
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 {
- home.file.".local/share/dbus-1/services/org.knopwob.dunst.service".source =
- "${pkgs.dunst}/share/dbus-1/services/org.knopwob.dunst.service";
+ config = mkIf cfg.enable (
+ mkMerge [
+ {
+ 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 = {
- Unit = {
- Description = "Dunst notification daemon";
- After = [ "graphical-session-pre.target" ];
- PartOf = [ "graphical-session.target" ];
- };
+ systemd.user.services.dunst = {
+ Unit = {
+ Description = "Dunst notification daemon";
+ After = [ "graphical-session-pre.target" ];
+ PartOf = [ "graphical-session.target" ];
+ };
- Service = {
- Type = "dbus";
- BusName = "org.freedesktop.Notifications";
- ExecStart = "${pkgs.dunst}/bin/dunst";
- };
- };
- };
+ Service = {
+ Type = "dbus";
+ BusName = "org.freedesktop.Notifications";
+ ExecStart = "${pkgs.dunst}/bin/dunst";
+ };
+ };
+ }
+
+ (mkIf (cfg.settings != {}) {
+ home.file.".config/dunst/dunstrc".text = toDunstIni cfg.settings;
+ })
+ ]
+ );
}