From 94e53c37776f0859feaaefbb197b4842cbe6900f Mon Sep 17 00:00:00 2001 From: dmitry Date: Sun, 29 Aug 2021 16:34:29 +0300 Subject: [PATCH 01/12] Add swap flags --- src/modules/memory/common.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/modules/memory/common.cpp b/src/modules/memory/common.cpp index 31219ed6..07a1caf6 100644 --- a/src/modules/memory/common.cpp +++ b/src/modules/memory/common.cpp @@ -12,7 +12,15 @@ auto waybar::modules::Memory::update() -> void { parseMeminfo(); unsigned long memtotal = meminfo_["MemTotal"]; + unsigned long swaptotal = 0; + if (meminfo_.count("SwapTotal")) { + swaptotal = meminfo_["SwapTotal"]; + } unsigned long memfree; + unsigned long swapfree = 0; + if (meminfo_.count("SwapFree")) { + swapfree = meminfo_["SwapFree"]; + } if (meminfo_.count("MemAvailable")) { // New kernels (3.4+) have an accurate available memory field. memfree = meminfo_["MemAvailable"]; @@ -24,9 +32,16 @@ auto waybar::modules::Memory::update() -> void { if (memtotal > 0 && memfree >= 0) { auto total_ram_gigabytes = memtotal / std::pow(1024, 2); + auto total_swap_gigabytes = swaptotal / std::pow(1024, 2); int used_ram_percentage = 100 * (memtotal - memfree) / memtotal; + int used_swap_percentage = 0; + if (swaptotal && swapfree) { + used_swap_percentage = 100 * (swaptotal - swapfree) / swaptotal; + } auto used_ram_gigabytes = (memtotal - memfree) / std::pow(1024, 2); + auto used_swap_gigabytes = (swaptotal - swapfree) / std::pow(1024, 2); auto available_ram_gigabytes = memfree / std::pow(1024, 2); + auto available_swap_gigabytes = swapfree / std::pow(1024, 2); auto format = format_; auto state = getState(used_ram_percentage); @@ -43,9 +58,13 @@ auto waybar::modules::Memory::update() -> void { used_ram_percentage, fmt::arg("icon", getIcon(used_ram_percentage, icons)), fmt::arg("total", total_ram_gigabytes), + fmt::arg("swapTotal", total_swap_gigabytes), fmt::arg("percentage", used_ram_percentage), + fmt::arg("swapPercentage", used_swap_percentage), fmt::arg("used", used_ram_gigabytes), - fmt::arg("avail", available_ram_gigabytes))); + fmt::arg("swapUsed", used_swap_gigabytes), + fmt::arg("avail", available_ram_gigabytes), + fmt::arg("swapAvail", available_swap_gigabytes))); } if (tooltipEnabled()) { @@ -54,9 +73,13 @@ auto waybar::modules::Memory::update() -> void { label_.set_tooltip_text(fmt::format(tooltip_format, used_ram_percentage, fmt::arg("total", total_ram_gigabytes), + fmt::arg("swapTotal", total_swap_gigabytes), fmt::arg("percentage", used_ram_percentage), + fmt::arg("swapPercentage", used_swap_percentage), fmt::arg("used", used_ram_gigabytes), - fmt::arg("avail", available_ram_gigabytes))); + fmt::arg("swapUsed", used_swap_gigabytes), + fmt::arg("avail", available_ram_gigabytes), + fmt::arg("swapAvail", available_swap_gigabytes))); } else { label_.set_tooltip_text(fmt::format("{:.{}f}GiB used", used_ram_gigabytes, 1)); } From 8d9e322507790785598ced6ea5346d069f1c5d52 Mon Sep 17 00:00:00 2001 From: dmitry Date: Sun, 29 Aug 2021 16:37:02 +0300 Subject: [PATCH 02/12] Add man --- man/waybar-memory.5.scd | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/man/waybar-memory.5.scd b/man/waybar-memory.5.scd index 0639c07c..d960ffd2 100644 --- a/man/waybar-memory.5.scd +++ b/man/waybar-memory.5.scd @@ -84,12 +84,20 @@ Addressed by *memory* *{percentage}*: Percentage of memory in use. +*{swapPercentage}*: Percentage of swap in use. + *{total}*: Amount of total memory available in GiB. +*{swapTotal}*: Amount of total swap available in GiB. + *{used}*: Amount of used memory in GiB. +*{swapUsed}*: Amount of used swap in GiB. + *{avail}*: Amount of available memory in GiB. +*{swapAvail}*: Amount of available swap in GiB. + # EXAMPLES ``` From 4a85ec0f59137b041d99801292a9b708b99a15a5 Mon Sep 17 00:00:00 2001 From: Johannes Wienke Date: Thu, 6 Jan 2022 17:49:06 +0100 Subject: [PATCH 03/12] fix: match sway workspace order with sway one Ensure that sway workspaces are always displayed in the same order as used internally by sway. The previous sorting code always sorted unnumbered workspaces lexicographically. This isn't the order used by sway internally. Therefore, commands such as "workspace next" might have jumped arbitrarily in waybar. This commit reworks the sorting code such that the internal order is always obeyed. Additionally, numbered persistent workspaces are inserted at their natural position at the front of the workspace list while unnumbered ones are appended. This should match the expectations of workspace ordering known from sway's behavior. The changes make the configuration property "numeric-first" unnecessary as this will always be the case now. There's also no reasonable way around this behavior now. Otherwise, persistent workspaces would jump around in the visual representation as soon as they become known to sway. Fixes #802 --- man/waybar-sway-workspaces.5.scd | 5 --- src/modules/sway/workspaces.cpp | 74 +++++++++++++++++--------------- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/man/waybar-sway-workspaces.5.scd b/man/waybar-sway-workspaces.5.scd index f2808b90..b575e098 100644 --- a/man/waybar-sway-workspaces.5.scd +++ b/man/waybar-sway-workspaces.5.scd @@ -69,10 +69,6 @@ Addressed by *sway/workspaces* typeof: string ++ Command to execute when the module is updated. -*numeric-first*: ++ - typeof: bool ++ - Whether to put workspaces starting with numbers before workspaces that do not start with a number. - *disable-auto-back-and-forth*: ++ typeof: bool ++ Whether to disable *workspace_auto_back_and_forth* when clicking on workspaces. If this is set to *true*, clicking on a workspace you are already on won't do anything, even if *workspace_auto_back_and_forth* is enabled in the Sway configuration. @@ -120,7 +116,6 @@ n.b.: the list of outputs can be obtained from command line using *swaymsg -t ge "sway/workspaces": { "disable-scroll": true, "all-outputs": true, - "numeric-first": false, "format": "{name}: {icon}", "format-icons": { "1": "", diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp index 43dcf33c..074d145f 100644 --- a/src/modules/sway/workspaces.cpp +++ b/src/modules/sway/workspaces.cpp @@ -2,6 +2,7 @@ #include +#include #include #include @@ -98,6 +99,7 @@ void Workspaces::onCmd(const struct Ipc::ipc_response &res) { Json::Value v; v["name"] = p_w_name; v["target_output"] = bar_.output->name; + v["num"] = convertWorkspaceNameToNum(p_w_name); workspaces_.emplace_back(std::move(v)); break; } @@ -107,57 +109,59 @@ void Workspaces::onCmd(const struct Ipc::ipc_response &res) { Json::Value v; v["name"] = p_w_name; v["target_output"] = ""; + v["num"] = convertWorkspaceNameToNum(p_w_name); workspaces_.emplace_back(std::move(v)); } } } - // config option to sort numeric workspace names before others - bool config_numeric_first = config_["numeric-first"].asBool(); - + // sway has a defined ordering of workspaces that should be preserved in + // the representation displayed by waybar to ensure that commands such + // as "workspace prev" or "workspace next" make sense when looking at + // the workspace representation in the bar. + // Due to waybar's own feature of persistent workspaces unknown to sway, + // custom sorting logic is necessary to make these workspaces appear + // naturally in the list of workspaces without messing up sway's + // sorting. For this purpose, a custom numbering property is created + // that preserves the order provided by sway while inserting numbered + // persistent workspaces at their natural positions. + // + // All of this code assumes that sway provides numbered workspaces first + // and other workspaces are sorted by their creation time. + // + // In a first pass, the maximum "num" value is computed to enqueue + // unnumbered workspaces behind numbered ones when computing the sort + // attribute. + int max_num = -1; + for (auto & workspace : workspaces_) { + max_num = std::max(workspace["num"].asInt(), max_num); + } + for (auto & workspace : workspaces_) { + auto workspace_num = workspace["num"].asInt(); + if (workspace_num > -1) { + workspace["sort"] = workspace_num; + } else { + workspace["sort"] = ++max_num; + } + } std::sort(workspaces_.begin(), workspaces_.end(), - [config_numeric_first](const Json::Value &lhs, const Json::Value &rhs) { - // the "num" property (integer type): - // The workspace number or -1 for workspaces that do - // not start with a number. - // We could rely on sway providing this property: - // - // auto l = lhs["num"].asInt(); - // auto r = rhs["num"].asInt(); - // - // We cannot rely on the "num" property as provided by sway - // via IPC, because persistent workspace might not exist in - // sway's view. However, we need this property also for - // not-yet created persistent workspace. As such, we simply - // duplicate sway's logic of assigning the "num" property - // into waybar (see convertWorkspaceNameToNum). This way the - // sorting should work out even when we include workspaces - // that do not currently exist. + [](const Json::Value &lhs, const Json::Value &rhs) { auto lname = lhs["name"].asString(); auto rname = rhs["name"].asString(); - int l = convertWorkspaceNameToNum(lname); - int r = convertWorkspaceNameToNum(rname); + int l = lhs["sort"].asInt(); + int r = rhs["sort"].asInt(); if (l == r) { - // in case both integers are the same, lexicographical - // sort. This also covers the case when both don't have a - // number (i.e., l == r == -1). + // In case both integers are the same, lexicographical + // sort. The code above already ensure that this will only + // happend in case of explicitly numbered workspaces. return lname < rname; } - // one of the workspaces doesn't begin with a number, so - // num is -1. - if (l < 0 || r < 0) { - if (config_numeric_first) { - return r < 0; - } - return l < 0; - } - - // both workspaces have a "num" so let's just compare those return l < r; }); + } dp.emit(); } catch (const std::exception &e) { From c0d84853ea2f3f8b016abf92458ba15378de6c91 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Fri, 7 Jan 2022 18:09:44 -0800 Subject: [PATCH 04/12] refactor(clock): extract waybar_time to util/waybar_time.hpp --- include/modules/clock.hpp | 18 ++++++------------ include/util/waybar_time.hpp | 29 +++++++++++++++++++++++++++++ src/modules/clock.cpp | 14 ++------------ 3 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 include/util/waybar_time.hpp diff --git a/include/modules/clock.hpp b/include/modules/clock.hpp index 9f950192..ddcdf609 100644 --- a/include/modules/clock.hpp +++ b/include/modules/clock.hpp @@ -1,21 +1,14 @@ #pragma once -#include -#if FMT_VERSION < 60000 -#include -#else -#include -#endif #include #include "ALabel.hpp" #include "util/sleeper_thread.hpp" -namespace waybar::modules { +namespace waybar { -struct waybar_time { - std::locale locale; - date::zoned_seconds ztime; -}; +struct waybar_time; + +namespace modules { const std::string kCalendarPlaceholder = "calendar"; @@ -43,4 +36,5 @@ class Clock : public ALabel { bool is_timezone_fixed(); }; -} // namespace waybar::modules +} // namespace modules +} // namespace waybar diff --git a/include/util/waybar_time.hpp b/include/util/waybar_time.hpp new file mode 100644 index 00000000..3eaf1146 --- /dev/null +++ b/include/util/waybar_time.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include +#if FMT_VERSION < 60000 +#include +#else +#include +#endif +#include + +namespace waybar { + +struct waybar_time { + std::locale locale; + date::zoned_seconds ztime; +}; + +} // namespace waybar + +template <> +struct fmt::formatter : fmt::formatter { + template + auto format(const waybar::waybar_time& t, FormatContext& ctx) { +#if FMT_VERSION >= 80000 + auto& tm_format = specs; +#endif + return format_to(ctx.out(), "{}", date::format(t.locale, fmt::to_string(tm_format), t.ztime)); + } +}; diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index 7e7d7420..739b79d1 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -6,12 +6,13 @@ #include #include #include "util/ustring_clen.hpp" +#include "util/waybar_time.hpp" #ifdef HAVE_LANGINFO_1STDAY #include #include #endif -using waybar::modules::waybar_time; +using waybar::waybar_time; waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) : ALabel(config, "clock", id, "{:%H:%M}", 60, false, false, true), @@ -227,14 +228,3 @@ auto waybar::modules::Clock::first_day_of_week() -> date::weekday { #endif return date::Sunday; } - -template <> -struct fmt::formatter : fmt::formatter { - template - auto format(const waybar_time& t, FormatContext& ctx) { -#if FMT_VERSION >= 80000 - auto& tm_format = specs; -#endif - return format_to(ctx.out(), "{}", date::format(t.locale, fmt::to_string(tm_format), t.ztime)); - } -}; From 8c41aaae046eb014b9192679f9c707fc429dbb9b Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Fri, 7 Jan 2022 18:59:08 -0800 Subject: [PATCH 05/12] refactor(test): use single executable --- test/SafeSignal.cpp | 6 ------ test/config.cpp | 1 - test/main.cpp | 26 ++++++++++++++++++++++++++ test/meson.build | 23 ++++++----------------- 4 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 test/main.cpp diff --git a/test/SafeSignal.cpp b/test/SafeSignal.cpp index 2c67317b..244487f2 100644 --- a/test/SafeSignal.cpp +++ b/test/SafeSignal.cpp @@ -1,4 +1,3 @@ -#define CATCH_CONFIG_RUNNER #include "util/SafeSignal.hpp" #include @@ -138,8 +137,3 @@ TEST_CASE_METHOD(GlibTestsFixture, "SafeSignal copy/move counter", "[signal][thr producer.join(); REQUIRE(count == NUM_EVENTS); } - -int main(int argc, char* argv[]) { - Glib::init(); - return Catch::Session().run(argc, argv); -} diff --git a/test/config.cpp b/test/config.cpp index edd6d6b8..29b0502a 100644 --- a/test/config.cpp +++ b/test/config.cpp @@ -1,4 +1,3 @@ -#define CATCH_CONFIG_MAIN #include "config.hpp" #include diff --git a/test/main.cpp b/test/main.cpp new file mode 100644 index 00000000..bbfcc9f2 --- /dev/null +++ b/test/main.cpp @@ -0,0 +1,26 @@ +#define CATCH_CONFIG_RUNNER +#include +#include +#include + +#include +#include +#include + +int main(int argc, char* argv[]) { + Catch::Session session; + Glib::init(); + + session.applyCommandLine(argc, argv); + const auto logger = spdlog::default_logger(); + const auto& reporter_name = session.config().getReporterName(); + if (reporter_name == "tap") { + spdlog::set_pattern("# [%l] %v"); + } else if (reporter_name == "compact") { + logger->sinks().clear(); + } else { + logger->sinks().assign({std::make_shared()}); + } + + return session.run(); +} diff --git a/test/meson.build b/test/meson.build index bbef21e7..473a6269 100644 --- a/test/meson.build +++ b/test/meson.build @@ -7,29 +7,18 @@ test_dep = [ spdlog, ] -config_test = executable( - 'config_test', +waybar_test = executable( + 'waybar_test', + 'main.cpp', + 'SafeSignal.cpp', 'config.cpp', '../src/config.cpp', dependencies: test_dep, include_directories: test_inc, ) -safesignal_test = executable( - 'safesignal_test', - 'SafeSignal.cpp', - dependencies: test_dep, - include_directories: test_inc, -) - test( - 'Configuration test', - config_test, - workdir: meson.source_root(), -) - -test( - 'SafeSignal test', - safesignal_test, + 'waybar', + waybar_test, workdir: meson.source_root(), ) From 766c8a103533828346577eab4be21aca49a83094 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Fri, 7 Jan 2022 19:32:18 -0800 Subject: [PATCH 06/12] test: add tests for waybar_time formatter --- test/meson.build | 14 +++++-- test/waybar_time.cpp | 90 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 test/waybar_time.cpp diff --git a/test/meson.build b/test/meson.build index 473a6269..b1e11237 100644 --- a/test/meson.build +++ b/test/meson.build @@ -6,13 +6,21 @@ test_dep = [ jsoncpp, spdlog, ] - -waybar_test = executable( - 'waybar_test', +test_src = files( 'main.cpp', 'SafeSignal.cpp', 'config.cpp', '../src/config.cpp', +) + +if tz_dep.found() + test_dep += tz_dep + test_src += files('waybar_time.cpp') +endif + +waybar_test = executable( + 'waybar_test', + test_src, dependencies: test_dep, include_directories: test_inc, ) diff --git a/test/waybar_time.cpp b/test/waybar_time.cpp new file mode 100644 index 00000000..5fc3312d --- /dev/null +++ b/test/waybar_time.cpp @@ -0,0 +1,90 @@ +#include "util/waybar_time.hpp" + +#include +#include + +#include +#include +#include + +using namespace std::literals::chrono_literals; + +/* + * Check that the date/time formatter with locale and timezone support is working as expected. + */ + +const date::zoned_time TEST_TIME = date::make_zoned( + "UTC", date::local_days{date::Monday[1] / date::January / 2022} + 13h + 4min + 5s); + +TEST_CASE("Format UTC time", "[clock][util]") { + waybar::waybar_time tm{std::locale("C"), TEST_TIME}; + + REQUIRE(fmt::format("{}", tm).empty()); // no format specified + REQUIRE(fmt::format("{:%c %Z}", tm) == "Mon Jan 3 13:04:05 2022 UTC"); + REQUIRE(fmt::format("{arg:%Y%m%d%H%M%S}", fmt::arg("arg", tm)) == "20220103130405"); + + /* Test a few locales that are most likely to be present */ + SECTION("US locale") { + try { + tm.locale = std::locale("en_US"); + + REQUIRE(fmt::format("{}", tm).empty()); // no format specified + REQUIRE_THAT(fmt::format("{:%c}", tm), // HowardHinnant/date#704 + Catch::Matchers::StartsWith("Mon 03 Jan 2022 01:04:05 PM")); + REQUIRE(fmt::format("{:%x %X}", tm) == "01/03/2022 01:04:05 PM"); + REQUIRE(fmt::format("{arg:%Y%m%d%H%M%S}", fmt::arg("arg", tm)) == "20220103130405"); + } catch (const std::runtime_error&) { + // locale not found; ignore + } + } + SECTION("GB locale") { + try { + tm.locale = std::locale("en_GB"); + + REQUIRE(fmt::format("{}", tm).empty()); // no format specified + REQUIRE_THAT(fmt::format("{:%c}", tm), // HowardHinnant/date#704 + Catch::Matchers::StartsWith("Mon 03 Jan 2022 13:04:05")); + REQUIRE(fmt::format("{:%x %X}", tm) == "03/01/22 13:04:05"); + REQUIRE(fmt::format("{arg:%Y%m%d%H%M%S}", fmt::arg("arg", tm)) == "20220103130405"); + } catch (const std::runtime_error&) { + // locale not found; ignore + } + } +} + +TEST_CASE("Format zoned time", "[clock][util]") { + waybar::waybar_time tm{std::locale("C"), date::make_zoned("America/New_York", TEST_TIME)}; + + REQUIRE(fmt::format("{}", tm).empty()); // no format specified + REQUIRE(fmt::format("{:%c %Z}", tm) == "Mon Jan 3 08:04:05 2022 EST"); + REQUIRE(fmt::format("{arg:%Y%m%d%H%M%S}", fmt::arg("arg", tm)) == "20220103080405"); + + /* Test a few locales that are most likely to be present */ + SECTION("US locale") { + try { + tm.locale = std::locale("en_US"); + + REQUIRE(fmt::format("{}", tm).empty()); // no format specified + REQUIRE_THAT(fmt::format("{:%c}", tm), // HowardHinnant/date#704 + Catch::Matchers::StartsWith("Mon 03 Jan 2022 08:04:05 AM")); + REQUIRE(fmt::format("{:%x %X}", tm) == "01/03/2022 08:04:05 AM"); + REQUIRE(fmt::format("{arg:%Y%m%d%H%M%S}", fmt::arg("arg", tm)) == "20220103080405"); + } catch (const std::runtime_error&) { + // locale not found; ignore + } + } + + SECTION("GB locale") { + try { + tm.locale = std::locale("en_GB"); + + REQUIRE(fmt::format("{}", tm).empty()); // no format specified + REQUIRE_THAT(fmt::format("{:%c}", tm), // HowardHinnant/date#704 + Catch::Matchers::StartsWith("Mon 03 Jan 2022 08:04:05")); + REQUIRE(fmt::format("{:%x %X}", tm) == "03/01/22 08:04:05"); + REQUIRE(fmt::format("{arg:%Y%m%d%H%M%S}", fmt::arg("arg", tm)) == "20220103080405"); + } catch (const std::runtime_error&) { + // locale not found; ignore + } + } +} From 1489a539f85a177d5efe78a292fabfe9758a2f48 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Fri, 7 Jan 2022 22:09:46 -0800 Subject: [PATCH 07/12] chore: bump supported fmt ver to 7.0.0 Certain features we use were added only in 7.0 and the code no longer compiles with any earlier versions. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 2c434266..1ccf6340 100644 --- a/meson.build +++ b/meson.build @@ -79,7 +79,7 @@ is_netbsd = host_machine.system() == 'netbsd' is_openbsd = host_machine.system() == 'openbsd' thread_dep = dependency('threads') -fmt = dependency('fmt', version : ['>=5.3.0'], fallback : ['fmt', 'fmt_dep']) +fmt = dependency('fmt', version : ['>=7.0.0'], fallback : ['fmt', 'fmt_dep']) spdlog = dependency('spdlog', version : ['>=1.8.5'], fallback : ['spdlog', 'spdlog_dep'], default_options : ['external_fmt=true']) wayland_client = dependency('wayland-client') wayland_cursor = dependency('wayland-cursor') From 7f6bef20496ca23e83692801f6ff2957d28dde76 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Fri, 7 Jan 2022 22:25:15 -0800 Subject: [PATCH 08/12] fix(util): make waybar_time formatter compatible with fmt 8.1.0 Stop using private implementation details of the `formatter`. We never needed anything from the class besides the format specifier, which is easily obtainable with public API. --- include/util/waybar_time.hpp | 32 +++++++++++++++++++++----------- src/modules/clock.cpp | 8 +++++++- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/include/util/waybar_time.hpp b/include/util/waybar_time.hpp index 3eaf1146..c74e58c3 100644 --- a/include/util/waybar_time.hpp +++ b/include/util/waybar_time.hpp @@ -1,12 +1,7 @@ #pragma once -#include -#if FMT_VERSION < 60000 -#include -#else -#include -#endif #include +#include namespace waybar { @@ -18,12 +13,27 @@ struct waybar_time { } // namespace waybar template <> -struct fmt::formatter : fmt::formatter { +struct fmt::formatter { + std::string_view specs; + + template + constexpr auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + auto it = ctx.begin(); + if (it != ctx.end() && *it == ':') { + ++it; + } + auto end = it; + while (end != ctx.end() && *end != '}') { + ++end; + } + if (end != it) { + specs = {it, std::string_view::size_type(end - it)}; + } + return end; + } + template auto format(const waybar::waybar_time& t, FormatContext& ctx) { -#if FMT_VERSION >= 80000 - auto& tm_format = specs; -#endif - return format_to(ctx.out(), "{}", date::format(t.locale, fmt::to_string(tm_format), t.ztime)); + return format_to(ctx.out(), "{}", date::format(t.locale, fmt::to_string(specs), t.ztime)); } }; diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index 739b79d1..b0a6776a 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -1,10 +1,16 @@ #include "modules/clock.hpp" -#include #include +#if FMT_VERSION < 60000 +#include +#else +#include +#endif +#include #include #include + #include "util/ustring_clen.hpp" #include "util/waybar_time.hpp" #ifdef HAVE_LANGINFO_1STDAY From ce404199de0fb6cea8ff59cb8546c6669949a311 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Fri, 7 Jan 2022 22:50:23 -0800 Subject: [PATCH 09/12] chore: add `tzdata` to the alpine builder Fixes date formatting test execution on alpine. --- Dockerfiles/alpine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfiles/alpine b/Dockerfiles/alpine index c0e032ff..03836aaa 100644 --- a/Dockerfiles/alpine +++ b/Dockerfiles/alpine @@ -2,4 +2,4 @@ FROM alpine:latest -RUN apk add --no-cache git meson alpine-sdk libinput-dev wayland-dev wayland-protocols mesa-dev libxkbcommon-dev eudev-dev pixman-dev gtkmm3-dev jsoncpp-dev pugixml-dev libnl3-dev pulseaudio-dev libmpdclient-dev sndio-dev scdoc libxkbcommon +RUN apk add --no-cache git meson alpine-sdk libinput-dev wayland-dev wayland-protocols mesa-dev libxkbcommon-dev eudev-dev pixman-dev gtkmm3-dev jsoncpp-dev pugixml-dev libnl3-dev pulseaudio-dev libmpdclient-dev sndio-dev scdoc libxkbcommon tzdata From 5c574975b733aa7e9c0ca347c77eaf3bc6b1155b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 9 Jan 2022 10:30:15 +0000 Subject: [PATCH 10/12] resources: don't break tray icon checkboxes via CSS These three lines break checkboxes and other forms of UI in status indicator dropdowns. For instance, they break checkboxes on NetworkManager's "nm-applet --indicator" via libappindicator-gtk3. First, disabling borders completely hides those UI elements, as they seem to render entirely via borders. Second, min-height makes checkboxes just flat lines. When removed entirely, the border settings seem to have had an effect on the workspaces widget, which now renders with round underline borders. To undo that, re-add those two lines inside its section. The min-height setting doesn't seem to affect anything that I can see. Remove it entirely, for now. Fixes #1148. --- resources/style.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/style.css b/resources/style.css index 0235942b..3bc70525 100644 --- a/resources/style.css +++ b/resources/style.css @@ -1,10 +1,7 @@ * { - border: none; - border-radius: 0; /* `otf-font-awesome` is required to be installed for icons */ font-family: Roboto, Helvetica, Arial, sans-serif; font-size: 13px; - min-height: 0; } window#waybar { @@ -43,6 +40,9 @@ window#waybar.chromium { color: #ffffff; /* Use box-shadow instead of border so the text isn't offset */ box-shadow: inset 0 -3px transparent; + /* Avoid rounded borders under each workspace name */ + border: none; + border-radius: 0; } /* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ From 1540797cd93bd91517b7fb28b2a129cb8938381d Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 10 Jan 2022 09:58:29 +0100 Subject: [PATCH 11/12] chore: v0.9.9 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 1ccf6340..2c644cc3 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project( 'waybar', 'cpp', 'c', - version: '0.9.8', + version: '0.9.9', license: 'MIT', meson_version: '>= 0.49.0', default_options : [ From 5abdecc402ed5de5c7224d8d3a878d25f97a0e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Tue, 11 Jan 2022 17:28:17 -0300 Subject: [PATCH 12/12] fix(man): add missing newlines to wlr docs. --- man/waybar-wlr-taskbar.5.scd | 5 +++++ man/waybar-wlr-workspaces.5.scd | 1 + 2 files changed, 6 insertions(+) diff --git a/man/waybar-wlr-taskbar.5.scd b/man/waybar-wlr-taskbar.5.scd index 40be7be4..b2946ac5 100644 --- a/man/waybar-wlr-taskbar.5.scd +++ b/man/waybar-wlr-taskbar.5.scd @@ -93,10 +93,15 @@ Addressed by *wlr/taskbar* # CLICK ACTIONS *activate*: Bring the application into foreground. + *minimize*: Toggle application's minimized state. + *minimize-raise*: Bring the application into foreground or toggle its minimized state. + *maximize*: Toggle application's maximized state. + *fullscreen*: Toggle application's fullscreen state. + *close*: Close the application. # EXAMPLES diff --git a/man/waybar-wlr-workspaces.5.scd b/man/waybar-wlr-workspaces.5.scd index f0df5e94..5d7b2acd 100644 --- a/man/waybar-wlr-workspaces.5.scd +++ b/man/waybar-wlr-workspaces.5.scd @@ -52,6 +52,7 @@ Addressed by *wlr/workspaces* # CLICK ACTIONS *activate*: Switch to workspace. + *close*: Close the workspace. # ICONS