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.lua101
2 files changed, 195 insertions, 0 deletions
diff --git a/.config/awesome/ui/wicked/_default.lua b/.config/awesome/ui/wicked/_default.lua
new file mode 100644
index 0000000..25283f9
--- /dev/null
+++ b/.config/awesome/ui/wicked/_default.lua
@@ -0,0 +1,94 @@
+----------------------------------------------------------------------------
+--- 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
new file mode 100644
index 0000000..5687b81
--- /dev/null
+++ b/.config/awesome/ui/wicked/init.lua
@@ -0,0 +1,101 @@
+local awful = require "awful"
+local vars = require "misc.vars"
+local wibox = require "wibox"
+local debug = require "gears.debug"
+local gtimer = require "gears.timer"
+local naughty = require "naughty"
+-- local rubato = require "lib.rubato"
+local default = require "ui.wicked._default"
+local h = require "misc.helpers"
+
+local beautiful = require "beautiful"
+local xresources = require "beautiful.xresources"
+local dpi = xresources.apply_dpi
+
+local wicked = {}
+
+wicked._active_notififcations = {}
+
+function wicked:notify(n)
+ -- local notif = wibox.widget {
+ local notif = h.popup {
+ -- widget = {
+ -- {
+ -- {
+ -- widget = naughty.widget.icon,
+ -- notification = n,
+ -- forced_height = 0,
+ -- forced_width = 0,
+ -- clip_shape = vars.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 = vars.padding
+ -- },
+ -- widget = wibox.container.margin,
+ -- margins = vars.padding
+ -- },
+ widget = {
+ -- {
+ {
+ widget = naughty.widget.icon,
+ notification = n
+ },
+ {
+ widget = wibox.container.place,
+ valign = "center",
+ halign = "center",
+ {
+ {
+ widget = naughty.widget.title,
+ notification = n
+ },
+ {
+ widget = naughty.widget.message,
+ notification = n
+ },
+ -- 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,
+ },
+ placement = awful.placement.centered,
+ ontop = true
+ }
+
+ gtimer {
+ timeout = vars.notif_timeout,
+ autostart = true,
+ callback = function()
+ notif.visible = false
+ notif = nil
+ end
+ }
+
+ -- local icon = notif.widget:get_children_by_id("icon_role")[1]
+
+ -- if n.image then
+ -- icon.forced_height = dpi(32)
+ -- icon.forced_width = dpi(32)
+ -- end
+end
+
+return wicked