update notifications

This commit is contained in:
gnat 2024-11-18 17:34:41 -08:00
parent 0cf8c0d102
commit 460c2589cc
2 changed files with 51 additions and 33 deletions

View File

@ -21,7 +21,10 @@ local notification_icon = function(n)
end end
local make_notification = function(n) local make_notification = function(n)
print(n:get_urgency())
local layout = Widget.Box({ local layout = Widget.Box({
children = {
Widget.Box({
vertical = true, vertical = true,
css = 'min-width: 200px; min-height: 50px;', css = 'min-width: 200px; min-height: 50px;',
children = { children = {
@ -35,28 +38,27 @@ local make_notification = function(n)
class_name = 'title', class_name = 'title',
label = n.summary, label = n.summary,
xalign = 0, xalign = 0,
max_width_chars = 32, justify = 0,
justify = 0 ellipsize = pango.EllipsizeMode.END,
}), }),
Widget.Label({ Widget.Label({
class_name = 'body', class_name = 'body',
label = n.body, label = n.body,
xalign = 0, xalign = 0,
justify = 0, justify = 0,
max_width_chars = 32,
wrap = true, wrap = true,
wrap_mode = pango.WrapMode.WORD_CHAR, wrap_mode = pango.WrapMode.WORD_CHAR,
use_markup = true use_markup = true
}) })
} }
}) }),
} }
}), }),
Widget.ProgressBar({ Widget.ProgressBar({
class_name = 'timeout-bar', class_name = 'timeout-bar',
hexpand = true, hexpand = true,
valign = 2, valign = 2,
fraction = bind(Variable(1):poll(((n.expire_timeout > 0 and n.expire_timeout or popup_timeout_seconds) * 1000 + 255) // 100, function(prev) 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 if prev > .01 then
return prev - .01 return prev - .01
end end
@ -64,6 +66,11 @@ local make_notification = function(n)
end)), end)),
}) })
} }
}),
Widget.Box({
class_name = 'urgency-indicator ' .. n.urgency
})
}
}) })
return Widget.Revealer({ return Widget.Revealer({
@ -71,7 +78,7 @@ local make_notification = function(n)
transition_duration = 250, transition_duration = 250,
class_name = 'notifications', class_name = 'notifications',
child = Widget.Revealer({ child = Widget.Revealer({
transition_type = 'SLIDE_LEFT', transition_type = 'SLIDE_DOWN',
transition_duration = 250, transition_duration = 250,
child = layout, child = layout,
setup = function(self) setup = function(self)

View File

@ -1,9 +1,8 @@
.notifications { .notifications {
> * { > * {
> box { > box {
margin: 10px 20px; margin: 10px 15px;
border: 1px solid $fg; border: 1px solid $fg;
border-right: none;
background: $bg; background: $bg;
.title { .title {
@ -27,6 +26,18 @@
background-color: $hl-alt-1; background-color: $hl-alt-1;
} }
} }
.urgency-indicator {
min-width: 25px;
&.NORMAL, &.LOW {
background: $hl-alt-2;
}
&.CRITICAL {
background: $hl;
}
}
} }
} }
} }