2017-01-07 18:16:26 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2017-10-09 09:20:12 +00:00
|
|
|
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'}";
|
|
|
|
};
|
|
|
|
|
2017-11-06 23:27:46 +00:00
|
|
|
themeType = types.submodule {
|
|
|
|
options = {
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
example = literalExample "pkgs.gnome3.adwaita-icon-theme";
|
|
|
|
description = "Package providing the theme.";
|
|
|
|
};
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "Adwaita";
|
|
|
|
description = "The name of the theme within the package.";
|
|
|
|
};
|
|
|
|
|
|
|
|
size = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "32x32";
|
|
|
|
example = "16x16";
|
|
|
|
description = "The desired icon size.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
hicolorTheme = {
|
|
|
|
package = pkgs.hicolor_icon_theme;
|
|
|
|
name = "hicolor";
|
|
|
|
size = "32x32";
|
|
|
|
};
|
|
|
|
|
2017-10-09 09:20:12 +00:00
|
|
|
in
|
|
|
|
|
2017-01-07 18:16:26 +00:00
|
|
|
{
|
2017-09-26 21:40:31 +00:00
|
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
|
2017-01-07 18:16:26 +00:00
|
|
|
options = {
|
|
|
|
services.dunst = {
|
|
|
|
enable = mkEnableOption "the dunst notification daemon";
|
|
|
|
|
2017-11-06 23:27:46 +00:00
|
|
|
iconTheme = mkOption {
|
|
|
|
type = themeType;
|
|
|
|
default = hicolorTheme;
|
|
|
|
description = "Set the icon theme.";
|
|
|
|
};
|
|
|
|
|
2017-01-07 18:16:26 +00:00
|
|
|
settings = mkOption {
|
2017-10-09 09:20:12 +00:00
|
|
|
type = types.attrsOf types.attrs;
|
2017-01-07 18:16:26 +00:00
|
|
|
default = {};
|
|
|
|
description = "Configuration written to ~/.config/dunstrc";
|
2017-10-09 09:20:12 +00:00
|
|
|
example = literalExample ''
|
|
|
|
{
|
|
|
|
global = {
|
|
|
|
geometry = "300x5-30+50";
|
|
|
|
transparency = 10;
|
|
|
|
frame_color = "#eceff1";
|
|
|
|
font = "Droid Sans 9";
|
|
|
|
};
|
|
|
|
|
|
|
|
urgency_normal = {
|
|
|
|
background = "#37474f";
|
|
|
|
foreground = "#eceff1";
|
|
|
|
timeout = 10;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
'';
|
2017-01-07 18:16:26 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-10-09 09:20:12 +00:00
|
|
|
config = mkIf cfg.enable (
|
|
|
|
mkMerge [
|
|
|
|
{
|
2017-11-10 23:31:44 +00:00
|
|
|
xdg.dataFile."dbus-1/services/org.knopwob.dunst.service".source =
|
2017-10-09 09:20:12 +00:00
|
|
|
"${pkgs.dunst}/share/dbus-1/services/org.knopwob.dunst.service";
|
2017-01-07 18:16:26 +00:00
|
|
|
|
2017-11-06 23:27:46 +00:00
|
|
|
services.dunst.settings.global.icon_folders =
|
|
|
|
let
|
|
|
|
useCustomTheme =
|
|
|
|
cfg.iconTheme.package != hicolorTheme.package
|
|
|
|
|| cfg.iconTheme.name != hicolorTheme.name
|
|
|
|
|| cfg.iconTheme.size != hicolorTheme.size;
|
|
|
|
|
|
|
|
basePaths = [
|
|
|
|
"/run/current-system/sw"
|
2018-07-29 16:15:50 +00:00
|
|
|
config.home.profileDirectory
|
2017-11-06 23:27:46 +00:00
|
|
|
cfg.iconTheme.package
|
|
|
|
] ++ optional useCustomTheme hicolorTheme.package;
|
|
|
|
|
|
|
|
themes =
|
|
|
|
[
|
|
|
|
cfg.iconTheme
|
|
|
|
] ++ optional useCustomTheme (
|
|
|
|
hicolorTheme // { size = cfg.iconTheme.size; }
|
|
|
|
);
|
|
|
|
|
|
|
|
categories = [
|
|
|
|
"actions"
|
|
|
|
"animations"
|
|
|
|
"apps"
|
|
|
|
"categories"
|
|
|
|
"devices"
|
|
|
|
"emblems"
|
|
|
|
"emotes"
|
|
|
|
"filesystem"
|
|
|
|
"intl"
|
|
|
|
"mimetypes"
|
|
|
|
"places"
|
|
|
|
"status"
|
|
|
|
"stock"
|
|
|
|
];
|
|
|
|
in
|
|
|
|
concatStringsSep ":" (
|
|
|
|
concatMap (theme:
|
|
|
|
concatMap (basePath:
|
|
|
|
map (category:
|
|
|
|
"${basePath}/share/icons/${theme.name}/${theme.size}/${category}"
|
|
|
|
) categories
|
|
|
|
) basePaths
|
|
|
|
) themes
|
|
|
|
);
|
|
|
|
|
2017-10-09 09:20:12 +00:00
|
|
|
systemd.user.services.dunst = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Dunst notification daemon";
|
|
|
|
After = [ "graphical-session-pre.target" ];
|
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
2017-01-07 18:16:26 +00:00
|
|
|
|
2017-10-09 09:20:12 +00:00
|
|
|
Service = {
|
|
|
|
Type = "dbus";
|
|
|
|
BusName = "org.freedesktop.Notifications";
|
|
|
|
ExecStart = "${pkgs.dunst}/bin/dunst";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
(mkIf (cfg.settings != {}) {
|
2017-10-24 16:30:35 +00:00
|
|
|
xdg.configFile."dunst/dunstrc".text = toDunstIni cfg.settings;
|
2017-10-09 09:20:12 +00:00
|
|
|
})
|
|
|
|
]
|
|
|
|
);
|
2017-01-07 18:16:26 +00:00
|
|
|
}
|