luca-awesome-dotfiles/home/.config/awesome/ui/notifications-list/init.lua
Hydroxycarbamide 2401cfcee2 Add revelation
Update and add bling task_preview, tag_preview and window_switcher
Add catppuccin-macchiato
Use my weather key
Update keybindings
Update autorun
Fix sliders
2023-03-20 09:51:48 +01:00

108 lines
2.6 KiB
Lua

-- ## Sidebar ##
-- ~~~~~~~~~~~~~
-- Requirements :
-- ~~~~~~~~~~~~~~
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require ("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- # Libs :
-- ~~~~~~~~
local helpers = require("libs.helpers")
local rubato = require("libs.rubato")
local function box_widget(widgets, width, height)
return wibox.widget {
{
{
widgets,
margins = dpi(16),
widget = wibox.container.margin,
},
forced_width = dpi(width),
forced_height = dpi(height),
shape = helpers.rrect(theme.rounded),
bg = colors.container,
widget = wibox.container.background,
},
margins = {left = dpi(20), right = dpi(20)},
widget = wibox.container.margin,
}
end
-- Get widgets
local notifications_list_core = require("ui.notifications-list.list")
local notifications_widget = notifications_list_core.widget
-- Combine some widgets
local notifications = box_widget(notifications_widget, 380, 150)
-- Sidebar
local notifications_list = wibox {
type = "dock",
visible = false,
ontop = true,
width = dpi(420),
height = dpi(836),
y = dpi(8),
bg = theme.bg,
shape = helpers.rrect(18),
}
-- Sidebar widget setup
notifications_list : setup {
{
notifications,
spacing = dpi(20),
layout = wibox.layout.flex.vertical,
},
margins = { top = dpi(20), bottom = dpi(20)},
widget = wibox.container.margin,
}
-- Slide animation
local slide = rubato.timed {
pos = helpers.screen.geometry.height,
rate = 60,
intro = 0.05,
duration = 0.2,
easing = rubato.quadratic,
subscribed = function(pos)
notifications_list.y = helpers.screen.geometry.y + pos
end
}
-- Timer of sidebar's death
notifications_list.timer = gears.timer {
timeout = 0.5,
single_shot = true,
callback = function()
notifications_list.visible = not notifications_list.visible
end
}
-- Toggle function
notifications_list.toggle = function()
if notifications_list.visible then
slide.target = helpers.screen.geometry.y - notifications_list.height
notifications_list.timer:start()
else
slide.target = helpers.screen.geometry.y + dpi(10)
notifications_list.visible = not notifications_list.visible
end
end
awful.placement.top_right(notifications_list, {honor_workarea = true, margins = beautiful.useless_gap * 3})
notifications_list.core = notifications_list_core
-- Get signal to execute the function (if that makes sense)
awesome.connect_signal("notifications_list::toggle", function()
notifications_list.toggle()
end)
return notifications_list