aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/ui/wicked/init.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/awesome/ui/wicked/init.lua')
-rw-r--r--.config/awesome/ui/wicked/init.lua192
1 files changed, 109 insertions, 83 deletions
diff --git a/.config/awesome/ui/wicked/init.lua b/.config/awesome/ui/wicked/init.lua
index dea28d5..dd3324d 100644
--- a/.config/awesome/ui/wicked/init.lua
+++ b/.config/awesome/ui/wicked/init.lua
@@ -8,13 +8,14 @@ local qvars = require "quarrel.vars"
local wibox = require "wibox"
local rtimed = require("lib.rubato").timed
local easing = require("lib.rubato").easing
+local consts = require "ui.wicked.consts"
local gtimer = require "gears.timer"
local qcolor = require "quarrel.color"
local qmarkup = require "quarrel.markup"
local M = require "ui.wicked.consts"
-function M.new(n)
+function M.new(n, _, n_args)
local intertext_margin = (n.title ~= "" or n.message ~= "") and qui.PADDING or 0
local title_height = n.title ~= "" and qui.CHAR_HEIGHT or 0
local message_height = n.message ~= "" and qui.CHAR_HEIGHT or 0
@@ -25,7 +26,33 @@ function M.new(n)
app_name = n.app_name
end
- local notif = naughty.layout.box {
+ local w_progress, t_progress
+
+ local level_color = consts.LEVEL_COLORS[n_args.level] or (n.urgency == "critical" and qcolor.palette.yellow())
+
+ if n.timeout > 0 then
+ w_progress = wibox.widget {
+ widget = wibox.container.radialprogressbar,
+ max_value = M.NOTIF_TIMEOUT,
+ border_color = qcolor.palette.bg.lowest,
+ color = qcolor.palette.yellow(),
+ border_width = qui.PADDING / 2,
+ forced_height = qui.CHAR_HEIGHT,
+ forced_width = qui.CHAR_HEIGHT,
+ }
+
+ t_progress = rtimed {
+ duration = n.timeout,
+ pos = 0,
+ easing = easing.none,
+ clamp_position = true,
+ subscribed = function(pos)
+ w_progress.value = pos
+ end,
+ }
+ end
+
+ local w_notif = naughty.layout.box {
notification = n,
placement = function(d)
return awful.placement.right(d, {
@@ -50,6 +77,8 @@ function M.new(n)
{
qui.styled {
widget = wibox.container.background,
+ forced_width = beautiful.notification_max_width,
+ -- border_color = border_color,
point = function(geo, args)
return {
x = args.parent.width,
@@ -57,114 +86,111 @@ function M.new(n)
}
end,
{
+ widget = wibox.container.margin,
+ margins = qui.BIG_PADDING,
{
- widget = wibox.container.margin,
- margins = qui.BIG_PADDING,
- {
- {
- widget = wibox.widget.textbox,
- markup = qmarkup(app_name, { bold = true }),
- },
- nil,
- {
-
- widget = wibox.container.radialprogressbar,
- max_value = M.NOTIF_TIMEOUT,
- border_color = qcolor.palette.bg.lowest,
- color = qcolor.palette.yellow(),
- border_width = qui.BORDER_WIDTH,
- forced_height = qui.CHAR_HEIGHT,
- forced_width = qui.CHAR_HEIGHT,
- id = "progress",
- },
- layout = wibox.layout.align.horizontal,
- },
- },
- {
- widget = wibox.container.constraint,
- height = qui.BORDER_WIDTH,
- width = beautiful.notification_max_width,
- strategy = "exact",
- {
- widget = wibox.container.background,
- bg = qcolor.palette.border(),
- },
- },
- {
- widget = wibox.container.margin,
- margins = qui.BIG_PADDING,
{
widget = wibox.container.constraint,
- height = n.icon and qui.CHAR_HEIGHT * 2 + qui.PADDING
- or (title_height + message_height + intertext_margin),
- strategy = "exact",
+ width = beautiful.notification_max_width - (qui.BIG_PADDING + qui.BORDER_WIDTH) * 2 - (level_color and qui.BIG_PADDING + qui.PADDING or 0),
+ strategy = "max",
{
+ widget = wibox.container.place,
+ content_fill_horizontal = true,
{
- widget = wibox.container.background,
{
- widget = naughty.widget.icon,
- shape = qui.shape,
- notification = n,
+ {
+ widget = wibox.widget.textbox,
+ markup = qmarkup(app_name, { bold = true }),
+ },
+ nil,
+ w_progress,
+ layout = wibox.layout.align.horizontal,
},
- },
- {
{
widget = wibox.container.constraint,
- height = title_height,
+ height = qui.BORDER_WIDTH,
strategy = "exact",
{
- widget = wibox.widget.textbox,
- text = n.title or "",
+ widget = wibox.container.background,
+ bg = qcolor.palette.border(),
},
},
{
widget = wibox.container.constraint,
- height = message_height,
+ height = n.icon and qui.CHAR_HEIGHT * 2 + qui.PADDING
+ or (title_height + message_height + intertext_margin),
strategy = "exact",
{
- widget = wibox.widget.textbox,
- text = n.message or "",
+ {
+ widget = naughty.widget.icon,
+ shape = qui.shape,
+ notification = n,
+ },
+ {
+ {
+ widget = wibox.container.constraint,
+ height = title_height,
+ strategy = "exact",
+ {
+ widget = wibox.widget.textbox,
+ text = n.title or "",
+ },
+ },
+ {
+ widget = wibox.container.constraint,
+ height = message_height,
+ strategy = "exact",
+ {
+ widget = wibox.widget.textbox,
+ text = n.message or "",
+ },
+ },
+ spacing = intertext_margin,
+ layout = wibox.layout.fixed.vertical,
+ },
+ fill_space = true,
+ spacing = n.icon and qui.BIG_PADDING,
+ layout = wibox.layout.fixed.horizontal,
},
},
- spacing = intertext_margin,
layout = wibox.layout.fixed.vertical,
+ spacing = qui.BIG_PADDING,
},
- fill_space = true,
- spacing = n.icon and qui.BIG_PADDING or nil,
- layout = wibox.layout.fixed.horizontal,
},
},
+ -- {
+ -- widget = wibox.container.constraint,
+ -- strategy = "max",
+ -- widget = wibox.container.place,
+ {
+ forced_width = qui.PADDING,
+ widget = wibox.container.background,
+ bg = level_color,
+ shape = qui.shape,
+ -- },
+ },
+ layout = wibox.layout.fixed.horizontal,
+ spacing = level_color and qui.BIG_PADDING,
+ -- expand = "outside"
},
- layout = wibox.layout.fixed.vertical,
},
id = "bg",
},
layout = wibox.layout.manual,
- id = "manual",
},
},
}
local hiding = false
- local old_destroy = notif._private.destroy_callback
+ local old_destroy = w_notif._private.destroy_callback
- local progress = rtimed {
- duration = n.timeout,
- pos = 0,
- easing = easing.none,
- clamp_position = true,
- subscribed = function(pos)
- notif.widget:get_children_by_id("progress")[1].value = pos
- end,
- }
-
- local position = qanim:new {
+ local t_position = qanim:new {
duration = qvars.anim_duration,
pos = 0,
easing = qvars.easing,
subscribed = function(pos)
gtimer.delayed_call(function()
- notif.widget.widget:move(1, function(geo, args)
+ w_notif.widget.widget:move(1, function(geo, args)
if pos == 0 and hiding then
old_destroy()
end
@@ -176,30 +202,30 @@ function M.new(n)
end)
end,
}
- local opacity = rtimed {
+ local t_opacity = rtimed {
duration = qvars.anim_duration,
intro = qvars.anim_intro,
easing = easing.quadratic,
pos = 0,
clamp_position = true,
subscribed = function(pos)
- notif.opacity = pos
+ w_notif.opacity = pos
end,
}
- n:disconnect_signal("destroyed", notif._private.destroy_callback)
- function notif._private.destroy_callback()
- opacity.target = 0
- position:set(0)
+ n:disconnect_signal("destroyed", w_notif._private.destroy_callback)
+ function w_notif._private.destroy_callback()
+ t_opacity.target = 0
+ t_position:set(0)
hiding = true
end
- n:weak_connect_signal("destroyed", notif._private.destroy_callback)
+ n:weak_connect_signal("destroyed", w_notif._private.destroy_callback)
- --- for some reason when urgency is critical, it somehow makes it not disappear
- --- why? dunno, FIXME
- opacity.target = 1
- position:set(beautiful.notification_max_width)
- progress.target = M.NOTIF_TIMEOUT
+ t_opacity.target = 1
+ t_position:set(beautiful.notification_max_width)
+ if t_progress then
+ t_progress.target = M.NOTIF_TIMEOUT
+ end
end
return setmetatable(M, {