diff options
Diffstat (limited to '.config/awesome/ui/osd/init.lua')
-rw-r--r-- | .config/awesome/ui/osd/init.lua | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/.config/awesome/ui/osd/init.lua b/.config/awesome/ui/osd/init.lua new file mode 100644 index 0000000..4310f17 --- /dev/null +++ b/.config/awesome/ui/osd/init.lua @@ -0,0 +1,102 @@ +local awful = require "awful" +local beautiful = require "beautiful" +local gtimer = require "gears.timer" +local phosphor = require "assets.phosphor" +local qmath = require "quarrel.math" +local qui = require "quarrel.ui" +local qvars = require "quarrel.vars" +local rubato = require "lib.rubato" +local wibox = require "wibox" +-- local mpris_widget = require "ui.osd.mpris" + +local osd = {} + +local widget = awful.popup(qui.styled { + ontop = true, + visible = true, + placement = function(d) + awful.placement.top(d, { + margins = { + top = beautiful.useless_gap * 2, + }, + }) + end, + minimum_height = qui.CHAR_HEIGHT * 3, + -- widget = mpris_widget + -- minimum_width = awful.screen.focused().geometry.width / 2, + -- widget = { + -- { + -- widget = wibox.container.place, + -- + -- qui.icon { + -- icon = phosphor.speaker_simple_none_fill, + -- widget = { + -- forced_height = qui.CHAR_HEIGHT * 1.2, + -- forced_width = qui.CHAR_HEIGHT * 1.2, + -- id = "icon", + -- }, + -- }, + -- }, + -- { + -- widget = wibox.container.place, + -- { + -- widget = wibox.widget.progressbar, + -- max_value = 100, + -- value = 20, + -- forced_height = qui.CHAR_HEIGHT / 1.5, + -- forced_width = qvars.expanded_bar_size + -- - (qui.BIG_PADDING + qui.BIG_PADDING * 2 + qui.PADDING * 2) + -- - (qui.CHAR_HEIGHT / 1.25 + qui.PADDING) * 3, + -- color = qcolor.palette.yellow(), + -- background_color = qcolor.palette.border.variant, + -- shape = qui.shape, + -- id = "progress", + -- }, + -- }, + -- + -- { + -- widget = wibox.widget.textbox, + -- text = "20%", + -- font = qui.font(1.2), + -- id = "percentage", + -- }, + -- layout = wibox.layout.fixed.horizontal, + -- spacing = qui.BIG_PADDING, + -- }, +}) + +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 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)) .. "%" +end + +return osd |