diff options
| author | delta <darkussdelta@gmail.com> | 2026-04-17 08:10:30 +0200 |
|---|---|---|
| committer | delta <darkussdelta@gmail.com> | 2026-04-17 08:10:30 +0200 |
| commit | a7c79cb5a04562be10347856642a80f0c4be89fc (patch) | |
| tree | 98fac95855d84f5037a1c6f44061cbe94b550600 /.config/awesome/ui/osd/init.lua | |
| parent | 225eeafcea67d63a608f9c666faf2a2ef014be4a (diff) | |
Diffstat (limited to '.config/awesome/ui/osd/init.lua')
| -rw-r--r-- | .config/awesome/ui/osd/init.lua | 136 |
1 files changed, 104 insertions, 32 deletions
diff --git a/.config/awesome/ui/osd/init.lua b/.config/awesome/ui/osd/init.lua index 4310f17..85cb1d7 100644 --- a/.config/awesome/ui/osd/init.lua +++ b/.config/awesome/ui/osd/init.lua @@ -4,24 +4,49 @@ local gtimer = require "gears.timer" local phosphor = require "assets.phosphor" local qmath = require "quarrel.math" local qui = require "quarrel.ui" +local qdebug = require "quarrel.debug" +local gshape = require "gears.shape" +local qanim = require "quarrel.animation" local qvars = require "quarrel.vars" local rubato = require "lib.rubato" local wibox = require "wibox" -- local mpris_widget = require "ui.osd.mpris" -local osd = {} +local MAX_HEIGHT = qui.BIG_PADDING * 2 + qui.CHAR_HEIGHT -local widget = awful.popup(qui.styled { +local M = { + _toggled = false +} + +local geo = awful.screen.focused().geometry + +M._w_popup = qui.animateable_shape(qui.popup { ontop = true, visible = true, - placement = function(d) - awful.placement.top(d, { - margins = { - top = beautiful.useless_gap * 2, - }, + shape = function(cr, w, h) + gshape.partially_rounded_rect(cr, w, h, true, true, false, false, qui.BORDER_RADIUS) + end, + placement = function (d) + return (awful.placement.bottom + awful.placement.center_horizontal)(d, { + offset = { + y = qui.BORDER_WIDTH + 1 -- Needs one more pixel to fully occlude the bottom border for some reason + } }) end, - minimum_height = qui.CHAR_HEIGHT * 3, + -- placement = function(d) + -- awful.placement.bottom(d, { + -- margins = { + -- top = beautiful.useless_gap * 2, + -- }, + -- }) + -- end, + -- x = geo.width / 2, + -- y = geo.height - 10, + minimum_height = qui.CHAR_HEIGHT, + widget = { + widget = wibox.widget.textbox, + text = "blah" + } -- widget = mpris_widget -- minimum_width = awful.screen.focused().geometry.width / 2, -- widget = { @@ -65,38 +90,85 @@ local widget = awful.popup(qui.styled { -- }, }) -local timer +M._t_height = qanim:new { + duration = qvars.anim_duration, + pos = 0, + easing = qvars.easing, + subscribed = function(pos) + M._w_popup.shape_height = pos + end, +} -local anim = rubato.timed { +-- TODO: optimize the search algo to be more efficient and not require making fresnel invisible +M._t_opacity = rubato.timed { duration = qvars.anim_duration, - intro = qvars.anim_intro, - pos = 1, + pos = 0, subscribed = function(pos) - widget.opacity = pos + M._w_popup.opacity = pos + if pos == 0 then - widget.visible = false - elseif not widget.visible then - widget.visible = true - elseif pos == 1 then - -- timer:start() + M._w_popup.visible = false + else + M._w_popup.visible = true end end, } -timer = gtimer { - timeout = 1, - callback = function() - -- anim.target = 0 - end, - single_shot = true, -} +M._t_height:set(qui.BIG_PADDING * 2 + qui.CHAR_HEIGHT) +M._t_opacity.target = 1 + +function M:show() + self._toggled = true + self._t_opacity.target = 1 + self._t_height:set(MAX_HEIGHT) +end -function osd.notify(icon, value, max) - anim.target = 1 - widget:get_children_by_id("icon")[1].image = icon - widget:get_children_by_id("progress")[1].value = value - widget:get_children_by_id("progress")[1].max_value = max - widget:get_children_by_id("percentage")[1].text = tostring(qmath.percentage(value, max)) .. "%" +function M:hide() + self._toggled = false + self._t_opacity.target = 0 + self._t_height:set(0) end -return osd +function M:toggle() + if self._toggled then + self:hide() + else + self:show() + end +end + +-- local timer +-- +-- local anim = rubato.timed { +-- duration = qvars.anim_duration, +-- intro = qvars.anim_intro, +-- pos = 1, +-- subscribed = function(pos) +-- widget.opacity = pos +-- if pos == 0 then +-- widget.visible = false +-- elseif not widget.visible then +-- widget.visible = true +-- elseif pos == 1 then +-- -- timer:start() +-- end +-- end, +-- } +-- +-- timer = gtimer { +-- timeout = 1, +-- callback = function() +-- -- anim.target = 0 +-- end, +-- single_shot = true, +-- } + +-- function M.notify(icon, value, max) +-- anim.target = 1 +-- widget:get_children_by_id("icon")[1].image = icon +-- widget:get_children_by_id("progress")[1].value = value +-- widget:get_children_by_id("progress")[1].max_value = max +-- widget:get_children_by_id("percentage")[1].text = tostring(qmath.percentage(value, max)) .. "%" +-- end + +return M |
