From 056fe1e7fe0eea034b641ba18d26333098239aea Mon Sep 17 00:00:00 2001 From: oddlama Date: Thu, 12 Oct 2023 04:05:19 +0200 Subject: [PATCH] feat: add progress to wired-notify --- pkgs/ron.nix | 2 + users/myuser/graphical/default.nix | 2 + users/myuser/graphical/wired-notify.nix | 93 +++++++++++++++++++------ 3 files changed, 77 insertions(+), 20 deletions(-) diff --git a/pkgs/ron.nix b/pkgs/ron.nix index 821dfc8..5a61c73 100644 --- a/pkgs/ron.nix +++ b/pkgs/ron.nix @@ -86,6 +86,8 @@ entriesStr = if value ? _ronType then specialType indent value + else if builtins.isList value + then list newIndent value else let entries = mapAttrsToList toEntry value; entriesStrSpace = concatStringsSep ", " entries; diff --git a/users/myuser/graphical/default.nix b/users/myuser/graphical/default.nix index cab7c2f..56b1e43 100644 --- a/users/myuser/graphical/default.nix +++ b/users/myuser/graphical/default.nix @@ -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" ]; }; diff --git a/users/myuser/graphical/wired-notify.nix b/users/myuser/graphical/wired-notify.nix index 84a052e..fd7220c 100644 --- a/users/myuser/graphical/wired-notify.nix +++ b/users/myuser/graphical/wired-notify.nix @@ -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]; + }) + ]); }); }; }