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;
|
2018-12-05 10:53:17 +00:00
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
eitherStrBoolIntList = with types;
|
|
|
|
either str (either bool (either int (listOf str)));
|
2018-12-05 10:53:17 +00:00
|
|
|
|
2017-10-09 09:20:12 +00:00
|
|
|
toDunstIni = generators.toINI {
|
|
|
|
mkKeyValue = key: value:
|
2020-02-01 23:39:17 +00:00
|
|
|
let
|
|
|
|
value' = if isBool value then
|
2022-04-08 04:36:13 +00:00
|
|
|
(lib.hm.booleans.yesNo value)
|
2020-02-01 23:39:17 +00:00
|
|
|
else if isString value then
|
|
|
|
''"${value}"''
|
|
|
|
else
|
|
|
|
toString value;
|
|
|
|
in "${key}=${value'}";
|
2017-10-09 09:20:12 +00:00
|
|
|
};
|
|
|
|
|
2017-11-06 23:27:46 +00:00
|
|
|
themeType = types.submodule {
|
|
|
|
options = {
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
2021-10-09 09:14:08 +00:00
|
|
|
example = literalExpression "pkgs.gnome.adwaita-icon-theme";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = "Package providing the theme.";
|
2017-11-06 23:27:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "Adwaita";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = "The name of the theme within the package.";
|
2017-11-06 23:27:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
size = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "32x32";
|
|
|
|
example = "16x16";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = "The desired icon size.";
|
2017-11-06 23:27:46 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
hicolorTheme = {
|
2020-06-06 12:52:22 +00:00
|
|
|
package = pkgs.hicolor-icon-theme;
|
2017-11-06 23:27:46 +00:00
|
|
|
name = "hicolor";
|
|
|
|
size = "32x32";
|
|
|
|
};
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
in {
|
2017-09-26 21:40:31 +00:00
|
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
|
2017-01-07 18:16:26 +00:00
|
|
|
options = {
|
|
|
|
services.dunst = {
|
2023-07-01 23:45:18 +00:00
|
|
|
enable = mkEnableOption "the dunst notification daemon";
|
2017-01-07 18:16:26 +00:00
|
|
|
|
2021-04-25 05:56:48 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.dunst;
|
2021-10-09 09:14:08 +00:00
|
|
|
defaultText = literalExpression "pkgs.dunst";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = "Package providing {command}`dunst`.";
|
2021-04-25 05:56:48 +00:00
|
|
|
};
|
|
|
|
|
2021-08-08 00:44:36 +00:00
|
|
|
configFile = mkOption {
|
|
|
|
type = with types; either str path;
|
|
|
|
default = "${config.xdg.configHome}/dunst/dunstrc";
|
|
|
|
defaultText = "$XDG_CONFIG_HOME/dunst/dunstrc";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2021-08-08 00:44:36 +00:00
|
|
|
Path to the configuration file read by dunst.
|
2023-06-30 23:30:13 +00:00
|
|
|
|
2021-08-08 00:44:36 +00:00
|
|
|
Note that the configuration generated by Home Manager will be
|
2023-06-30 23:30:13 +00:00
|
|
|
written to {file}`$XDG_CONFIG_HOME/dunst/dunstrc`
|
2021-08-08 00:44:36 +00:00
|
|
|
regardless. This allows using a mutable configuration file generated
|
|
|
|
from the immutable one, useful in scenarios where live reloading is
|
|
|
|
desired.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-11-06 23:27:46 +00:00
|
|
|
iconTheme = mkOption {
|
|
|
|
type = themeType;
|
|
|
|
default = hicolorTheme;
|
2023-07-01 23:45:18 +00:00
|
|
|
description = "Set the icon theme.";
|
2017-11-06 23:27:46 +00:00
|
|
|
};
|
|
|
|
|
2021-04-25 05:56:48 +00:00
|
|
|
waylandDisplay = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2023-07-01 23:45:18 +00:00
|
|
|
description =
|
2023-06-30 23:30:13 +00:00
|
|
|
"Set the service's {env}`WAYLAND_DISPLAY` environment variable.";
|
2021-04-25 05:56:48 +00:00
|
|
|
};
|
|
|
|
|
2017-01-07 18:16:26 +00:00
|
|
|
settings = mkOption {
|
2021-06-17 01:06:16 +00:00
|
|
|
type = types.submodule {
|
|
|
|
freeformType = with types; attrsOf (attrsOf eitherStrBoolIntList);
|
|
|
|
options = {
|
|
|
|
global.icon_path = mkOption {
|
|
|
|
type = types.separatedString ":";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = "Paths where dunst will look for icons.";
|
2021-06-17 01:06:16 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2020-02-01 23:39:17 +00:00
|
|
|
default = { };
|
2023-07-01 23:45:18 +00:00
|
|
|
description =
|
2023-06-30 23:30:13 +00:00
|
|
|
"Configuration written to {file}`$XDG_CONFIG_HOME/dunst/dunstrc`.";
|
2021-10-09 09:14:08 +00:00
|
|
|
example = literalExpression ''
|
2017-10-09 09:20:12 +00:00
|
|
|
{
|
|
|
|
global = {
|
2022-06-20 06:07:29 +00:00
|
|
|
width = 300;
|
|
|
|
height = 300;
|
|
|
|
offset = "30x50";
|
|
|
|
origin = "top-right";
|
2017-10-09 09:20:12 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
|
|
{
|
2022-04-24 14:25:54 +00:00
|
|
|
assertions = [
|
|
|
|
(hm.assertions.assertPlatform "services.dunst" pkgs platforms.linux)
|
|
|
|
];
|
|
|
|
|
2021-06-05 21:31:50 +00:00
|
|
|
home.packages = [ cfg.package ];
|
2020-03-22 20:08:45 +00:00
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
xdg.dataFile."dbus-1/services/org.knopwob.dunst.service".source =
|
|
|
|
"${pkgs.dunst}/share/dbus-1/services/org.knopwob.dunst.service";
|
|
|
|
|
|
|
|
services.dunst.settings.global.icon_path = let
|
|
|
|
useCustomTheme = cfg.iconTheme.package != hicolorTheme.package
|
|
|
|
|| cfg.iconTheme.name != hicolorTheme.name || cfg.iconTheme.size
|
|
|
|
!= hicolorTheme.size;
|
|
|
|
|
|
|
|
basePaths = [
|
|
|
|
"/run/current-system/sw"
|
|
|
|
config.home.profileDirectory
|
|
|
|
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"
|
2020-12-18 18:41:39 +00:00
|
|
|
"legacy"
|
2020-02-01 23:39:17 +00:00
|
|
|
"mimetypes"
|
|
|
|
"places"
|
|
|
|
"status"
|
|
|
|
"stock"
|
|
|
|
];
|
2021-06-17 01:06:16 +00:00
|
|
|
|
|
|
|
mkPath = { basePath, theme, category }:
|
|
|
|
"${basePath}/share/icons/${theme.name}/${theme.size}/${category}";
|
|
|
|
in concatMapStringsSep ":" mkPath (cartesianProductOfSets {
|
|
|
|
basePath = basePaths;
|
|
|
|
theme = themes;
|
|
|
|
category = categories;
|
|
|
|
});
|
2020-02-01 23:39:17 +00:00
|
|
|
|
|
|
|
systemd.user.services.dunst = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Dunst notification daemon";
|
|
|
|
After = [ "graphical-session-pre.target" ];
|
|
|
|
PartOf = [ "graphical-session.target" ];
|
2017-10-09 09:20:12 +00:00
|
|
|
};
|
2020-02-01 23:39:17 +00:00
|
|
|
|
|
|
|
Service = {
|
|
|
|
Type = "dbus";
|
|
|
|
BusName = "org.freedesktop.Notifications";
|
2021-08-08 00:44:36 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/dunst -config ${cfg.configFile}";
|
2021-04-25 05:56:48 +00:00
|
|
|
Environment = optionalString (cfg.waylandDisplay != "")
|
|
|
|
"WAYLAND_DISPLAY=${cfg.waylandDisplay}";
|
2019-01-13 22:48:20 +00:00
|
|
|
};
|
2020-02-01 23:39:17 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
(mkIf (cfg.settings != { }) {
|
|
|
|
xdg.configFile."dunst/dunstrc" = {
|
|
|
|
text = toDunstIni cfg.settings;
|
|
|
|
onChange = ''
|
2021-07-31 22:54:47 +00:00
|
|
|
${pkgs.procps}/bin/pkill -u "$USER" ''${VERBOSE+-e} dunst || true
|
2020-02-01 23:39:17 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
})
|
|
|
|
]);
|
2017-01-07 18:16:26 +00:00
|
|
|
}
|