Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions man/waybar-clock.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ View all valid format options in *strftime(3)* or have a look https://en.cpprefe
:[ When enabled, the calendar follows the ISO 8601 standard: weeks begin on
Monday, and the first week of the year is numbered 1. The default week format is
'{:%V}'.
|[ *first-day-of-week*
:[ integer
:[
:[ The first day of the week, where 0 is Sunday and 6 is Saturday.
When not set, the first day of the week is determined by the locale settings.

3. Addressed by *clock: calendar: format*
[- *Option*
Expand Down Expand Up @@ -207,11 +212,12 @@ View all valid format options in *strftime(3)* or have a look https://en.cpprefe
"format-alt": "{:%A, %B %d, %Y (%R)}  ",
"tooltip-format": "<tt><small>{calendar}</small></tt>",
"calendar": {
"mode" : "year",
"mode-mon-col" : 3,
"weeks-pos" : "right",
"on-scroll" : 1,
"on-click-right": "mode",
"mode" : "year",
"mode-mon-col" : 3,
"weeks-pos" : "right",
"first-day-of-week": 1,
"on-scroll" : 1,
"on-click-right" : "mode",
"format": {
"months": "<span color='#ffead3'><b>{}</b></span>",
"days": "<span color='#ecc6d9'><b>{}</b></span>",
Expand Down
12 changes: 12 additions & 0 deletions src/modules/clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,18 @@ using deleting_unique_ptr = std::unique_ptr<T, deleter_from_fn<fn>>;

// Computations done similarly to Linux cal utility.
auto waybar::modules::Clock::first_day_of_week() -> weekday {
const auto firstdow = config_[kCldPlaceholder]["first-day-of-week"];
if (firstdow.isInt()) {
const int firstDay = firstdow.asInt();
if (!(firstDay >= 0 && firstDay <= 6)) {
spdlog::warn(
"Clock calender configuration first-day-of-week = {0} must be in range [0, 6]. Default "
"value is used instead",
firstDay);
} else {
return weekday{static_cast<unsigned>(firstDay)};
}
}
if (iso8601Calendar_) {
return Monday;
}
Expand Down