about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2020-09-21 18:28:59 +0200
committerProfpatsch <mail@profpatsch.de>2020-09-21 18:28:59 +0200
commitf774d0e7f8a4047f3e167d3e58a64fb05e9424c2 (patch)
treeca4d2b25938e41605d68936e0d5dc18a6e0036f3 /modules
parentb332f86d7fe3c93c09508f1e50c58a4b8106b059 (diff)
modules/profpatsch/services: add dunst user service
Diffstat (limited to 'modules')
-rw-r--r--modules/module-list.nix1
-rw-r--r--modules/user/profpatsch/services/dunst.nix117
2 files changed, 118 insertions, 0 deletions
diff --git a/modules/module-list.nix b/modules/module-list.nix
index c343e3a1..0122ce3d 100644
--- a/modules/module-list.nix
+++ b/modules/module-list.nix
@@ -36,4 +36,5 @@
   ./user/profpatsch/programs/scanning.nix
   ./user/profpatsch/programs/weechat.nix
   ./user/profpatsch/services/bitlbee.nix
+  ./user/profpatsch/services/dunst.nix
 ]
diff --git a/modules/user/profpatsch/services/dunst.nix b/modules/user/profpatsch/services/dunst.nix
new file mode 100644
index 00000000..08e430b1
--- /dev/null
+++ b/modules/user/profpatsch/services/dunst.nix
@@ -0,0 +1,117 @@
+# dunst notification daemon (user service)
+# partially stolen from https://github.com/nix-community/home-manager/blob/9b1b55ba0264a55add4b7b4e022bdc2832b531f6/modules/services/dunst.nix
+# but simplified
+{ pkgs, lib, config, ... }:
+
+let
+  cfg = config.vuizvui.services.profpatsch.dunst;
+
+  eitherStrBoolIntList = with lib.types;
+    either str (either bool (either int (listOf str)));
+
+  toDunstINI = lib.generators.toINI {
+    mkKeyValue = key: value:
+      let
+        value' = if builtins.isBool value then
+          (if value then "yes" else "no")
+        else if builtins.isString value then
+          ''"${value}"''
+        else
+          toString value;
+      in "${key}=${value'}";
+  };
+
+
+  themeType = lib.types.submodule {
+    options = {
+      package = lib.mkOption {
+        type = lib.types.package;
+        example = lib.literalExample "pkgs.gnome3.adwaita-icon-theme";
+        description = "Package providing the theme.";
+      };
+
+      name = lib.mkOption {
+        type = lib.types.str;
+        example = "Adwaita";
+        description = "The name of the theme within the package.";
+      };
+    };
+  };
+
+
+  themeSize = "32x32";
+
+in {
+  options.vuizvui.services.profpatsch.dunst = {
+    enable = lib.mkEnableOption "dunst libnotify server";
+
+    settings = lib.mkOption {
+      type = with lib.types; attrsOf (attrsOf eitherStrBoolIntList);
+      default = { };
+    };
+
+    iconTheme = lib.mkOption {
+      type = themeType;
+      description = "Set the icon theme.";
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+    systemd.user.services.dunst = {
+      description = "dunst libnotify daemon";
+      serviceConfig = {
+        Type = "dbus";
+        BusName = "org.freedesktop.Notifications";
+        ExecStart = "${lib.getBin pkgs.dunst}/bin/dunst -config ${pkgs.writeText "dunst.conf" (toDunstINI cfg.settings)}";
+        Restart = "on-failure";
+      };
+      partOf = [ "graphical-session.target" ];
+      wantedBy = [ "graphical-session.target" ];
+    };
+
+
+    vuizvui.services.profpatsch.dunst.settings = {
+      global = {
+        icon_path = let
+          theme = cfg.iconTheme;
+
+          categories = [
+            "actions"
+            "animations"
+            "apps"
+            "categories"
+            "devices"
+            "emblems"
+            "emotes"
+            "filesystem"
+            "intl"
+            "mimetypes"
+            "places"
+            "status"
+            "stock"
+          ];
+        in lib.concatMapStringsSep ":"
+            (category: "${cfg.iconTheme.package}/share/icons/${theme.name}/${themeSize}/${category}")
+            categories;
+
+        dmenu = "${pkgs.dmenu}/bin/dmenu -p dunst:";
+        browser = "xdg-open";
+      };
+      # TODO: set better urgency colors for low and high
+      urgency_low = {
+        background = "#F1EAD7";
+        foreground = "#504D47";
+      };
+      urgency_normal = {
+        background = "#F1EAD7";
+        foreground = "#504D47";
+      };
+      urgency_high = {
+        background = "#F1EAD7";
+        foreground = "#504D47";
+      };
+    };
+
+  };
+
+}