aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/ui/wicked
diff options
context:
space:
mode:
Diffstat (limited to '.config/awesome/ui/wicked')
-rw-r--r--.config/awesome/ui/wicked/_default.lua94
-rw-r--r--.config/awesome/ui/wicked/init.lua258
-rw-r--r--.config/awesome/ui/wicked/widgets/message.lua0
3 files changed, 182 insertions, 170 deletions
diff --git a/.config/awesome/ui/wicked/_default.lua b/.config/awesome/ui/wicked/_default.lua
deleted file mode 100644
index 25283f9..0000000
--- a/.config/awesome/ui/wicked/_default.lua
+++ /dev/null
@@ -1,94 +0,0 @@
-----------------------------------------------------------------------------
---- The default widget template for the notifications.
---
--- @author Emmanuel Lepage Vallee <elv1313@gmail.com>
--- @copyright 2019 Emmanuel Lepage Vallee
--- @classmod naughty.widget._default
-----------------------------------------------------------------------------
-
-local wibox = require("wibox")
-local actionlist = require("naughty.list.actions")
-local wtitle = require("naughty.widget.title")
-local wmessage = require("naughty.widget.message")
-local wicon = require("naughty.widget.icon")
-local wbg = require("naughty.container.background")
-local beautiful = require("beautiful")
-local dpi = require("beautiful").xresources.apply_dpi
-
--- It is not worth doing a special widget for this.
-local function notif_size()
- local constraint = wibox.container.constraint()
- constraint:set_strategy("max")
- constraint:set_width(beautiful.notification_max_width or dpi(500))
-
- rawset(constraint, "set_notification", function(_, notif)
- constraint._private.notification = setmetatable({notif}, {__mode = "v"})
- local s = false
-
- if notif.width and notif.width ~= beautiful.notification_max_width then
- constraint.width = notif.width
- s = true
- end
- if notif.height then
- constraint.height = notif.height
- s = true
- end
-
- constraint.strategy = s and "exact" or "max"
- end)
-
- rawset(constraint, "get_notification", function()
- return constraint._private.notification[1]
- end)
-
- return constraint
-end
-
--- It is not worth doing a special widget for this either.
-local function notif_margins()
- local margins = wibox.container.margin()
- margins:set_margins(beautiful.notification_margin or 4)
-
- rawset(margins, "set_notification", function(_, notif)
- if notif.margin then
- margins:set_margins(notif.margin)
- end
- end)
-
- return margins
-end
-
--- Used as a fallback when no widget_template is provided, emulate the legacy
--- widget.
-return {
- {
- {
- {
- {
- wicon,
- {
- widget = wibox.container.place,
- valign = "center",
- halign = "center",
- {
- wtitle,
- wmessage,
- -- spacing = 4,
- layout = wibox.layout.fixed.vertical,
- }
- },
- fill_space = true,
- -- spacing = 4,
- layout = wibox.layout.fixed.horizontal
- },
- actionlist,
- -- spacing = 10,
- layout = wibox.layout.fixed.vertical,
- },
- widget = notif_margins,
- },
- id = "background_role",
- widget = wbg,
- },
- widget = notif_size,
-}
diff --git a/.config/awesome/ui/wicked/init.lua b/.config/awesome/ui/wicked/init.lua
index 76d77cf..ddbf912 100644
--- a/.config/awesome/ui/wicked/init.lua
+++ b/.config/awesome/ui/wicked/init.lua
@@ -1,97 +1,203 @@
local awful = require "awful"
-local debug = require "gears.debug"
-local default = require "ui.wicked._default"
-local gtimer = require "gears.timer"
+local beautiful = require "beautiful"
+local gshape = require "gears.shape"
local naughty = require "naughty"
local qui = require "quarrel.ui"
local qvars = require "quarrel.vars"
--- local rubato = require "lib.rubato"
local wibox = require "wibox"
+local rtimed = require("lib.rubato").timed
+local easing = require("lib.rubato").easing
+local gtimer = require "gears.timer"
+local qmarkup = require "quarrel.markup"
-local wicked = {}
+return function(n)
+ local intertext_margin = (n.title ~= "" or n.message ~= "") and qvars.padding or 0
+ local title_height = n.title ~= "" and qvars.char_height or 0
+ local message_height = n.message ~= "" and qvars.char_height or 0
+ -- local app_name_height = n.app_name ~= "" and
+ local app_name
+ if n.app_name == "" then
+ app_name = n._private._foreign and "Unknown" or "Awesome"
+ else
+ app_name = n.app_name
+ end
-wicked._active_notififcations = {}
+ local notif = naughty.layout.box {
+ notification = n,
+ placement = function(d)
+ return awful.placement.right(d, {
+ margins = beautiful.useless_gap * 2,
+ })
+ end,
+ bg = qvars.colors.transparent,
+ border_width = 0,
+ shape = gshape.rectangle,
+ widget_template = {
+ widget = wibox.container.constraint,
+ height = qvars.big_padding * 2
+ + qvars.char_height
+ + qvars.border_width
+ + qvars.big_padding * 2
+ -- + title_height
+ -- + message_height
+ -- + intertext_margin,
+ + (
+ n.icon and qvars.char_height * 2 + qvars.padding
+ or (title_height + message_height + intertext_margin)
+ ),
-function wicked:notify(n)
- -- local notif = wibox.widget {
- local notif = qui.popup {
- -- widget = {
- -- {
- -- {
- -- widget = naughty.widget.icon,
- -- notification = n,
- -- forced_height = 0,
- -- forced_width = 0,
- -- clip_shape = qvars.shape,
- -- id = "icon_role"
- -- },
- -- {
- -- {
- -- widget = naughty.widget.title,
- -- notification = n
- -- },
- -- {
- -- widget = naughty.widget.message,
- -- notification = n
- -- },
- -- layout = wibox.layout.fixed.vertical
- -- },
- -- layout = wibox.layout.fixed.horizontal,
- -- spacing = qvars.padding
- -- },
- -- widget = wibox.container.margin,
- -- margins = qvars.padding
- -- },
- widget = {
- -- {
- {
- widget = naughty.widget.icon,
- notification = n
- },
- {
- widget = wibox.container.place,
- valign = "center",
- halign = "center",
+ strategy = "exact",
+ {
+ qui.styled {
+ widget = wibox.container.background,
+ point = function(geo, args)
+ return {
+ x = args.parent.width,
+ y = args.parent.height - geo.height,
+ }
+ end,
{
{
- widget = naughty.widget.title,
- notification = n
+ widget = wibox.container.margin,
+ margins = qvars.big_padding,
+ {
+ {
+ widget = wibox.widget.textbox,
+ markup = qmarkup(app_name, { bold = true }),
+ },
+ nil,
+ {
+
+ widget = wibox.container.radialprogressbar,
+ max_value = qvars.notif_timeout,
+ border_color = qvars.colors.black,
+ color = qvars.colors.yellow,
+ border_width = qvars.border_width,
+ forced_height = qvars.char_height,
+ forced_width = qvars.char_height,
+ id = "progress",
+ },
+ layout = wibox.layout.align.horizontal,
+ },
},
{
- widget = naughty.widget.message,
- notification = n
+ widget = wibox.container.constraint,
+ height = qvars.border_width,
+ width = beautiful.notification_max_width,
+ strategy = "exact",
+ {
+ widget = wibox.container.background,
+ bg = qvars.colors.bright.black,
+ },
},
- -- spacing = 4,
- layout = wibox.layout.fixed.vertical,
- }
+ {
+ widget = wibox.container.margin,
+ margins = qvars.big_padding,
+ {
+ widget = wibox.container.constraint,
+ height = n.icon and qvars.char_height * 2 + qvars.padding
+ or (title_height + message_height + intertext_margin),
+ strategy = "exact",
+ {
+ {
+ widget = wibox.container.background,
+ {
+ widget = naughty.widget.icon,
+ shape = qvars.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 qvars.big_padding or nil,
+ layout = wibox.layout.fixed.horizontal,
+ },
+ },
+ },
+ layout = wibox.layout.fixed.vertical,
+ },
+ id = "bg",
},
- fill_space = true,
- -- spacing = 4,
- layout = wibox.layout.fixed.horizontal
- -- },
- -- actionlist,
- -- spacing = 10,
- -- layout = wibox.layout.fixed.vertical,
+ layout = wibox.layout.manual,
+ id = "manual",
+ },
},
- placement = awful.placement.centered,
- ontop = true
}
- gtimer {
- timeout = qvars.notif_timeout,
- autostart = true,
- callback = function()
- notif.visible = false
- notif = nil
- end
+ local hiding = false
+ local old_destroy = 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 = rtimed {
+ duration = qvars.anim_duration * 2,
+ intro = qvars.anim_intro * 2,
+ pos = 0,
+ easing = easing.quadratic,
+ clamp_position = true,
+ subscribed = function(pos)
+ gtimer.delayed_call(function()
+ notif.widget.widget:move(1, function(geo, args)
+ if pos == 0 and hiding then
+ old_destroy()
+ end
+ return {
+ x = args.parent.width - pos,
+ y = args.parent.height - geo.height,
+ }
+ end)
+ end)
+ end,
+ }
+ local opacity = rtimed {
+ duration = qvars.anim_duration * 2,
+ intro = qvars.anim_intro * 2,
+ easing = easing.quadratic,
+ pos = 0,
+ clamp_position = true,
+ subscribed = function(pos)
+ notif.opacity = pos
+ end,
}
- -- local icon = notif.widget:get_children_by_id("icon_role")[1]
+ n:disconnect_signal("destroyed", notif._private.destroy_callback)
+ function notif._private.destroy_callback()
+ opacity.target = 0
+ position.target = 0
+ hiding = true
+ end
+ n:weak_connect_signal("destroyed", notif._private.destroy_callback)
- -- if n.image then
- -- icon.forced_height = dpi(32)
- -- icon.forced_width = dpi(32)
- -- end
+ opacity.target = 1
+ position.target = qvars.char_width * 48
+ progress.target = qvars.notif_timeout
end
-
-return wicked
diff --git a/.config/awesome/ui/wicked/widgets/message.lua b/.config/awesome/ui/wicked/widgets/message.lua
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.config/awesome/ui/wicked/widgets/message.lua