diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index d5064fe4..f3c107ac 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Test in FreeBSD VM - uses: vmactions/freebsd-vm@v0.1.5 # aka FreeBSD 13.0 + uses: vmactions/freebsd-vm@v0.1.6 # aka FreeBSD 13.0 with: mem: 2048 usesh: true @@ -21,7 +21,7 @@ jobs: pkg install -y git # subprojects/date pkg install -y catch evdev-proto gtk-layer-shell gtkmm30 jsoncpp \ libdbusmenu libevdev libfmt libmpdclient libudev-devd meson \ - pkgconf pulseaudio scdoc sndio spdlog + pkgconf pulseaudio scdoc sndio spdlog wayland-protocols run: | meson build -Dman-pages=enabled ninja -C build diff --git a/include/util/command.hpp b/include/util/command.hpp index 3a38da36..5f398e19 100644 --- a/include/util/command.hpp +++ b/include/util/command.hpp @@ -68,7 +68,10 @@ inline int close(FILE* fp, pid_t pid) { inline FILE* open(const std::string& cmd, int& pid) { if (cmd == "") return nullptr; int fd[2]; - pipe(fd); + if (pipe(fd) != 0){ + spdlog::error("Unable to pipe fd"); + return nullptr; + } pid_t child_pid = fork(); diff --git a/include/util/format.hpp b/include/util/format.hpp index 543a100f..48f0f516 100644 --- a/include/util/format.hpp +++ b/include/util/format.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include class pow_format { public: @@ -84,5 +85,15 @@ namespace fmt { ); } }; + + + // Glib ustirng support + template <> + struct formatter : formatter { + template + auto format(const Glib::ustring& value, FormatContext& ctx) { + return formatter::format(value, ctx); + } + }; } diff --git a/man/waybar-clock.5.scd b/man/waybar-clock.5.scd index 2c901d2d..265e739d 100644 --- a/man/waybar-clock.5.scd +++ b/man/waybar-clock.5.scd @@ -86,6 +86,11 @@ The *clock* module displays the current date and time. typeof: double ++ Threshold to be used when scrolling. +*tooltip*: ++ + typeof: bool ++ + default: true ++ + Option to disable tooltip on hover. + View all valid format options in *strftime(3)*. # FORMAT REPLACEMENTS diff --git a/man/waybar-custom.5.scd b/man/waybar-custom.5.scd index 8f9dcfaf..3d30859d 100644 --- a/man/waybar-custom.5.scd +++ b/man/waybar-custom.5.scd @@ -151,7 +151,8 @@ $text\\n$tooltip\\n$class* "max-length": 40, "interval": 30, // Remove this if your script is endless and write in loop "exec": "$HOME/.config/waybar/mediaplayer.sh 2> /dev/null", // Script in resources folder - "exec-if": "pgrep spotify" + "exec-if": "pgrep spotify", + "return-type": "json" } ``` diff --git a/man/waybar-sway-mode.5.scd b/man/waybar-sway-mode.5.scd index b8b59cd3..29eed4f5 100644 --- a/man/waybar-sway-mode.5.scd +++ b/man/waybar-sway-mode.5.scd @@ -69,7 +69,7 @@ Addressed by *sway/mode* # EXAMPLES ``` -"sway/window": { +"sway/mode": { "format": " {}", "max-length": 50 } diff --git a/man/waybar-tray.5.scd b/man/waybar-tray.5.scd index c664594d..bfd1f296 100644 --- a/man/waybar-tray.5.scd +++ b/man/waybar-tray.5.scd @@ -29,6 +29,10 @@ Addressed by *tray* typeof: integer ++ Defines the spacing between the tray icons. +*reverse-direction*: ++ + typeof: bool ++ + Defines if new app icons should be added in a reverse order + *on-update*: ++ typeof: string ++ Command to execute when the module is updated. diff --git a/src/AModule.cpp b/src/AModule.cpp index 7da942e0..0e0f00ec 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -6,7 +6,9 @@ namespace waybar { AModule::AModule(const Json::Value& config, const std::string& name, const std::string& id, bool enable_click, bool enable_scroll) - : name_(std::move(name)), config_(std::move(config)) { + : name_(std::move(name)), config_(std::move(config)) + , distance_scrolled_y_(0.0) + , distance_scrolled_x_(0.0) { // configure events' user commands if (config_["on-click"].isString() || config_["on-click-middle"].isString() || config_["on-click-backward"].isString() || config_["on-click-forward"].isString() || diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index 26567690..c0075a48 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -161,7 +161,7 @@ const std::tuple waybar::modules::Battery::g uint32_t energy_now; uint32_t energy_full_design; std::string _status; - std::ifstream(bat / "status") >> _status; + std::getline(std::ifstream(bat / "status"), _status); // Some battery will report current and charge in μA/μAh. // Scale these by the voltage to get μW/μWh. diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index 6aa5afbe..acb90b79 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -113,10 +113,10 @@ auto waybar::modules::Clock::update() -> void { } auto tooltip_format = config_["tooltip-format"].asString(); text = fmt::format(tooltip_format, wtime, fmt::arg(kCalendarPlaceholder.c_str(), calendar_lines)); + label_.set_tooltip_markup(text); } } - label_.set_tooltip_markup(text); // Call parent update ALabel::update(); } diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 4825a099..4fd8e3ec 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -78,7 +78,7 @@ waybar::modules::Network::Network(const std::string &id, const Json::Value &conf family_(config["family"] == "ipv6" ? AF_INET6 : AF_INET), efd_(-1), ev_fd_(-1), - want_route_dump_(false), + want_route_dump_(true), want_link_dump_(false), want_addr_dump_(false), dump_in_progress_(false), @@ -106,7 +106,7 @@ waybar::modules::Network::Network(const std::string &id, const Json::Value &conf } if (!config_["interface"].isString()) { - // "interface" isn't configure, then try to guess the external + // "interface" isn't configured, then try to guess the external // interface currently used for internet. want_route_dump_ = true; } else { diff --git a/src/modules/pulseaudio.cpp b/src/modules/pulseaudio.cpp index 3c320608..b1f78302 100644 --- a/src/modules/pulseaudio.cpp +++ b/src/modules/pulseaudio.cpp @@ -54,7 +54,9 @@ void waybar::modules::Pulseaudio::contextStateCb(pa_context *c, void *data) { c, static_cast(static_cast(PA_SUBSCRIPTION_MASK_SERVER) | static_cast(PA_SUBSCRIPTION_MASK_SINK) | - static_cast(PA_SUBSCRIPTION_MASK_SOURCE)), + static_cast(PA_SUBSCRIPTION_MASK_SINK_INPUT) | + static_cast(PA_SUBSCRIPTION_MASK_SOURCE) | + static_cast(PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT)), nullptr, nullptr); break; @@ -121,8 +123,12 @@ void waybar::modules::Pulseaudio::subscribeCb(pa_context * conte pa_context_get_server_info(context, serverInfoCb, data); } else if (facility == PA_SUBSCRIPTION_EVENT_SINK) { pa_context_get_sink_info_by_index(context, idx, sinkInfoCb, data); + } else if (facility == PA_SUBSCRIPTION_EVENT_SINK_INPUT) { + pa_context_get_sink_info_list(context, sinkInfoCb, data); } else if (facility == PA_SUBSCRIPTION_EVENT_SOURCE) { pa_context_get_source_info_by_index(context, idx, sourceInfoCb, data); + } else if (facility == PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT) { + pa_context_get_source_info_list(context, sourceInfoCb, data); } } @@ -279,7 +285,7 @@ auto waybar::modules::Pulseaudio::update() -> void { fmt::arg("source_desc", source_desc_), fmt::arg("icon", getIcon(volume_, getPulseIcon())))); getState(volume_); - + if (tooltipEnabled()) { if (tooltip_format.empty() && config_["tooltip-format"].isString()) { tooltip_format = config_["tooltip-format"].asString(); diff --git a/src/modules/sni/item.cpp b/src/modules/sni/item.cpp index b504c8d0..74987ca4 100644 --- a/src/modules/sni/item.cpp +++ b/src/modules/sni/item.cpp @@ -8,13 +8,7 @@ #include #include -template <> -struct fmt::formatter : formatter { - template - auto format(const Glib::ustring& value, FormatContext& ctx) { - return formatter::format(value, ctx); - } -}; +#include "util/format.hpp" template <> struct fmt::formatter : formatter { diff --git a/src/modules/sni/tray.cpp b/src/modules/sni/tray.cpp index c32c0d6a..94120be6 100644 --- a/src/modules/sni/tray.cpp +++ b/src/modules/sni/tray.cpp @@ -25,7 +25,11 @@ Tray::Tray(const std::string& id, const Bar& bar, const Json::Value& config) } void Tray::onAdd(std::unique_ptr& item) { - box_.pack_start(item->event_box); + if (config_["reverse-direction"].isBool() && config_["reverse-direction"].asBool()) { + box_.pack_end(item->event_box); + } else { + box_.pack_start(item->event_box); + } dp.emit(); } diff --git a/src/modules/sway/language.cpp b/src/modules/sway/language.cpp index 73a64c3b..f64c7d05 100644 --- a/src/modules/sway/language.cpp +++ b/src/modules/sway/language.cpp @@ -154,7 +154,10 @@ auto Language::init_layouts_map(const std::vector& used_layouts) -> std::map short_name_to_number_map; for (const auto& used_layout_name : used_layouts) { - auto used_layout = &layouts_map_.find(used_layout_name)->second; + auto found = layouts_map_.find(used_layout_name); + if (found == layouts_map_.end()) + continue; + auto used_layout = &found->second; auto layouts_with_same_name_list = found_by_short_names[used_layout->short_name]; if (layouts_with_same_name_list.size() < 2) { continue;