From 03e437e32a8eece7d0eae364c3f1d36168f9dbd4 Mon Sep 17 00:00:00 2001 From: sarubo Date: Sat, 13 Nov 2021 21:44:10 +0900 Subject: [PATCH 1/2] calendar_popup: Fix markup not working --- lib/awful/widget/calendar_popup.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/awful/widget/calendar_popup.lua b/lib/awful/widget/calendar_popup.lua index 97a625ae..0d911aba 100644 --- a/lib/awful/widget/calendar_popup.lua +++ b/lib/awful/widget/calendar_popup.lua @@ -137,11 +137,14 @@ local function parse_cell_options(cell, args) -- Get default props[prop] = args[prop] or beautiful["calendar_" .. cell .. "_" .. prop] or bl_style[prop] or default end - props['markup'] = cell == "focus" and - (args['markup'] or beautiful["calendar_" .. cell .. "_markup"] or bl_style['markup'] or - string.format('%s', - props['fg_color'], props['bg_color'], "%s") + if cell == "focus" and props.markup == nil then + local fg = props.fg_color and string.format('foreground="%s"', props.fg_color) or "" + local bg = props.bg_color and string.format('background="%s"', props.bg_color) or "" + props.markup = string.format( + '%s', + fg, bg, "%s" ) + end return props end @@ -420,4 +423,4 @@ end return setmetatable(calendar_popup, calendar_popup.mt) --- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 \ No newline at end of file From 8d61790be77d560138928a28ca807e443f15adfc Mon Sep 17 00:00:00 2001 From: sarubo Date: Sun, 21 Nov 2021 23:49:46 +0900 Subject: [PATCH 2/2] doc: Add the markup example of popup_calendar Refer to tests/examples/awful/widget/calendar_popup/default.lua --- lib/awful/widget/calendar_popup.lua | 3 ++ .../widget/calendar_popup/cell_properties.lua | 42 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tests/examples/awful/widget/calendar_popup/cell_properties.lua diff --git a/lib/awful/widget/calendar_popup.lua b/lib/awful/widget/calendar_popup.lua index 0d911aba..6da667ae 100644 --- a/lib/awful/widget/calendar_popup.lua +++ b/lib/awful/widget/calendar_popup.lua @@ -46,6 +46,9 @@ local styles = { "year", "month", "yearheader", "monthheader", "header", "weekda -- @tparam cell_properties table Table of cell style properties --- Cell properties. +-- +-- @DOC_awful_widget_calendar_popup_cell_properties_EXAMPLE@ +-- -- @field markup Markup function or format string -- @field fg_color Text foreground color -- @field bg_color Text background color diff --git a/tests/examples/awful/widget/calendar_popup/cell_properties.lua b/tests/examples/awful/widget/calendar_popup/cell_properties.lua new file mode 100644 index 00000000..f9fc1d29 --- /dev/null +++ b/tests/examples/awful/widget/calendar_popup/cell_properties.lua @@ -0,0 +1,42 @@ +--DOC_HIDE_START --DOC_GEN_IMAGE +local awful = require("awful") +local wibox = require("wibox") + +screen[1]._resize { width = 480, height = 200 } + +local wb = awful.wibar { position = "top", } + +-- Create the same number of tags as the default config +awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[1], awful.layout.layouts[1]) + +-- Only bother with widgets that are visible by default +local mykeyboardlayout = awful.widget.keyboardlayout() +local my_text_clock = wibox.widget.textclock() +local mytaglist = awful.widget.taglist(screen[1], awful.widget.taglist.filter.all, {}) +local mytasklist = awful.widget.tasklist(screen[1], awful.widget.tasklist.filter.currenttags, {}) +--DOC_HIDE_END + +local my_header_properties = { + markup = function(text) return "" .. text .. "" end, +} +local my_options = { style_header = my_header_properties, } +local month_calendar = awful.widget.calendar_popup.month(my_options) +month_calendar:attach(my_text_clock, "tr") + +--DOC_HIDE_START +wb:setup { + layout = wibox.layout.align.horizontal, + { + mytaglist, + layout = wibox.layout.fixed.horizontal, + }, + mytasklist, + { + layout = wibox.layout.fixed.horizontal, + mykeyboardlayout, + my_text_clock, + }, +} +month_calendar:toggle() + +--vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 --DOC_HIDE_END \ No newline at end of file