nixos/users/malte/mako.nix

74 lines
1.8 KiB
Nix

{ pkgs, config, ... }:
let
col = config.colors;
format = { bg, fg }:
''
<span background="${bg.hashRgb}" foreground="${fg.hashRgb}"><b> %s </b></span> %b'';
in {
programs.mako = {
enable = true;
anchor = "top-right";
font = "FiraCode Nerd Font 11";
backgroundColor = col.foreground.hashRgb;
textColor = col.background.hashRgb;
borderColor = (col.foreground.darker 0.4).hashRgb;
borderSize = 2;
defaultTimeout = 4000;
width = 500;
height = 200;
format = format {
fg = col.foreground;
bg = col.background;
};
layer = "overlay";
extraConfig = ''
[urgency=low]
default-timeout=2000
[urgency=normal]
format=${
format {
bg = col.warn;
fg = col.background;
}
}
default-timeout=3000
[urgency=high]
format=${
format {
bg = col.error;
fg = col.background;
}
}
default-timeout=10000
'';
};
# This should really use the upstream service file, but I'm too lazy
# https://github.com/emersion/mako/blob/aafbc91da038e5a6ebab67a66a644487db3410d7/contrib/systemd/mako.service
systemd.user.services."mako" = {
Unit = {
Description = "Lightweight Wayland notification daemon";
Documentation = "man:mako(1)";
PartOf = "graphical-session.target";
After = "graphical-session.target";
};
Service = {
Type = "dbus";
BusName = "org.freedesktop.Notifications";
ExecCondition = "/bin/sh -c '[ -n \"$WAYLAND_DISPLAY\" ]'";
ExecStart = "${pkgs.mako}/bin/mako";
ExecReload = "${pkgs.mako}/bin/makoctl reload";
Restart = "always";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
};
home.packages = [ pkgs.firaCodeNerd ];
}