aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/ui/statusbar
diff options
context:
space:
mode:
Diffstat (limited to '.config/awesome/ui/statusbar')
-rw-r--r--.config/awesome/ui/statusbar/init.lua32
-rw-r--r--.config/awesome/ui/statusbar/panel/init.lua14
-rw-r--r--.config/awesome/ui/statusbar/panel/widgets/calendar.lua143
-rw-r--r--.config/awesome/ui/statusbar/panel/widgets/notifs/consts.lua13
-rw-r--r--.config/awesome/ui/statusbar/panel/widgets/notifs/init.lua0
-rw-r--r--.config/awesome/ui/statusbar/panel/widgets/notifs/widgets/notif.lua214
-rw-r--r--.config/awesome/ui/statusbar/widgets/dnd.lua34
7 files changed, 356 insertions, 94 deletions
diff --git a/.config/awesome/ui/statusbar/init.lua b/.config/awesome/ui/statusbar/init.lua
index 137ffb8..0a1198a 100644
--- a/.config/awesome/ui/statusbar/init.lua
+++ b/.config/awesome/ui/statusbar/init.lua
@@ -5,6 +5,7 @@ local qanim = require "quarrel.animation"
local qui = require "quarrel.ui"
local qvars = require "quarrel.vars"
local wibox = require "wibox"
+local dnd = require "ui.statusbar.widgets.dnd"
local M = require "ui.statusbar.consts"
@@ -31,29 +32,26 @@ screen.connect_signal("request::desktop_decoration", function(s)
},
nil,
{
- widget = wibox.container.place,
- valign = "bottom",
+ dnd,
+ displays.brightness,
+ displays.audio,
+ displays.battery,
+ displays.wifi,
{
- displays.brightness,
- displays.audio,
- displays.battery,
- displays.wifi,
+ widget = wibox.container.place,
{
- widget = wibox.container.place,
- {
- widget = wibox.container.constraint,
- height = qui.CHAR_HEIGHT,
- width = qui.CHAR_HEIGHT,
- keyboardlayout,
- },
+ widget = wibox.container.constraint,
+ height = qui.CHAR_HEIGHT,
+ width = qui.CHAR_HEIGHT,
+ keyboardlayout,
},
- clock,
- layout = wibox.layout.fixed.vertical,
- spacing = qui.PADDING * 2,
},
+ clock,
+ layout = wibox.layout.fixed.vertical,
+ spacing = qui.PADDING * 2,
},
layout = wibox.layout.align.vertical,
- expand = "outside",
+ expand = "inside",
},
nil,
nil,
diff --git a/.config/awesome/ui/statusbar/panel/init.lua b/.config/awesome/ui/statusbar/panel/init.lua
index 814a5a1..7e54560 100644
--- a/.config/awesome/ui/statusbar/panel/init.lua
+++ b/.config/awesome/ui/statusbar/panel/init.lua
@@ -36,23 +36,11 @@ local panel = wibox.widget {
wifi,
-- battery,
music.widget,
- calendar,
+ calendar.widget,
layout = wibox.layout.fixed.vertical,
spacing = qui.PADDING,
},
},
- -- {
- -- widget = wibox.container.background,
- -- {
- -- widget = wibox.widget.textbox,
- -- text = ":)",
- -- },
- -- },
- -- {
- -- widget = wibox.container.place,
- -- valign = "bottom",
- -- power_menu,
- -- },
layout = wibox.layout.align.vertical,
},
},
diff --git a/.config/awesome/ui/statusbar/panel/widgets/calendar.lua b/.config/awesome/ui/statusbar/panel/widgets/calendar.lua
index ddbffc0..c3f0424 100644
--- a/.config/awesome/ui/statusbar/panel/widgets/calendar.lua
+++ b/.config/awesome/ui/statusbar/panel/widgets/calendar.lua
@@ -1,14 +1,36 @@
-local awful = require "awful"
local phosphor = require "assets.phosphor"
-local qbind = require "quarrel.bind"
local qcolor = require "quarrel.color"
-local qmarkup = require "quarrel.markup"
local qui = require "quarrel.ui"
local wibox = require "wibox"
-local weekday_map = { 7, 1, 2, 3, 4, 5, 6 }
+local WEEKDAY_MAP = { 7, 1, 2, 3, 4, 5, 6 }
-local calendar = wibox.widget(qui.styled {
+local M = {}
+
+local l_grid = wibox.widget {
+ layout = wibox.layout.grid,
+ forced_num_rows = 7,
+ forced_num_cols = 7,
+ border_width = {
+ inner = qui.BORDER_WIDTH,
+ outer = 0,
+ },
+ border_color = qcolor.palette.border.variant,
+}
+
+local w_month = wibox.widget {
+ widget = wibox.widget.textbox,
+ text = "-",
+}
+
+local w_year = wibox.widget {
+ widget = wibox.widget.textbox,
+ text = "-",
+}
+
+local offset = 0
+
+M.widget = wibox.widget(qui.styled {
widget = wibox.container.background,
bg = qcolor.palette.bg.high,
{
@@ -16,18 +38,7 @@ local calendar = wibox.widget(qui.styled {
margins = qui.BORDER_WIDTH,
{
{
- {
- layout = wibox.layout.grid,
- forced_num_rows = 7,
- forced_num_cols = 7,
- -- spacing = (qui.PADDING) / 2,
- border_width = {
- inner = qui.BORDER_WIDTH,
- outer = 0,
- },
- border_color = qcolor.palette.border.variant,
- id = "grid",
- },
+ l_grid,
{
widget = wibox.container.background,
bg = qcolor.palette.border(),
@@ -43,9 +54,17 @@ local calendar = wibox.widget(qui.styled {
widget = wibox.container.place,
fill_horizontal = true,
{
- widget = wibox.widget.textbox,
- text = "05\n25",
- },
+ {
+ widget = wibox.container.place,
+ w_month,
+ },
+ qui.separator {
+ size = qui.BORDER_WIDTH
+ },
+ w_year,
+ layout = wibox.layout.fixed.vertical,
+ spacing = qui.PADDING
+ }
},
nil,
qui.styled {
@@ -86,7 +105,6 @@ local calendar = wibox.widget(qui.styled {
},
},
layout = wibox.layout.fixed.vertical,
- -- spacing = qui.PADDING
},
},
layout = wibox.layout.align.vertical,
@@ -97,11 +115,32 @@ local calendar = wibox.widget(qui.styled {
},
})
-local grid = calendar:get_children_by_id("grid")[1]
+function M:render(grid)
+ for i, row in ipairs(grid) do
+ for j, col in ipairs(row) do
+ local widget = l_grid:get_widgets_at(i, j)[1]
+ widget.widget.widget.widget.text = col[1]
+ if col[2] then
+ widget.bg = qcolor.palette.yellow()
+ widget.fg = qcolor.palette.bg()
+ elseif j % 6 == 0 or j % 7 == 0 then
+ widget.bg = col[3] and qcolor.palette.bg.highest or qcolor.palette.bg.high
+ else
+ widget.bg = col[3] and qcolor.palette.bg.high or qcolor.palette.bg()
+ end
+
+ if i == 1 then
+ widget.fg = qcolor.palette.fg()
+ elseif not col[2] then
+ widget.fg = qcolor.palette.fg.low
+ end
+ end
+ end
+end
-- Logic heavily inspired by https://github.com/Sinomor/dotfiles/blob/e409f9a84bf40daf1e39c0179ec749232ed827c9/home/.config/awesome/ui/control/moment/calendar.lua#L134-L173
-function calendar:compute_grid(year, month)
- local calendar_table = {
+function M:compute(year, month)
+ local grid = {
{
{ "Mo", false, true },
{ "Tu", false, true },
@@ -125,7 +164,7 @@ function calendar:compute_grid(year, month)
local days = last_day.day
local prev_days = os.date("*t", os.time { year = year, month = month, day = 0 })
- local prev_offset = weekday_map[first_day.wday] - 1
+ local prev_offset = WEEKDAY_MAP[first_day.wday] - 1
local prev_month = month - 1 == -1 and 12 or month - 1
local prev_year = prev_month == 12 and year - 1 or year
@@ -133,7 +172,7 @@ function calendar:compute_grid(year, month)
for offset = prev_offset, 1, -1 do
local day = prev_days.day - offset + 1
table.insert(
- calendar_table[2],
+ grid[2],
{ day, day == current.day and prev_month == current.month and prev_year == current.year, false }
)
end
@@ -141,10 +180,10 @@ function calendar:compute_grid(year, month)
do
local row = 2
- local weekday = weekday_map[first_day.wday]
+ local weekday = WEEKDAY_MAP[first_day.wday]
for day = 1, days do
table.insert(
- calendar_table[row],
+ grid[row],
{ day, day == current.day and month == current.month and year == current.year, true }
)
if weekday == 7 then
@@ -159,7 +198,7 @@ function calendar:compute_grid(year, month)
local next_year = next_month == 1 and year + 1 or year
for day = 1, 42 - prev_offset - days do
table.insert(
- calendar_table[row],
+ grid[row],
{ day, day == current.day and next_month + 1 == current.month and next_year == current.year, false }
)
if weekday == 7 then
@@ -171,35 +210,16 @@ function calendar:compute_grid(year, month)
end
end
- for i, row in ipairs(calendar_table) do
- for j, col in ipairs(row) do
- local widget = grid:get_widgets_at(i, j)[1]
- widget.widget.widget.widget.text = col[1]
- if col[2] then
- widget.bg = qcolor.palette.yellow()
- widget.fg = qcolor.palette.bg()
- elseif j % 6 == 0 or j % 7 == 0 then
- widget.bg = col[3] and qcolor.palette.bg.highest or qcolor.palette.bg.high
- else
- widget.bg = col[3] and qcolor.palette.bg.high or qcolor.palette.bg()
- end
-
- if i == 1 then
- widget.fg = qcolor.palette.fg()
- elseif not col[2] then
- -- widget.fg = col[3] and qcolor.palette.fg() or qcolor.palette.fg.low
- widget.fg = qcolor.palette.fg.low
- end
- end
- end
+ w_month.text = month
+ w_year.text = year
+ self:render(grid)
end
-local cells = {}
-local function cell(content)
- local widget = wibox.widget {
+-- Set up the widget
+for _ = 1, 49 do
+ local cell = wibox.widget {
widget = wibox.container.background,
bg = qcolor.palette.bg.high,
- -- shape = qui.shape,
{
widget = wibox.container.margin,
margins = qui.PADDING * 1.5,
@@ -209,20 +229,15 @@ local function cell(content)
forced_width = qui.CHAR_HEIGHT,
{
widget = wibox.widget.textbox,
- markup = content,
+ markup = "",
},
},
},
}
- table.insert(cells, widget)
-end
-
-for _ = 1, 49 do
- cell()
+ l_grid:add(cell)
end
-grid:add(table.unpack(cells))
local current_time = os.date "*t"
-calendar:compute_grid(current_time.year, current_time.month)
-grid:add_row_border(2, qui.BORDER_WIDTH, { color = qcolor.palette.border() })
+M:compute(current_time.year, current_time.month)
+l_grid:add_row_border(2, qui.BORDER_WIDTH, { color = qcolor.palette.border() })
-return calendar
+return M
diff --git a/.config/awesome/ui/statusbar/panel/widgets/notifs/consts.lua b/.config/awesome/ui/statusbar/panel/widgets/notifs/consts.lua
new file mode 100644
index 0000000..c864483
--- /dev/null
+++ b/.config/awesome/ui/statusbar/panel/widgets/notifs/consts.lua
@@ -0,0 +1,13 @@
+local qcolor = require "quarrel.color"
+
+local C = {}
+
+C.NOTIF_TIMEOUT = 3
+C.LEVEL_COLORS = {
+ debug = qcolor.palette.purple(),
+ info = qcolor.palette.blue(),
+ warn = qcolor.palette.orange(),
+ error = qcolor.palette.red(),
+}
+
+return C
diff --git a/.config/awesome/ui/statusbar/panel/widgets/notifs/init.lua b/.config/awesome/ui/statusbar/panel/widgets/notifs/init.lua
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.config/awesome/ui/statusbar/panel/widgets/notifs/init.lua
diff --git a/.config/awesome/ui/statusbar/panel/widgets/notifs/widgets/notif.lua b/.config/awesome/ui/statusbar/panel/widgets/notifs/widgets/notif.lua
new file mode 100644
index 0000000..b2b66b2
--- /dev/null
+++ b/.config/awesome/ui/statusbar/panel/widgets/notifs/widgets/notif.lua
@@ -0,0 +1,214 @@
+local awful = require "awful"
+local beautiful = require "beautiful"
+local gshape = require "gears.shape"
+local naughty = require "naughty"
+local qanim = require "quarrel.animation"
+local qui = require "quarrel.ui"
+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, _, 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
+ local app_name
+ if n.app_name == "" then
+ app_name = n._private._foreign and "Unknown" or "Awesome"
+ else
+ app_name = n.app_name
+ end
+
+ local w_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,
+ }
+ end
+
+ local w_notif = naughty.layout.box {
+ notification = n,
+ placement = function(d)
+ return awful.placement.right(d, {
+ margins = beautiful.useless_gap * 2,
+ })
+ end,
+ bg = qcolor.palette.transparent,
+ border_width = 0,
+ shape = gshape.rectangle,
+ widget_template = {
+ widget = wibox.container.constraint,
+ height = qui.BIG_PADDING * 2
+ + qui.CHAR_HEIGHT
+ + qui.BORDER_WIDTH
+ + qui.BIG_PADDING * 2
+ + (n.icon and qui.CHAR_HEIGHT * 2 + qui.PADDING or (title_height + message_height + intertext_margin)),
+
+ strategy = "exact",
+ {
+ qui.styled {
+ widget = wibox.container.background,
+ forced_width = beautiful.notification_max_width,
+ point = function(geo, args)
+ return {
+ x = args.parent.width,
+ y = args.parent.height - geo.height,
+ }
+ end,
+ {
+ widget = wibox.container.margin,
+ margins = qui.BIG_PADDING,
+ {
+ {
+ widget = wibox.container.constraint,
+ 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.widget.textbox,
+ markup = qmarkup(app_name, { bold = true }),
+ },
+ nil,
+ w_progress,
+ layout = wibox.layout.align.horizontal,
+ },
+ {
+ widget = wibox.container.constraint,
+ height = qui.BORDER_WIDTH,
+ strategy = "exact",
+ {
+ widget = wibox.container.background,
+ bg = qcolor.palette.border(),
+ },
+ },
+ {
+ widget = wibox.container.constraint,
+ height = n.icon and qui.CHAR_HEIGHT * 2 + qui.PADDING
+ or (title_height + message_height + intertext_margin),
+ strategy = "exact",
+ {
+ {
+ 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,
+ },
+ },
+ layout = wibox.layout.fixed.vertical,
+ spacing = qui.BIG_PADDING,
+ },
+ },
+ },
+ {
+ 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,
+ },
+ },
+ id = "bg",
+ },
+ layout = wibox.layout.manual,
+ },
+ },
+ }
+
+ local hiding = false
+
+ local t_position = qanim:new {
+ duration = qvars.anim_duration,
+ pos = 0,
+ easing = qvars.easing,
+ subscribed = function(pos)
+ gtimer.delayed_call(function()
+ w_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 t_opacity = rtimed {
+ duration = qvars.anim_duration,
+ intro = qvars.anim_intro,
+ easing = easing.quadratic,
+ pos = 0,
+ clamp_position = true,
+ subscribed = function(pos)
+ w_notif.opacity = pos
+ end,
+ }
+
+ 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", w_notif._private.destroy_callback)
+
+ 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, {
+ __call = function(_, ...)
+ return M.new(...)
+ end,
+})
diff --git a/.config/awesome/ui/statusbar/widgets/dnd.lua b/.config/awesome/ui/statusbar/widgets/dnd.lua
new file mode 100644
index 0000000..37d96b7
--- /dev/null
+++ b/.config/awesome/ui/statusbar/widgets/dnd.lua
@@ -0,0 +1,34 @@
+local qvars = require "quarrel.vars"
+local wibox = require "wibox"
+local dnd = require "services.dnd"
+local qcolor = require "quarrel.color"
+local phosphor = require "assets.phosphor"
+local qui = require "quarrel.ui"
+local qdebug = require "quarrel.debug"
+
+local w = wibox.widget {
+ widget = wibox.container.background,
+ shape = qui.shape,
+ qui.padded {
+ widget = wibox.container.place,
+ qui.icon {
+ icon = phosphor.bell_simple_slash_fill,
+ color = qcolor.palette.bg(),
+ widget = {
+ forced_height = qui.CHAR_HEIGHT - qui.PADDING * 2,
+ forced_width = qui.CHAR_HEIGHT - qui.PADDING * 2
+ }
+ }
+ },
+ -- visible = false
+}
+
+dnd:connect_signal("dnd", function (_, value)
+ -- this is a giant hack
+ -- why is it here? cause otherwise the align layout freaks out
+ -- and counts the hidden widget when reserving space *and* when drawing, offsetting the rest of the widgets in the process
+ -- w.visible = value
+ w.bg = qcolor.palette[value and "yellow" or "bg"]()
+end)
+
+return w