dotfiles/.config/awesome/ui/info-panel/calendar.lua

81 lines
1.6 KiB
Lua
Raw Normal View History

2024-02-19 19:41:33 -08:00
local wibox = require("wibox")
local beautiful = require("beautiful")
local dpi = beautiful.xresources.apply_dpi
-- Creating Calendar
----------------------
-- copied from awesome doc and adjusted a bit
local styles = {}
2024-02-19 19:41:33 -08:00
styles.month = { bg_color = beautiful.xcolorS0 }
styles.normal = {
bg_color = beautiful.xcolorS0,
padding = dpi(6),
fg_color = beautiful.xcolorT2,
}
2024-02-19 19:41:33 -08:00
styles.focus = {
fg_color = beautiful.xcolor7,
padding = dpi(6),
2024-02-19 19:41:33 -08:00
markup = function(t)
return "<b>" .. t .. "</b>"
end,
}
2024-02-19 19:41:33 -08:00
styles.header = {
fg_color = beautiful.xcolor2,
2024-02-19 19:41:33 -08:00
markup = function(t)
return "<b>" .. t .. "</b>"
end,
}
2024-02-19 19:41:33 -08:00
styles.weekday = {
fg_color = beautiful.xcolorT2,
2024-02-19 19:41:33 -08:00
markup = function(t)
return '<span font_desc="FiraCode Nerd Font Medium 16">' .. t .. "</span>"
end,
}
-- The Function
2024-02-19 19:41:33 -08:00
local function decorate_cell(widget, flag)
if flag == "monthheader" and not styles.monthheader then
flag = "header"
end
2024-02-19 19:41:33 -08:00
local props = styles[flag] or {}
2024-02-19 19:41:33 -08:00
if props.markup and widget.get_text and widget.set_markup then
widget:set_markup(props.markup(widget:get_text()))
end
-- Change bg color for weekends
local ret = wibox.widget({
{
widget,
margins = props.padding,
widget = wibox.container.margin,
},
fg = props.fg_color,
bg = props.bg_color,
widget = wibox.container.background,
})
2024-02-19 19:41:33 -08:00
return ret
end
2024-02-19 19:41:33 -08:00
local calendar = wibox.widget({
date = os.date("*t"),
2024-02-19 19:41:33 -08:00
font = beautiful.font_name .. "14",
fn_embed = decorate_cell,
widget = wibox.widget.calendar.month,
2024-02-19 19:41:33 -08:00
})
2024-02-19 19:41:33 -08:00
return wibox.widget({
nil,
{
nil,
calendar,
2024-02-19 19:41:33 -08:00
expand = "none",
layout = wibox.layout.align.horizontal,
},
2024-02-19 19:41:33 -08:00
expand = "none",
layout = wibox.layout.align.vertical,
2024-02-19 19:41:33 -08:00
})