Merge pull request #417 from Luka5W/luka5w-calendar

calendar-widget: added option to show week numbers, possible fix for #316
This commit is contained in:
streetturtle 2023-11-19 14:00:21 -05:00 committed by GitHub
commit d98fb49135
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View File

@ -8,11 +8,12 @@ Calendar widget for Awesome WM - slightly improved version of the `wibox.widget.
### Customization ### Customization
| Name | Default | Description | | Name | Default | Description |
|---|---|---| |--------------|-----------|-------------------------------------|
| theme | `naughty` | The theme to use | | theme | `naughty` | The theme to use |
| placement | `top` | The position of the popup | | placement | `top` | The position of the popup |
| radius | 8 | The popup radius | | radius | 8 | The popup radius |
| start_sunday | false | Start the week on Sunday | | start_sunday | false | Start the week on Sunday |
| week_numbers | false | Show ISO week numbers (Mon = first) |
- themes: - themes:

View File

@ -98,6 +98,7 @@ local function worker(user_args)
local next_month_button = args.next_month_button or 4 local next_month_button = args.next_month_button or 4
local previous_month_button = args.previous_month_button or 5 local previous_month_button = args.previous_month_button or 5
local start_sunday = args.start_sunday or false local start_sunday = args.start_sunday or false
local week_numbers = args.week_numbers or false
local styles = {} local styles = {}
local function rounded_shape(size) local function rounded_shape(size)
@ -156,7 +157,7 @@ local function worker(user_args)
-- Change bg color for weekends -- Change bg color for weekends
local d = { year = date.year, month = (date.month or 1), day = (date.day or 1) } local d = { year = date.year, month = (date.month or 1), day = (date.day or 1) }
local weekday = tonumber(os.date('%w', os.time(d))) local weekday = tonumber(os.date('%w', os.time(d)))
local default_bg = (weekday == 0 or weekday == 6) local default_bg = (flag == 'focus' or flag == 'normal') and (weekday == 0 or weekday == 6)
and calendar_themes[theme].weekend_day_bg and calendar_themes[theme].weekend_day_bg
or calendar_themes[theme].bg or calendar_themes[theme].bg
local ret = wibox.widget { local ret = wibox.widget {
@ -173,7 +174,7 @@ local function worker(user_args)
shape_border_color = props.border_color or '#000000', shape_border_color = props.border_color or '#000000',
shape_border_width = props.border_width or 0, shape_border_width = props.border_width or 0,
fg = props.fg_color or calendar_themes[theme].fg, fg = props.fg_color or calendar_themes[theme].fg,
bg = props.bg_color or default_bg, bg = default_bg,
widget = wibox.container.background widget = wibox.container.background
} }
@ -186,6 +187,7 @@ local function worker(user_args)
fn_embed = decorate_cell, fn_embed = decorate_cell,
long_weekdays = true, long_weekdays = true,
start_sunday = start_sunday, start_sunday = start_sunday,
week_numbers = week_numbers,
widget = wibox.widget.calendar.month widget = wibox.widget.calendar.month
} }