2021-10-24 15:50:13 +02:00
|
|
|
{ config, lib, pkgs, stdenv, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.twmn;
|
|
|
|
|
|
|
|
animationOpts = {
|
|
|
|
curve = mkOption {
|
|
|
|
type = types.ints.between 0 40;
|
|
|
|
default = 38;
|
|
|
|
example = 19;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-24 15:50:13 +02:00
|
|
|
The qt easing-curve animation to use for the animation. See
|
2023-07-01 01:30:13 +02:00
|
|
|
[
|
|
|
|
QEasingCurve documentation](https://doc.qt.io/qt-5/qeasingcurve.html#Type-enum).
|
2021-10-24 15:50:13 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
duration = mkOption {
|
|
|
|
type = types.ints.unsigned;
|
|
|
|
default = 1000;
|
|
|
|
example = 618;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "The animation duration in milliseconds.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in {
|
|
|
|
meta.maintainers = [ hm.maintainers.austreelis ];
|
|
|
|
|
|
|
|
options.services.twmn = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "twmn, a tiling window manager notification daemon";
|
2021-10-24 15:50:13 +02:00
|
|
|
|
|
|
|
duration = mkOption {
|
|
|
|
type = types.ints.unsigned;
|
|
|
|
default = 3000;
|
|
|
|
example = 5000;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-24 15:50:13 +02:00
|
|
|
The time each notification remains visible, in milliseconds.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
default = { };
|
|
|
|
example = literalExpression
|
|
|
|
''{ main.activation_command = "\${pkgs.hello}/bin/hello"; }'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-24 15:50:13 +02:00
|
|
|
Extra configuration options to add to the twmnd config file. See
|
2023-07-01 01:30:13 +02:00
|
|
|
<https://github.com/sboli/twmn/blob/master/README.md>
|
2021-10-24 15:50:13 +02:00
|
|
|
for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
host = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "127.0.0.1";
|
|
|
|
example = "laptop.lan";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Host address to listen on for notifications.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
icons = {
|
|
|
|
critical = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Path to the critical notifications' icon.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
info = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Path to the informative notifications' icon.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
warning = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Path to the warning notifications' icon.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 9797;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "UDP port to listen on for notifications.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
screen = mkOption {
|
|
|
|
type = types.nullOr types.int;
|
|
|
|
default = null;
|
|
|
|
example = 0;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-24 15:50:13 +02:00
|
|
|
Screen number to display notifications on when using a multi-head
|
|
|
|
desktop.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
soundCommand = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Command to execute to play a notification's sound.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
text = {
|
|
|
|
color = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "#999999";
|
|
|
|
example = "lightgray";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
Notification's text color. RGB hex and keywords (e.g. `lightgray`)
|
2021-10-24 15:50:13 +02:00
|
|
|
are supported.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
font = {
|
|
|
|
package = mkOption {
|
|
|
|
type = types.nullOr types.package;
|
|
|
|
default = null;
|
|
|
|
example = literalExpression "pkgs.dejavu_fonts";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
Notification text's font package. If `null` then
|
2021-10-24 15:50:13 +02:00
|
|
|
the font is assumed to already be available in your profile.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
family = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "Sans";
|
|
|
|
example = "Noto Sans";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Notification text's font family.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
size = mkOption {
|
|
|
|
type = types.ints.unsigned;
|
|
|
|
default = 13;
|
|
|
|
example = 42;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Notification text's font size.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
variant = mkOption {
|
|
|
|
# These are the font variant supported by twmn
|
|
|
|
# See https://github.com/sboli/twmn/blob/master/README.md?plain=1#L42
|
|
|
|
type = types.enum [
|
|
|
|
"oblique"
|
|
|
|
"italic"
|
|
|
|
"ultra-light"
|
|
|
|
"light"
|
|
|
|
"medium"
|
|
|
|
"semi-bold"
|
|
|
|
"bold"
|
|
|
|
"ultra-bold"
|
|
|
|
"heavy"
|
|
|
|
"ultra-condensed"
|
|
|
|
"extra-condensed"
|
|
|
|
"condensed"
|
|
|
|
"semi-condensed"
|
|
|
|
"semi-expanded"
|
|
|
|
"expanded"
|
|
|
|
"extra-expanded"
|
|
|
|
"ultra-expanded"
|
|
|
|
];
|
|
|
|
default = "medium";
|
|
|
|
example = "heavy";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Notification text's font variant.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
maxLength = mkOption {
|
|
|
|
type = types.nullOr types.ints.unsigned;
|
|
|
|
default = null;
|
|
|
|
example = 80;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-24 15:50:13 +02:00
|
|
|
Maximum length of the text before it is cut and suffixed with "...".
|
2023-07-01 01:30:13 +02:00
|
|
|
Never cuts if `null`.
|
2021-10-24 15:50:13 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
window = {
|
2023-07-02 01:45:18 +02:00
|
|
|
alwaysOnTop =
|
|
|
|
mkEnableOption "forcing the notification window to always be on top";
|
2021-10-24 15:50:13 +02:00
|
|
|
|
|
|
|
animation = {
|
|
|
|
easeIn = mkOption {
|
|
|
|
type = types.submodule { options = animationOpts; };
|
|
|
|
default = { };
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
curve = 19;
|
|
|
|
duration = 618;
|
|
|
|
}
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Options for the notification appearance's animation.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
easeOut = mkOption {
|
|
|
|
type = types.submodule { options = animationOpts; };
|
|
|
|
default = { };
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
curve = 19;
|
|
|
|
duration = 618;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description =
|
2023-07-02 01:45:18 +02:00
|
|
|
"Options for the notification disappearance's animation.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
bounce = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption
|
|
|
|
"notification bounce when displaying next notification directly";
|
2021-10-24 15:50:13 +02:00
|
|
|
|
|
|
|
duration = mkOption {
|
|
|
|
type = types.ints.unsigned;
|
|
|
|
default = 500;
|
|
|
|
example = 618;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "The bounce animation duration in milliseconds.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
color = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "#000000";
|
|
|
|
example = "lightgray";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-24 15:50:13 +02:00
|
|
|
Notification's background color. RGB hex and keywords (e.g.
|
2023-07-01 01:30:13 +02:00
|
|
|
`lightgray`) are supported.
|
2021-10-24 15:50:13 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
height = mkOption {
|
|
|
|
type = types.ints.unsigned;
|
|
|
|
default = 18;
|
|
|
|
example = 42;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-24 15:50:13 +02:00
|
|
|
Height of the slide bar. Useful to match your tiling window
|
|
|
|
manager's bar.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
offset = {
|
|
|
|
x = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 0;
|
|
|
|
example = 50;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-24 15:50:13 +02:00
|
|
|
Offset of the notification's slide starting point in pixels on the
|
|
|
|
horizontal axis (positive is rightward).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
y = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 0;
|
|
|
|
example = -100;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-24 15:50:13 +02:00
|
|
|
Offset of the notification's slide starting point in pixels on the
|
|
|
|
vertical axis (positive is upward).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
opacity = mkOption {
|
|
|
|
type = types.ints.between 0 100;
|
|
|
|
default = 100;
|
|
|
|
example = 80;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "The notification window's opacity.";
|
2021-10-24 15:50:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
position = mkOption {
|
|
|
|
type = types.enum [
|
|
|
|
"tr"
|
|
|
|
"top_right"
|
|
|
|
"tl"
|
|
|
|
"top_left"
|
|
|
|
"br"
|
|
|
|
"bottom_right"
|
|
|
|
"bl"
|
|
|
|
"bottom_left"
|
|
|
|
"tc"
|
|
|
|
"top_center"
|
|
|
|
"bc"
|
|
|
|
"bottom_center"
|
|
|
|
"c"
|
|
|
|
"center"
|
|
|
|
];
|
|
|
|
default = "top_right";
|
|
|
|
example = "bottom_left";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-24 15:50:13 +02:00
|
|
|
Position of the notification slide. The notification will slide
|
|
|
|
in vertically from the border if placed in
|
2023-07-01 01:30:13 +02:00
|
|
|
`top_center` or `bottom_center`,
|
2021-10-24 15:50:13 +02:00
|
|
|
horizontally otherwise.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
#################
|
|
|
|
# Implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "services.twmn" pkgs
|
|
|
|
lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
|
|
|
home.packages =
|
|
|
|
lib.optional (!isNull cfg.text.font.package) cfg.text.font.package
|
|
|
|
++ [ pkgs.twmn ];
|
|
|
|
|
|
|
|
xdg.configFile."twmn/twmn.conf".text = let
|
|
|
|
conf = recursiveUpdate {
|
|
|
|
gui = {
|
|
|
|
always_on_top = if cfg.window.alwaysOnTop then "true" else "false";
|
|
|
|
background_color = cfg.window.color;
|
|
|
|
bounce =
|
|
|
|
if cfg.window.animation.bounce.enable then "true" else "false";
|
|
|
|
bounce_duration = toString cfg.window.animation.bounce.duration;
|
|
|
|
font = cfg.text.font.family;
|
|
|
|
font_size = toString cfg.text.font.size;
|
|
|
|
font_variant = cfg.text.font.variant;
|
|
|
|
foreground_color = cfg.text.color;
|
|
|
|
height = toString cfg.window.height;
|
|
|
|
in_animation = toString cfg.window.animation.easeIn.curve;
|
|
|
|
in_animation_duration = toString cfg.window.animation.easeIn.duration;
|
|
|
|
max_length = toString
|
|
|
|
(if isNull cfg.text.maxLength then -1 else cfg.text.maxLength);
|
|
|
|
offset_x = with cfg.window.offset;
|
|
|
|
if x < 0 then toString x else "+${toString x}";
|
|
|
|
offset_y = with cfg.window.offset;
|
|
|
|
if y < 0 then toString y else "+${toString y}";
|
|
|
|
opacity = toString cfg.window.opacity;
|
|
|
|
out_animation = toString cfg.window.animation.easeOut.curve;
|
|
|
|
out_animation_duration =
|
|
|
|
toString cfg.window.animation.easeOut.duration;
|
|
|
|
position = cfg.window.position;
|
|
|
|
screen = toString cfg.screen;
|
|
|
|
};
|
|
|
|
# map null values to empty strings because formats.toml generator fails
|
|
|
|
# when encountering a null.
|
|
|
|
icons = mapAttrs (_: toString) cfg.icons;
|
|
|
|
main = {
|
|
|
|
duration = toString cfg.duration;
|
|
|
|
host = cfg.host;
|
|
|
|
port = toString cfg.port;
|
|
|
|
sound_command = cfg.soundCommand;
|
|
|
|
};
|
|
|
|
} cfg.extraConfig;
|
|
|
|
|
|
|
|
mkLine = name: value: "${name}=${value}";
|
|
|
|
|
|
|
|
mkSection = section: conf: ''
|
|
|
|
[${section}]
|
|
|
|
${concatStringsSep "\n" (mapAttrsToList mkLine conf)}
|
|
|
|
'';
|
|
|
|
in concatStringsSep "\n" (mapAttrsToList mkSection conf) + "\n";
|
|
|
|
|
|
|
|
systemd.user.services.twmnd = {
|
|
|
|
Unit = {
|
|
|
|
Description = "twmn daemon";
|
|
|
|
After = [ "graphical-session-pre.target" ];
|
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
X-Restart-Triggers =
|
|
|
|
[ "${config.xdg.configFile."twmn/twmn.conf".source}" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
Install.WantedBy = [ "graphical-session.target" ];
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
ExecStart = "${pkgs.twmn}/bin/twmnd";
|
|
|
|
Restart = "on-failure";
|
|
|
|
Type = "simple";
|
|
|
|
StandardOutput = "null";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|