From 190b2dd922ba30d92b3e4b3a09b81efeffcbde22 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 24 Feb 2020 11:30:35 +0100 Subject: [PATCH 01/17] pulseaudio: track only the default sink and source When you have multiple sinks (resp. sources), the module used to display the state of the most recently changed one. This changes remembers the default sink name, and only records changes to that one. --- include/modules/pulseaudio.hpp | 2 ++ src/modules/pulseaudio.cpp | 26 +++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/modules/pulseaudio.hpp b/include/modules/pulseaudio.hpp index ba5a2aa..541747c 100644 --- a/include/modules/pulseaudio.hpp +++ b/include/modules/pulseaudio.hpp @@ -37,12 +37,14 @@ class Pulseaudio : public ALabel { std::string form_factor_; std::string desc_; std::string monitor_; + std::string default_sink_name_; // SOURCE uint32_t source_idx_{0}; uint16_t source_volume_; bool source_muted_; std::string source_port_name_; std::string source_desc_; + std::string default_source_name_; }; } // namespace waybar::modules diff --git a/src/modules/pulseaudio.cpp b/src/modules/pulseaudio.cpp index 46dc426..3e9a95e 100644 --- a/src/modules/pulseaudio.cpp +++ b/src/modules/pulseaudio.cpp @@ -134,15 +134,15 @@ void waybar::modules::Pulseaudio::volumeModifyCb(pa_context *c, int success, voi */ void waybar::modules::Pulseaudio::sourceInfoCb(pa_context * /*context*/, const pa_source_info *i, int /*eol*/, void *data) { - if (i != nullptr) { - auto self = static_cast(data); + auto pa = static_cast(data); + if (i != nullptr && pa->default_source_name_ == i->name) { auto source_volume = static_cast(pa_cvolume_avg(&(i->volume))) / float{PA_VOLUME_NORM}; - self->source_volume_ = std::round(source_volume * 100.0F); - self->source_idx_ = i->index; - self->source_muted_ = i->mute != 0; - self->source_desc_ = i->description; - self->source_port_name_ = i->active_port != nullptr ? i->active_port->name : "Unknown"; - self->dp.emit(); + pa->source_volume_ = std::round(source_volume * 100.0F); + pa->source_idx_ = i->index; + pa->source_muted_ = i->mute != 0; + pa->source_desc_ = i->description; + pa->source_port_name_ = i->active_port != nullptr ? i->active_port->name : "Unknown"; + pa->dp.emit(); } } @@ -150,9 +150,9 @@ void waybar::modules::Pulseaudio::sourceInfoCb(pa_context * /*context*/, const p * Called when the requested sink information is ready. */ void waybar::modules::Pulseaudio::sinkInfoCb(pa_context * /*context*/, const pa_sink_info *i, - int /*eol*/, void * data) { - if (i != nullptr) { - auto pa = static_cast(data); + int /*eol*/, void *data) { + auto pa = static_cast(data); + if (i != nullptr && pa->default_sink_name_ == i->name) { pa->pa_volume_ = i->volume; float volume = static_cast(pa_cvolume_avg(&(pa->pa_volume_))) / float{PA_VOLUME_NORM}; pa->sink_idx_ = i->index; @@ -174,6 +174,10 @@ void waybar::modules::Pulseaudio::sinkInfoCb(pa_context * /*context*/, const pa_ */ void waybar::modules::Pulseaudio::serverInfoCb(pa_context *context, const pa_server_info *i, void *data) { + auto pa = static_cast(data); + pa->default_sink_name_ = i->default_sink_name; + pa->default_source_name_ = i->default_source_name; + pa_context_get_sink_info_by_name(context, i->default_sink_name, sinkInfoCb, data); pa_context_get_source_info_by_name(context, i->default_source_name, sourceInfoCb, data); } From 03130b75654335ff31251c6dcca0a211b2bfa635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=98=D0=B0=D0=BD=20=D0=93=D0=B5=D0=BE?= =?UTF-8?q?=D1=80=D0=B3=D0=B8=D0=B5=D0=B2=D1=81=D0=BA=D0=B8?= Date: Tue, 3 Mar 2020 22:32:02 +0100 Subject: [PATCH 02/17] systemd service: fix start up ordering the service needs to have After=wayland-session.target otherwise it'll be started in parallel to the compositor which might not be fully configured --- resources/waybar.service.in | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/waybar.service.in b/resources/waybar.service.in index 1c086bf..03262a3 100644 --- a/resources/waybar.service.in +++ b/resources/waybar.service.in @@ -2,6 +2,7 @@ Description=Highly customizable Wayland bar for Sway and Wlroots based compositors. Documentation=https://github.com/Alexays/Waybar/wiki/ PartOf=wayland-session.target +After=wayland-session.target [Service] Type=dbus From dd0144c3cd285cc818fb31d239c7e759d6bef823 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Wed, 4 Mar 2020 06:47:12 -0800 Subject: [PATCH 03/17] fix(bar): set exclusive zone early for gtk-layer-shell If the bar is using initial size from the config (i.e both width and height are set and resize is not required), GtkWindow configure event is is not emitted. Initialize exclusive zone earlier for that case. Fixes #609 --- src/bar.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bar.cpp b/src/bar.cpp index 7b9e930..431a564 100644 --- a/src/bar.cpp +++ b/src/bar.cpp @@ -175,6 +175,11 @@ void waybar::Bar::initGtkLayerShell() { gtk_layer_set_margin(gtk_window, GTK_LAYER_SHELL_EDGE_RIGHT, margins_.right); gtk_layer_set_margin(gtk_window, GTK_LAYER_SHELL_EDGE_TOP, margins_.top); gtk_layer_set_margin(gtk_window, GTK_LAYER_SHELL_EDGE_BOTTOM, margins_.bottom); + + if (width_ > 1 && height_ > 1) { + /* configure events are not emitted if the bar is using initial size */ + setExclusiveZone(width_, height_); + } } #endif From 3945c7766891148c339a77118b7c1dbe709af407 Mon Sep 17 00:00:00 2001 From: Jordan Cohen Date: Thu, 5 Mar 2020 08:57:19 -0500 Subject: [PATCH 04/17] readme: adding libspdlog-dev to list of ubuntu dependencies, also sorting and cleaning up list to make it easier to read and copy --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d8b7545..be45818 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,24 @@ libmpdclient [MPD module] On Ubuntu 19.10 you can install all the relevant dependencies using this command: ``` -sudo apt install libgtkmm-3.0-dev libjsoncpp-dev libinput-dev libsigc++-2.0-dev libpulse-dev libnl-3-dev libdbusmenu-gtk3-dev libnl-genl-3-dev libfmt-dev clang-tidy libmpdclient-dev libwayland-dev libgtk-3-dev gobject-introspection libgirepository1.0-dev scdoc +sudo apt install \ + clang-tidy \ + gobject-introspection \ + libdbusmenu-gtk3-dev \ + libfmt-dev \ + libgirepository1.0-dev \ + libgtk-3-dev \ + libgtkmm-3.0-dev \ + libinput-dev \ + libjsoncpp-dev \ + libmpdclient-dev \ + libnl-3-dev \ + libnl-genl-3-dev \ + libpulse-dev \ + libsigc++-2.0-dev \ + libspdlog-dev \ + libwayland-dev \ + scdoc ``` From 2f975f870a715f6691ebd2fc12d6ad75dc752316 Mon Sep 17 00:00:00 2001 From: BoostCookie Date: Thu, 12 Mar 2020 22:04:00 +0100 Subject: [PATCH 05/17] Added support for absolute device paths for the temperature module. --- man/waybar-temperature.5.scd | 8 ++++++++ src/modules/temperature.cpp | 3 +++ 2 files changed, 11 insertions(+) diff --git a/man/waybar-temperature.5.scd b/man/waybar-temperature.5.scd index f867686..eeae546 100644 --- a/man/waybar-temperature.5.scd +++ b/man/waybar-temperature.5.scd @@ -20,6 +20,14 @@ Addressed by *temperature* typeof: string ++ The temperature path to use, e.g. */sys/class/hwmon/hwmon2/temp1_input* instead of one in */sys/class/thermal/*. +*hwmon-path-abs*: ++ + typeof: string ++ + The path of the hwmon-directory of the device, e.g. */sys/devices/pci0000:00/0000:00:18.3/hwmon*. (Note that the subdirectory *hwmon/hwmon#*, where *#* is a number is not part of the path!) Has to be used together with *input-filename*. + +*input-filename*: ++ + typeof: string ++ + The temperature filename of your *hwmon-path-abs*, e.g. *temp1_input* + *critical-threshold*: ++ typeof: integer ++ The threshold before it is considered critical (Celsius). diff --git a/src/modules/temperature.cpp b/src/modules/temperature.cpp index 78391a0..f2dd958 100644 --- a/src/modules/temperature.cpp +++ b/src/modules/temperature.cpp @@ -1,9 +1,12 @@ #include "modules/temperature.hpp" +#include waybar::modules::Temperature::Temperature(const std::string& id, const Json::Value& config) : ALabel(config, "temperature", id, "{temperatureC}°C", 10) { if (config_["hwmon-path"].isString()) { file_path_ = config_["hwmon-path"].asString(); + } else if (config_["hwmon-path-abs"].isString() && config_["input-filename"].isString()) { + file_path_ = (*std::filesystem::directory_iterator(config_["hwmon-path-abs"].asString())).path().u8string() + "/" + config_["input-filename"].asString(); } else { auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0; file_path_ = fmt::format("/sys/class/thermal/thermal_zone{}/temp", zone); From d405f28622dfc8e7979e5e7c523c11d3a373a4ba Mon Sep 17 00:00:00 2001 From: BoostCookie <62076789+BoostCookie@users.noreply.github.com> Date: Fri, 13 Mar 2020 16:42:05 +0100 Subject: [PATCH 06/17] Indent now uses spaces. --- src/modules/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/temperature.cpp b/src/modules/temperature.cpp index f2dd958..c1b6ebc 100644 --- a/src/modules/temperature.cpp +++ b/src/modules/temperature.cpp @@ -6,7 +6,7 @@ waybar::modules::Temperature::Temperature(const std::string& id, const Json::Val if (config_["hwmon-path"].isString()) { file_path_ = config_["hwmon-path"].asString(); } else if (config_["hwmon-path-abs"].isString() && config_["input-filename"].isString()) { - file_path_ = (*std::filesystem::directory_iterator(config_["hwmon-path-abs"].asString())).path().u8string() + "/" + config_["input-filename"].asString(); + file_path_ = (*std::filesystem::directory_iterator(config_["hwmon-path-abs"].asString())).path().u8string() + "/" + config_["input-filename"].asString(); } else { auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0; file_path_ = fmt::format("/sys/class/thermal/thermal_zone{}/temp", zone); From 5e712ca255232bba6b84ae3845e4ab9b4d0d8902 Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Sat, 14 Mar 2020 16:25:33 -0400 Subject: [PATCH 07/17] Switch default Makefile rule from run to build This commit makes it so that running `make` without arguments builds rather than builds and runs, which is unconventional and surprising behaviour. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bb6b334..d7182c1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: build build-debug run clean default install -default: run +default: build build: meson build From 19743f3085cc6fc865af33f0aa08d91d64499c0c Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Fri, 20 Mar 2020 17:37:22 -0400 Subject: [PATCH 08/17] fix(memory): provide better free memory approximation on old kernels The approximation should include SReclaimable, and subtract Shmem. To prevent the parsing code from ballooning in size, this commit also refactors the parsing into a map. --- include/modules/memory.hpp | 3 +-- src/modules/memory.cpp | 41 ++++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/include/modules/memory.hpp b/include/modules/memory.hpp index be66611..5b0f51b 100644 --- a/include/modules/memory.hpp +++ b/include/modules/memory.hpp @@ -17,8 +17,7 @@ class Memory : public ALabel { static inline const std::string data_dir_ = "/proc/meminfo"; void parseMeminfo(); - unsigned long memtotal_; - unsigned long memfree_; + std::unordered_map meminfo_; util::SleeperThread thread_; }; diff --git a/src/modules/memory.cpp b/src/modules/memory.cpp index eeb92bf..6aa7036 100644 --- a/src/modules/memory.cpp +++ b/src/modules/memory.cpp @@ -10,11 +10,23 @@ waybar::modules::Memory::Memory(const std::string& id, const Json::Value& config auto waybar::modules::Memory::update() -> void { parseMeminfo(); - if (memtotal_ > 0 && memfree_ >= 0) { - auto total_ram_gigabytes = memtotal_ / std::pow(1024, 2); - int used_ram_percentage = 100 * (memtotal_ - memfree_) / memtotal_; - auto used_ram_gigabytes = (memtotal_ - memfree_) / std::pow(1024, 2); - auto available_ram_gigabytes = memfree_ / std::pow(1024, 2); + + unsigned long memtotal = meminfo_["MemTotal"]; + unsigned long memfree; + if (meminfo_.count("MemAvailable")) { + // New kernels (3.4+) have an accurate available memory field. + memfree = meminfo_["MemAvailable"]; + } else { + // Old kernel; give a best-effort approximation of available memory. + memfree = meminfo_["MemFree"] + meminfo_["Buffers"] + meminfo_["Cached"] + + meminfo_["SReclaimable"] - meminfo_["Shmem"]; + } + + if (memtotal > 0 && memfree >= 0) { + auto total_ram_gigabytes = memtotal / std::pow(1024, 2); + int used_ram_percentage = 100 * (memtotal - memfree) / memtotal; + auto used_ram_gigabytes = (memtotal - memfree) / std::pow(1024, 2); + auto available_ram_gigabytes = memfree / std::pow(1024, 2); getState(used_ram_percentage); label_.set_markup(fmt::format(format_, @@ -33,7 +45,6 @@ auto waybar::modules::Memory::update() -> void { } void waybar::modules::Memory::parseMeminfo() { - int64_t memfree = -1, membuffer = -1, memcache = -1, memavail = -1; std::ifstream info(data_dir_); if (!info.is_open()) { throw std::runtime_error("Can't open " + data_dir_); @@ -44,23 +55,9 @@ void waybar::modules::Memory::parseMeminfo() { if (posDelim == std::string::npos) { continue; } + std::string name = line.substr(0, posDelim); int64_t value = std::stol(line.substr(posDelim + 1)); - - if (name.compare("MemTotal") == 0) { - memtotal_ = value; - } else if (name.compare("MemAvailable") == 0) { - memavail = value; - } else if (name.compare("MemFree") == 0) { - memfree = value; - } else if (name.compare("Buffers") == 0) { - membuffer = value; - } else if (name.compare("Cached") == 0) { - memcache = value; - } - if (memtotal_ > 0 && (memavail >= 0 || (memfree > -1 && membuffer > -1 && memcache > -1))) { - break; - } + meminfo_[name] = value; } - memfree_ = memavail >= 0 ? memavail : memfree + membuffer + memcache; } From cb2f5c154c1177da05e16f4c7c62312d6c80e352 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 25 Mar 2020 22:25:27 +0100 Subject: [PATCH 09/17] feat(custon): restart_interval for continuous script --- man/waybar-custom.5.scd | 6 ++++++ src/modules/custom.cpp | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/man/waybar-custom.5.scd b/man/waybar-custom.5.scd index 0ae7f4c..92eda6c 100644 --- a/man/waybar-custom.5.scd +++ b/man/waybar-custom.5.scd @@ -33,6 +33,12 @@ Addressed by *custom/* You can update it manually with a signal. If no *interval* is defined, it is assumed that the out script loops it self. +*restart_interval*: ++ + typeof: integer ++ + The restart interval (in seconds). + Can't be used with the *interval* option, so only with continuous scripts. + Once the scripts exit, it'll be re-executed after the *restart_interval*. + *signal*: ++ typeof: integer ++ The signal number used to update the module. diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index ca09508..cbc865d 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -55,12 +55,21 @@ void waybar::modules::Custom::continuousWorker() { exit_code = WEXITSTATUS(util::command::close(fp_, pid_)); fp_ = nullptr; } - thread_.stop(); if (exit_code != 0) { output_ = {exit_code, ""}; dp.emit(); spdlog::error("{} stopped unexpectedly, is it endless?", name_); } + if (config_["restart_interval"].isUInt()) { + pid_ = -1; + fp_ = util::command::open(cmd, pid_); + if (!fp_) { + throw std::runtime_error("Unable to open " + cmd); + } + thread_.sleep_for(std::chrono::seconds(config_["restart_interval"].asUInt()); + } else { + thread_.stop(); + } return; } std::string output = buff; From d12ad1128ec606c6c46e851eaa69c2d50393cde2 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 25 Mar 2020 22:30:22 +0100 Subject: [PATCH 10/17] fix: man --- man/waybar-custom.5.scd | 4 ++-- src/modules/custom.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/man/waybar-custom.5.scd b/man/waybar-custom.5.scd index 92eda6c..905dbc1 100644 --- a/man/waybar-custom.5.scd +++ b/man/waybar-custom.5.scd @@ -33,11 +33,11 @@ Addressed by *custom/* You can update it manually with a signal. If no *interval* is defined, it is assumed that the out script loops it self. -*restart_interval*: ++ +*restart-interval*: ++ typeof: integer ++ The restart interval (in seconds). Can't be used with the *interval* option, so only with continuous scripts. - Once the scripts exit, it'll be re-executed after the *restart_interval*. + Once the script exit, it'll be re-executed after the *restart-interval*. *signal*: ++ typeof: integer ++ diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index cbc865d..c81f192 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -60,13 +60,13 @@ void waybar::modules::Custom::continuousWorker() { dp.emit(); spdlog::error("{} stopped unexpectedly, is it endless?", name_); } - if (config_["restart_interval"].isUInt()) { + if (config_["restart-interval"].isUInt()) { pid_ = -1; fp_ = util::command::open(cmd, pid_); if (!fp_) { throw std::runtime_error("Unable to open " + cmd); } - thread_.sleep_for(std::chrono::seconds(config_["restart_interval"].asUInt()); + thread_.sleep_for(std::chrono::seconds(config_["restart-interval"].asUInt()); } else { thread_.stop(); } From ff36154c4bfd23651ba5bcc8e966f825b09ffad7 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 25 Mar 2020 22:31:04 +0100 Subject: [PATCH 11/17] fix: typo --- src/modules/custom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index c81f192..24cfa71 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -66,7 +66,7 @@ void waybar::modules::Custom::continuousWorker() { if (!fp_) { throw std::runtime_error("Unable to open " + cmd); } - thread_.sleep_for(std::chrono::seconds(config_["restart-interval"].asUInt()); + thread_.sleep_for(std::chrono::seconds(config_["restart-interval"].asUInt())); } else { thread_.stop(); } From 9acf5587fa2e7d3575b06682a8b8d936a995e861 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 25 Mar 2020 22:53:09 +0100 Subject: [PATCH 12/17] refactor(pulseaudio): fallback to default muted format --- src/modules/pulseaudio.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/pulseaudio.cpp b/src/modules/pulseaudio.cpp index 3e9a95e..d79e6ae 100644 --- a/src/modules/pulseaudio.cpp +++ b/src/modules/pulseaudio.cpp @@ -215,7 +215,11 @@ auto waybar::modules::Pulseaudio::update() -> void { } else { label_.get_style_context()->remove_class("bluetooth"); } - if (muted_ ) { + if (muted_) { + // Check muted bluetooth format exist, otherwise fallback to default muted format + if (format_name != "format" && !config_[format_name + "-muted"].isString()) { + format_name = "format"; + } format_name = format_name + "-muted"; label_.get_style_context()->add_class("muted"); } else { From 10b152ac3e28c59c2ec818c5b34351f620420e44 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 26 Mar 2020 09:18:47 +0100 Subject: [PATCH 13/17] fix: process last line, restart-interval --- src/modules/custom.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index 24cfa71..71140bf 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -49,6 +49,7 @@ void waybar::modules::Custom::continuousWorker() { thread_ = [&] { char* buff = nullptr; size_t len = 0; + bool restart = false; if (getline(&buff, &len, fp_) == -1) { int exit_code = 1; if (fp_) { @@ -61,16 +62,11 @@ void waybar::modules::Custom::continuousWorker() { spdlog::error("{} stopped unexpectedly, is it endless?", name_); } if (config_["restart-interval"].isUInt()) { - pid_ = -1; - fp_ = util::command::open(cmd, pid_); - if (!fp_) { - throw std::runtime_error("Unable to open " + cmd); - } - thread_.sleep_for(std::chrono::seconds(config_["restart-interval"].asUInt())); + restart = true; } else { thread_.stop(); + return; } - return; } std::string output = buff; @@ -80,6 +76,14 @@ void waybar::modules::Custom::continuousWorker() { } output_ = {0, output}; dp.emit(); + if (restart) { + pid_ = -1; + fp_ = util::command::open(cmd, pid_); + if (!fp_) { + throw std::runtime_error("Unable to open " + cmd); + } + thread_.sleep_for(std::chrono::seconds(config_["restart-interval"].asUInt())); + } }; } From af96150f5c0d466045a325a80b7ad8820ccff419 Mon Sep 17 00:00:00 2001 From: Yuuki Harano Date: Sat, 28 Mar 2020 01:35:21 +0900 Subject: [PATCH 14/17] restore SIGCHLD settings to SIG_DFL. --- include/util/command.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/util/command.hpp b/include/util/command.hpp index 69b1fd4..8db7bfb 100644 --- a/include/util/command.hpp +++ b/include/util/command.hpp @@ -88,6 +88,7 @@ inline int32_t forkExec(std::string cmd) { // Child executes the command if (!pid) { setpgid(pid, pid); + signal(SIGCHLD, SIG_DFL); execl("/bin/sh", "sh", "-c", cmd.c_str(), (char*)0); exit(0); } else { From ec451b5908558388608be6bc94794ee4c9f77b81 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 30 Mar 2020 10:36:24 +0200 Subject: [PATCH 15/17] fix(command): check WIFEXITED --- include/util/command.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/util/command.hpp b/include/util/command.hpp index 8db7bfb..f3dd4e1 100644 --- a/include/util/command.hpp +++ b/include/util/command.hpp @@ -72,7 +72,10 @@ inline struct res exec(std::string cmd) { if (!fp) return {-1, ""}; auto output = command::read(fp); auto stat = command::close(fp, pid); - return {WEXITSTATUS(stat), output}; + if (WIFEXITED(stat)) { + return {WEXITSTATUS(stat), output}; + } + return {-1, output}; } inline int32_t forkExec(std::string cmd) { From bb2c16386b512d5684422045c5c46b872a8f5797 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 4 Apr 2020 21:13:25 +0200 Subject: [PATCH 16/17] feat: format-icon for persistent workspaces --- man/waybar-sway-workspaces.5.scd | 1 + src/modules/sway/workspaces.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/man/waybar-sway-workspaces.5.scd b/man/waybar-sway-workspaces.5.scd index fe38d23..c92b512 100644 --- a/man/waybar-sway-workspaces.5.scd +++ b/man/waybar-sway-workspaces.5.scd @@ -75,6 +75,7 @@ Additional to workspace name matching, the following *format-icons* can be set. - *default*: Will be shown, when no string matches is found. - *urgent*: Will be shown, when workspace is flagged as urgent - *focused*: Will be shown, when workspace is focused +- *persistent*: Will be shown, when workspace is persistent one. # PERSISTENT WORKSPACES diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp index fe87f5e..297935a 100644 --- a/src/modules/sway/workspaces.cpp +++ b/src/modules/sway/workspaces.cpp @@ -205,6 +205,8 @@ std::string Workspaces::getIcon(const std::string &name, const Json::Value &node if (config_["format-icons"][key].isString() && node[key].asBool()) { return config_["format-icons"][key].asString(); } + } else if (config_["format_icons"]["persistent"].isString() && node["target_output"].isString()) { + return config_["format-icons"]["persistent"].asString(); } else if (config_["format-icons"][key].isString()) { return config_["format-icons"][key].asString(); } From d5bd3be8de0f7f20f97628969fb328ffb5822b07 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 5 Apr 2020 16:12:25 +0200 Subject: [PATCH 17/17] chore: use native git --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index b8185c2..717f36f 100644 --- a/meson.build +++ b/meson.build @@ -25,7 +25,7 @@ else cpp_link_args += ['-lstdc++fs'] endif -git = find_program('git', required: false) +git = find_program('git', native: true, required: false) if not git.found() add_project_arguments('-DVERSION="@0@"'.format(meson.project_version()), language: 'cpp')