From 460c2589cc7e69007ea5519ac6f065de97020818 Mon Sep 17 00:00:00 2001 From: gnat Date: Mon, 18 Nov 2024 17:34:41 -0800 Subject: [PATCH] update notifications --- lua/widgets/notifications/init.lua | 69 ++++++++++++++++-------------- style/widgets/notifications.scss | 15 ++++++- 2 files changed, 51 insertions(+), 33 deletions(-) diff --git a/lua/widgets/notifications/init.lua b/lua/widgets/notifications/init.lua index 581f046..da92901 100644 --- a/lua/widgets/notifications/init.lua +++ b/lua/widgets/notifications/init.lua @@ -21,47 +21,54 @@ local notification_icon = function(n) end local make_notification = function(n) + print(n:get_urgency()) local layout = Widget.Box({ - vertical = true, - css = 'min-width: 200px; min-height: 50px;', children = { Widget.Box({ + vertical = true, + css = 'min-width: 200px; min-height: 50px;', children = { - notification_icon(n), Widget.Box({ - vertical = true, children = { - Widget.Label({ - class_name = 'title', - label = n.summary, - xalign = 0, - max_width_chars = 32, - justify = 0 + notification_icon(n), + Widget.Box({ + vertical = true, + children = { + Widget.Label({ + class_name = 'title', + label = n.summary, + xalign = 0, + justify = 0, + ellipsize = pango.EllipsizeMode.END, + }), + Widget.Label({ + class_name = 'body', + label = n.body, + xalign = 0, + justify = 0, + wrap = true, + wrap_mode = pango.WrapMode.WORD_CHAR, + use_markup = true + }) + } }), - Widget.Label({ - class_name = 'body', - label = n.body, - xalign = 0, - justify = 0, - max_width_chars = 32, - wrap = true, - wrap_mode = pango.WrapMode.WORD_CHAR, - use_markup = true - }) } + }), + Widget.ProgressBar({ + class_name = 'timeout-bar', + hexpand = true, + valign = 2, + fraction = bind(Variable(1):poll(((n.expire_timeout > 0 and n.expire_timeout or popup_timeout_seconds) * 1000 + 250) // 100, function(prev) + if prev > .01 then + return prev - .01 + end + return 0 + end)), }) } }), - Widget.ProgressBar({ - class_name = 'timeout-bar', - hexpand = true, - valign = 2, - fraction = bind(Variable(1):poll(((n.expire_timeout > 0 and n.expire_timeout or popup_timeout_seconds) * 1000 + 255) // 100, function(prev) - if prev > .01 then - return prev - .01 - end - return 0 - end)), + Widget.Box({ + class_name = 'urgency-indicator ' .. n.urgency }) } }) @@ -71,7 +78,7 @@ local make_notification = function(n) transition_duration = 250, class_name = 'notifications', child = Widget.Revealer({ - transition_type = 'SLIDE_LEFT', + transition_type = 'SLIDE_DOWN', transition_duration = 250, child = layout, setup = function(self) diff --git a/style/widgets/notifications.scss b/style/widgets/notifications.scss index aadc718..1c2a92c 100644 --- a/style/widgets/notifications.scss +++ b/style/widgets/notifications.scss @@ -1,9 +1,8 @@ .notifications { > * { > box { - margin: 10px 20px; + margin: 10px 15px; border: 1px solid $fg; - border-right: none; background: $bg; .title { @@ -27,6 +26,18 @@ background-color: $hl-alt-1; } } + + .urgency-indicator { + min-width: 25px; + + &.NORMAL, &.LOW { + background: $hl-alt-2; + } + + &.CRITICAL { + background: $hl; + } + } } } }