feat: add progress to wired-notify

This commit is contained in:
oddlama 2023-10-12 04:05:19 +02:00
parent f09c203f8f
commit 056fe1e7fe
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
3 changed files with 77 additions and 20 deletions

View file

@ -29,6 +29,7 @@
chromium
feh
gamescope
obsidian
pavucontrol
pinentry-gnome # For yubikey, gnome = gtk3 variant
thunderbird
@ -77,6 +78,7 @@
persistence."/persist".directories = [
"projects"
"Pictures" # config.xdg.userDirs.pictures (infinite recursion)
".config/obsidian"
];
};

View file

@ -59,8 +59,7 @@
name = "${name}_root";
parent = "";
hook = mkHook "TR" "TR";
offset = mkVec2 (-50) 50;
render_criteria = [];
offset = Vec2 (-50) 50; # Vec2 instead of mkVec2 to not apply scaling.
params = struct "NotificationBlock" (unnamedStruct {
monitor = 0;
border_width = globalScale * 2;
@ -122,33 +121,33 @@
}
];
mkBody = name: yoffset: [
mkBody = name: yOffset: [
{
name = "${name}_hint";
parent = "${name}_root";
hook = mkHook "TL" "TL";
offset = mkVec2 0 yoffset;
offset = mkVec2 0 yOffset;
params = struct "ImageBlock" (unnamedStruct {
filter_mode = mkLiteral "Lanczos3";
image_type = mkLiteral "Hint";
padding = mkPaddingLrBt 12 0 12 12;
rounding = globalScale * 9;
scale_height = floor (globalScale * 120);
scale_width = floor (globalScale * 120);
scale_height = floor (globalScale * 128);
scale_width = floor (globalScale * 128);
});
}
{
name = "${name}_summary";
parent = "${name}_hint";
hook = mkHook "TR" "TL";
offset = mkVec2 0 12;
offset = mkVec2 0 0;
params = struct "TextBlock" (unnamedStruct {
text = "%s";
font = "${fonts.sansSerif.name} Bold ${toString (globalScale * 16)}";
ellipsize = mkLiteral "End";
color = colors.base06;
padding = mkPaddingLrBt 16 16 0 2;
dimensions = mkDimensionsWH 572 572 0 30;
padding = mkPaddingLrBt 16 16 0 8;
dimensions = mkDimensionsWH 580 580 0 30;
dimensions_image_hint = mkDimensionsWH 440 440 0 30;
dimensions_image_both = mkDimensionsWH 440 440 0 30;
});
@ -158,18 +157,55 @@
parent = "${name}_summary";
hook = mkHook "BL" "TL";
offset = mkVec2 0 12;
render_criteria = [(mkLiteral "Body")];
params = struct "TextBlock" (unnamedStruct {
text = "%b";
font = "${fonts.sansSerif.name} ${toString (globalScale * 16)}";
ellipsize = mkLiteral "End";
color = colors.base06;
padding = mkPaddingLrBt 16 16 12 0;
dimensions = mkDimensionsWH 572 572 0 80;
dimensions_image_hint = mkDimensionsWH 440 440 0 80;
dimensions_image_both = mkDimensionsWH 440 440 0 80;
dimensions = mkDimensionsWH 580 580 0 88;
dimensions_image_hint = mkDimensionsWH 440 440 0 88;
dimensions_image_both = mkDimensionsWH 440 440 0 88;
});
}
];
mkProgress = name: yOffset: extra:
map (x: x // extra) [
{
name = "${name}_progress_${toString yOffset}_text";
parent = "${name}_root";
hook = mkHook "TL" "TL";
offset = mkVec2 0 0;
params = struct "TextBlock" (unnamedStruct {
text = "%p%";
font = "${fonts.monospace.name} Bold ${toString (globalScale * 14)}";
align = mkLiteral "Right";
ellipsize = mkLiteral "End";
color = colors.base06;
padding = mkPaddingLrBt 12 16 12 yOffset;
dimensions = mkDimensionsWH 48 48 24 24;
});
}
{
name = "${name}_progress_${toString yOffset}";
parent = "${name}_root";
hook = mkHook "TL" "TL";
offset = mkVec2 0 0;
params = struct "ProgressBlock" (unnamedStruct {
width = globalScale * 520;
height = globalScale * 12;
border_width = 0.0;
border_rounding = globalScale * 6;
border_color = colors.base03;
background_color = colors.base03;
fill_color = colors.base0D;
fill_rounding = globalScale * 6;
padding = mkPaddingLrBt 68 16 12 (yOffset + 8);
});
}
];
in
format.generate "wired.ron" (unnamedStruct {
max_notifications = 10;
@ -179,7 +215,7 @@
replacing_enabled = true;
replacing_resets_timeout = true;
min_window_width = floor (globalScale * 600);
min_window_height = floor (globalScale * 120);
min_window_height = floor (globalScale * 60);
debug = false;
# https://github.com/Toqozz/wired-notify/wiki/Shortcuts
@ -189,14 +225,31 @@
notification_action1 = 3; # middle click
};
layout_blocks = map unnamedStruct (lib.flatten [
(mkRootBlock "general"
// {
render_criteria = [];
layout_blocks = let
# Progress for body or hint-image notifications
# must be much closer to the bottom
bottomProgressCriteria = struct "Or" [
(mkLiteral "Body")
(mkLiteral "HintImage")
];
in
map unnamedStruct (lib.flatten [
(mkRootBlock "general")
(mkTopBar "general")
(mkBody "general" 36)
(mkProgress "general" 180 {
render_criteria = [
(struct "And" [
(mkLiteral "Progress")
bottomProgressCriteria
])
];
})
(mkTopBar "general")
(mkBody "general" 36)
]);
(mkProgress "general" 80 {
render_criteria = [(mkLiteral "Progress")];
render_anti_criteria = [bottomProgressCriteria];
})
]);
});
};
}