From 0f0765e5175d53217ddd200a04a488c9dca0ed30 Mon Sep 17 00:00:00 2001 From: Jordi Pakey-Rodriguez Date: Fri, 5 Jul 2019 14:46:38 -0700 Subject: [PATCH 01/12] feat(modules): call user on-update if configured --- src/AModule.cpp | 2 +- src/modules/backlight.cpp | 5 +++++ src/modules/battery.cpp | 5 +++++ src/modules/clock.cpp | 5 +++++ src/modules/cpu.cpp | 5 +++++ src/modules/custom.cpp | 5 +++++ src/modules/idle_inhibitor.cpp | 5 +++++ src/modules/memory.cpp | 5 +++++ src/modules/mpd.cpp | 5 +++++ src/modules/network.cpp | 5 +++++ src/modules/pulseaudio.cpp | 5 +++++ src/modules/temperature.cpp | 5 +++++ 12 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/AModule.cpp b/src/AModule.cpp index 354d1bf9..da43259d 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -29,7 +29,7 @@ AModule::~AModule() { } auto AModule::update() -> void { - // Nothing here + pid_.push_back(util::command::forkExec(config_["on-update"].asString())); } bool AModule::handleToggle(GdkEventButton* const& e) { diff --git a/src/modules/backlight.cpp b/src/modules/backlight.cpp index b38f2603..8b63bd6c 100644 --- a/src/modules/backlight.cpp +++ b/src/modules/backlight.cpp @@ -175,6 +175,11 @@ auto waybar::modules::Backlight::update() -> void { return; } + // Run user-provided update handler if configured + if (config_["on-update"].isString()) { + AModule::update(); + } + const auto percent = best->get_max() == 0 ? 100 : best->get_actual() * 100 / best->get_max(); label_.set_markup(fmt::format( format_, fmt::arg("percent", std::to_string(percent)), fmt::arg("icon", getIcon(percent)))); diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index 61ed50a4..b50c38a6 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -149,6 +149,11 @@ const std::string waybar::modules::Battery::formatTimeRemaining(float hoursRemai } auto waybar::modules::Battery::update() -> void { + // Run user-provided update handler if configured + if (config_["on-update"].isString()) { + AModule::update(); + } + auto [capacity, time_remaining, status] = getInfos(); if (status == "Unknown") { status = getAdapterStatus(capacity); diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index 2fa02142..5a781ef7 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -13,6 +13,11 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) } auto waybar::modules::Clock::update() -> void { + // Run user-provided update handler if configured + if (config_["on-update"].isString()) { + AModule::update(); + } + tzset(); // Update timezone information auto now = std::chrono::system_clock::now(); auto localtime = fmt::localtime(std::chrono::system_clock::to_time_t(now)); diff --git a/src/modules/cpu.cpp b/src/modules/cpu.cpp index 298f7a46..33d0d531 100644 --- a/src/modules/cpu.cpp +++ b/src/modules/cpu.cpp @@ -10,6 +10,11 @@ waybar::modules::Cpu::Cpu(const std::string& id, const Json::Value& config) } auto waybar::modules::Cpu::update() -> void { + // Run user-provided update handler if configured + if (config_["on-update"].isString()) { + AModule::update(); + } + // TODO: as creating dynamic fmt::arg arrays is buggy we have to calc both auto cpu_load = getCpuLoad(); auto [cpu_usage, tooltip] = getCpuUsage(); diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index ca095088..1853b2fa 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -93,6 +93,11 @@ bool waybar::modules::Custom::handleToggle(GdkEventButton* const& e) { } auto waybar::modules::Custom::update() -> void { + // Run user-provided update handler if configured + if (config_["on-update"].isString()) { + AModule::update(); + } + // Hide label if output is empty if (config_["exec"].isString() && (output_.out.empty() || output_.exit_code != 0)) { event_box_.hide(); diff --git a/src/modules/idle_inhibitor.cpp b/src/modules/idle_inhibitor.cpp index e5460ad8..c39e0114 100644 --- a/src/modules/idle_inhibitor.cpp +++ b/src/modules/idle_inhibitor.cpp @@ -26,6 +26,11 @@ waybar::modules::IdleInhibitor::~IdleInhibitor() { } auto waybar::modules::IdleInhibitor::update() -> void { + // Run user-provided update handler if configured + if (config_["on-update"].isString()) { + AModule::update(); + } + label_.set_markup( fmt::format(format_, fmt::arg("status", status_), fmt::arg("icon", getIcon(0, status_)))); label_.get_style_context()->add_class(status_); diff --git a/src/modules/memory.cpp b/src/modules/memory.cpp index eeb92bfe..3e1ed746 100644 --- a/src/modules/memory.cpp +++ b/src/modules/memory.cpp @@ -9,6 +9,11 @@ waybar::modules::Memory::Memory(const std::string& id, const Json::Value& config } auto waybar::modules::Memory::update() -> void { + // Run user-provided update handler if configured + if (config_["on-update"].isString()) { + AModule::update(); + } + parseMeminfo(); if (memtotal_ > 0 && memfree_ >= 0) { auto total_ram_gigabytes = memtotal_ / std::pow(1024, 2); diff --git a/src/modules/mpd.cpp b/src/modules/mpd.cpp index 7bad855b..f61dfc40 100644 --- a/src/modules/mpd.cpp +++ b/src/modules/mpd.cpp @@ -35,6 +35,11 @@ waybar::modules::MPD::MPD(const std::string& id, const Json::Value& config) } auto waybar::modules::MPD::update() -> void { + // Run user-provided update handler if configured + if (config_["on-update"].isString()) { + AModule::update(); + } + std::lock_guard guard(connection_lock_); tryConnect(); diff --git a/src/modules/network.cpp b/src/modules/network.cpp index ba196cff..9513a93d 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -228,6 +228,11 @@ const std::string waybar::modules::Network::getNetworkState() const { } auto waybar::modules::Network::update() -> void { + // Run user-provided update handler if configured + if (config_["on-update"].isString()) { + AModule::update(); + } + std::lock_guard lock(mutex_); std::string tooltip_format; auto down_octets = read_netstat(BANDWIDTH_CATEGORY, BANDWIDTH_DOWN_TOTAL_KEY); diff --git a/src/modules/pulseaudio.cpp b/src/modules/pulseaudio.cpp index ef2bc273..e336825c 100644 --- a/src/modules/pulseaudio.cpp +++ b/src/modules/pulseaudio.cpp @@ -196,6 +196,11 @@ const std::string waybar::modules::Pulseaudio::getPortIcon() const { } auto waybar::modules::Pulseaudio::update() -> void { + // Run user-provided update handler if configured + if (config_["on-update"].isString()) { + AModule::update(); + } + auto format = format_; std::string format_name = "format"; if (monitor_.find("a2dp_sink") != std::string::npos) { diff --git a/src/modules/temperature.cpp b/src/modules/temperature.cpp index 78391a0d..d17c2ad8 100644 --- a/src/modules/temperature.cpp +++ b/src/modules/temperature.cpp @@ -19,6 +19,11 @@ waybar::modules::Temperature::Temperature(const std::string& id, const Json::Val } auto waybar::modules::Temperature::update() -> void { + // Run user-provided update handler if configured + if (config_["on-update"].isString()) { + AModule::update(); + } + auto [temperature_c, temperature_f] = getTemperature(); auto critical = isCritical(temperature_c); auto format = format_; From 27fbea2b5afde7fd601aa4e2afb2b3a74c9110bf Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 6 Apr 2020 12:42:04 +0200 Subject: [PATCH 02/12] refactor(workspaces): default value unstripped, fix man --- man/waybar-sway-workspaces.5.scd | 6 ++++-- src/modules/sway/workspaces.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/man/waybar-sway-workspaces.5.scd b/man/waybar-sway-workspaces.5.scd index c92b512e..f9ef31d5 100644 --- a/man/waybar-sway-workspaces.5.scd +++ b/man/waybar-sway-workspaces.5.scd @@ -19,7 +19,7 @@ Addressed by *sway/workspaces* *format*: ++ typeof: string ++ - default: {name} ++ + default: {value} ++ The format, how information should be displayed. *format-icons*: ++ @@ -62,7 +62,9 @@ Addressed by *sway/workspaces* # FORMAT REPLACEMENTS -*{name}*: Name of the workspace, as defined by sway. +*{value}*: Name of the workspace, as defined by sway. + +*{name}*: Number stripped from workspace value. *{icon}*: Icon, as defined in *format-icons*. diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp index 297935ab..6aeaacaa 100644 --- a/src/modules/sway/workspaces.cpp +++ b/src/modules/sway/workspaces.cpp @@ -157,12 +157,13 @@ auto Workspaces::update() -> void { if (needReorder) { box_.reorder_child(button, it - workspaces_.begin()); } - std::string output = getIcon((*it)["name"].asString(), *it); + std::string output = (*it)["name"].asString(); if (config_["format"].isString()) { auto format = config_["format"].asString(); output = fmt::format(format, - fmt::arg("icon", output), - fmt::arg("name", trimWorkspaceName((*it)["name"].asString())), + fmt::arg("icon", getIcon(output, *it)), + fmt::arg("value", output) + fmt::arg("name", trimWorkspaceName(output)), fmt::arg("index", (*it)["num"].asString())); } if (!config_["disable-markup"].asBool()) { From 7c4ea397749f8afc78d88b2f624b2a0b30a3b81a Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 6 Apr 2020 12:49:41 +0200 Subject: [PATCH 03/12] fix: add missing comma --- src/modules/sway/workspaces.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp index 6aeaacaa..f61c98a8 100644 --- a/src/modules/sway/workspaces.cpp +++ b/src/modules/sway/workspaces.cpp @@ -162,7 +162,7 @@ auto Workspaces::update() -> void { auto format = config_["format"].asString(); output = fmt::format(format, fmt::arg("icon", getIcon(output, *it)), - fmt::arg("value", output) + fmt::arg("value", output), fmt::arg("name", trimWorkspaceName(output)), fmt::arg("index", (*it)["num"].asString())); } From ac3126b6cf1d30fb4adedd16f17eefa836b2d860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Pla=C3=A7ais?= Date: Fri, 10 Apr 2020 15:45:29 +0200 Subject: [PATCH 04/12] feat(layout): add pugixml dependency to dockerfiles --- Dockerfiles/alpine | 2 +- Dockerfiles/archlinux | 2 +- Dockerfiles/debian | 2 +- Dockerfiles/fedora | 2 +- Dockerfiles/opensuse | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfiles/alpine b/Dockerfiles/alpine index 78a78b67..fec63c2b 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 libnl3-dev pulseaudio-dev libmpdclient-dev scdoc +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 libnl3-dev pulseaudio-dev libmpdclient-dev scdoc diff --git a/Dockerfiles/archlinux b/Dockerfiles/archlinux index 9197fb81..b640ce72 100644 --- a/Dockerfiles/archlinux +++ b/Dockerfiles/archlinux @@ -3,4 +3,4 @@ FROM archlinux/base:latest RUN pacman -Syu --noconfirm && \ - pacman -S git meson base-devel libinput wayland wayland-protocols pixman libxkbcommon mesa gtkmm3 jsoncpp scdoc --noconfirm + pacman -S git meson base-devel libinput wayland wayland-protocols pixman libxkbcommon mesa gtkmm3 jsoncpp pugixml scdoc --noconfirm diff --git a/Dockerfiles/debian b/Dockerfiles/debian index 8d7a0651..eedbcfbe 100644 --- a/Dockerfiles/debian +++ b/Dockerfiles/debian @@ -3,5 +3,5 @@ FROM debian:sid RUN apt-get update && \ - apt-get install -y build-essential meson ninja-build git pkg-config libinput10 libinput-dev wayland-protocols libwayland-client0 libwayland-cursor0 libwayland-dev libegl1-mesa-dev libgles2-mesa-dev libgbm-dev libxkbcommon-dev libudev-dev libpixman-1-dev libgtkmm-3.0-dev libjsoncpp-dev scdoc && \ + apt-get install -y build-essential meson ninja-build git pkg-config libinput10 libpugixml-dev libinput-dev wayland-protocols libwayland-client0 libwayland-cursor0 libwayland-dev libegl1-mesa-dev libgles2-mesa-dev libgbm-dev libxkbcommon-dev libudev-dev libpixman-1-dev libgtkmm-3.0-dev libjsoncpp-dev scdoc && \ apt-get clean diff --git a/Dockerfiles/fedora b/Dockerfiles/fedora index af886073..7bd9d767 100644 --- a/Dockerfiles/fedora +++ b/Dockerfiles/fedora @@ -2,6 +2,6 @@ FROM fedora:30 -RUN dnf install sway meson git libinput-devel wayland-devel wayland-protocols-devel egl-wayland-devel mesa-libEGL-devel mesa-libGLES-devel mesa-libgbm-devel libxkbcommon-devel libudev-devel pixman-devel gtkmm30-devel jsoncpp-devel scdoc -y && \ +RUN dnf install sway meson git libinput-devel wayland-devel wayland-protocols-devel pugixml-devel egl-wayland-devel mesa-libEGL-devel mesa-libGLES-devel mesa-libgbm-devel libxkbcommon-devel libudev-devel pixman-devel gtkmm30-devel jsoncpp-devel scdoc -y && \ dnf group install "C Development Tools and Libraries" -y && \ dnf clean all -y diff --git a/Dockerfiles/opensuse b/Dockerfiles/opensuse index c54777ee..af1be95a 100644 --- a/Dockerfiles/opensuse +++ b/Dockerfiles/opensuse @@ -4,4 +4,4 @@ FROM opensuse/tumbleweed:latest RUN zypper -n up && \ zypper -n install -t pattern devel_C_C++ && \ - zypper -n install git meson clang libinput10 libinput-devel libwayland-client0 libwayland-cursor0 wayland-protocols-devel wayland-devel Mesa-libEGL-devel Mesa-libGLESv2-devel libgbm-devel libxkbcommon-devel libudev-devel libpixman-1-0-devel gtkmm3-devel jsoncpp-devel scdoc + zypper -n install git meson clang libinput10 libinput-devel libpugixml1 libwayland-client0 libwayland-cursor0 wayland-protocols-devel wayland-devel Mesa-libEGL-devel Mesa-libGLESv2-devel libgbm-devel libxkbcommon-devel libudev-devel libpixman-1-0-devel gtkmm3-devel jsoncpp-devel scdoc From 8f6273e9d005114676c51cf788165d6204c6e229 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 11 Apr 2020 12:08:21 +0200 Subject: [PATCH 05/12] refactor(config): comment default config layer --- resources/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/config b/resources/config index 237c787d..832f76c8 100644 --- a/resources/config +++ b/resources/config @@ -1,5 +1,5 @@ { - "layer": "top", // Waybar at top layer + // "layer": "top", // Waybar at top layer // "position": "bottom", // Waybar position (top|bottom|left|right) "height": 30, // Waybar height (to be removed for auto height) // "width": 1280, // Waybar width From b9338c72c9dddac9d38c76b23aa3502557982a19 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 11 Apr 2020 12:24:49 +0200 Subject: [PATCH 06/12] chore: 0.9.2 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 717f36fb..1dab13d9 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project( 'waybar', 'cpp', 'c', - version: '0.9.1', + version: '0.9.2', license: 'MIT', default_options : [ 'cpp_std=c++17', From b40cdcb5bd995a117e581343c69512536bf1ff31 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 12 Apr 2020 18:30:21 +0200 Subject: [PATCH 07/12] refactor: call parent update --- src/ALabel.cpp | 2 +- src/AModule.cpp | 5 ++++- src/modules/backlight.cpp | 2 ++ src/modules/battery.cpp | 7 ++----- src/modules/clock.cpp | 7 ++----- src/modules/cpu.cpp | 7 ++----- src/modules/custom.cpp | 7 ++----- src/modules/disk.cpp | 2 ++ src/modules/idle_inhibitor.cpp | 7 ++----- src/modules/memory.cpp | 7 ++----- src/modules/mpd.cpp | 8 +++----- src/modules/network.cpp | 8 +++----- src/modules/pulseaudio.cpp | 10 ++++------ src/modules/sway/mode.cpp | 2 ++ src/modules/sway/window.cpp | 2 ++ src/modules/sway/workspaces.cpp | 2 ++ src/modules/temperature.cpp | 7 ++----- 17 files changed, 39 insertions(+), 53 deletions(-) diff --git a/src/ALabel.cpp b/src/ALabel.cpp index 3d9f2b2b..e251f0db 100644 --- a/src/ALabel.cpp +++ b/src/ALabel.cpp @@ -31,7 +31,7 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st } auto ALabel::update() -> void { - // Nothing here + AModule::update(); } std::string ALabel::getIcon(uint16_t percentage, const std::string& alt, uint16_t max) { diff --git a/src/AModule.cpp b/src/AModule.cpp index da43259d..3066bfc1 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -29,7 +29,10 @@ AModule::~AModule() { } auto AModule::update() -> void { - pid_.push_back(util::command::forkExec(config_["on-update"].asString())); + // Run user-provided update handler if configured + if (config_["on-update"].isString()) { + pid_.push_back(util::command::forkExec(config_["on-update"].asString())); + } } bool AModule::handleToggle(GdkEventButton* const& e) { diff --git a/src/modules/backlight.cpp b/src/modules/backlight.cpp index 8b63bd6c..759c7c60 100644 --- a/src/modules/backlight.cpp +++ b/src/modules/backlight.cpp @@ -192,6 +192,8 @@ auto waybar::modules::Backlight::update() -> void { } previous_best_ = best == nullptr ? std::nullopt : std::optional{*best}; previous_format_ = format_; + // Call parent update + ALabel::update(); } template diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index b50c38a6..632abd97 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -149,11 +149,6 @@ const std::string waybar::modules::Battery::formatTimeRemaining(float hoursRemai } auto waybar::modules::Battery::update() -> void { - // Run user-provided update handler if configured - if (config_["on-update"].isString()) { - AModule::update(); - } - auto [capacity, time_remaining, status] = getInfos(); if (status == "Unknown") { status = getAdapterStatus(capacity); @@ -192,4 +187,6 @@ auto waybar::modules::Battery::update() -> void { fmt::arg("icon", getIcon(capacity, state)), fmt::arg("time", formatTimeRemaining(time_remaining)))); } + // Call parent update + ALabel::update(); } diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index 5a781ef7..4e058683 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -13,11 +13,6 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) } auto waybar::modules::Clock::update() -> void { - // Run user-provided update handler if configured - if (config_["on-update"].isString()) { - AModule::update(); - } - tzset(); // Update timezone information auto now = std::chrono::system_clock::now(); auto localtime = fmt::localtime(std::chrono::system_clock::to_time_t(now)); @@ -33,4 +28,6 @@ auto waybar::modules::Clock::update() -> void { label_.set_tooltip_text(text); } } + // Call parent update + ALabel::update(); } diff --git a/src/modules/cpu.cpp b/src/modules/cpu.cpp index 33d0d531..a0f646f5 100644 --- a/src/modules/cpu.cpp +++ b/src/modules/cpu.cpp @@ -10,11 +10,6 @@ waybar::modules::Cpu::Cpu(const std::string& id, const Json::Value& config) } auto waybar::modules::Cpu::update() -> void { - // Run user-provided update handler if configured - if (config_["on-update"].isString()) { - AModule::update(); - } - // TODO: as creating dynamic fmt::arg arrays is buggy we have to calc both auto cpu_load = getCpuLoad(); auto [cpu_usage, tooltip] = getCpuUsage(); @@ -23,6 +18,8 @@ auto waybar::modules::Cpu::update() -> void { } label_.set_markup(fmt::format(format_, fmt::arg("load", cpu_load), fmt::arg("usage", cpu_usage))); getState(cpu_usage); + // Call parent update + ALabel::update(); } uint16_t waybar::modules::Cpu::getCpuLoad() { diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index 1853b2fa..7a664474 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -93,11 +93,6 @@ bool waybar::modules::Custom::handleToggle(GdkEventButton* const& e) { } auto waybar::modules::Custom::update() -> void { - // Run user-provided update handler if configured - if (config_["on-update"].isString()) { - AModule::update(); - } - // Hide label if output is empty if (config_["exec"].isString() && (output_.out.empty() || output_.exit_code != 0)) { event_box_.hide(); @@ -133,6 +128,8 @@ auto waybar::modules::Custom::update() -> void { event_box_.show(); } } + // Call parent update + ALabel::update(); } void waybar::modules::Custom::parseOutputRaw() { diff --git a/src/modules/disk.cpp b/src/modules/disk.cpp index 811fe729..87240dee 100644 --- a/src/modules/disk.cpp +++ b/src/modules/disk.cpp @@ -73,4 +73,6 @@ auto waybar::modules::Disk::update() -> void { )); } event_box_.show(); + // Call parent update + ALabel::update(); } diff --git a/src/modules/idle_inhibitor.cpp b/src/modules/idle_inhibitor.cpp index c39e0114..d94e9579 100644 --- a/src/modules/idle_inhibitor.cpp +++ b/src/modules/idle_inhibitor.cpp @@ -26,17 +26,14 @@ waybar::modules::IdleInhibitor::~IdleInhibitor() { } auto waybar::modules::IdleInhibitor::update() -> void { - // Run user-provided update handler if configured - if (config_["on-update"].isString()) { - AModule::update(); - } - label_.set_markup( fmt::format(format_, fmt::arg("status", status_), fmt::arg("icon", getIcon(0, status_)))); label_.get_style_context()->add_class(status_); if (tooltipEnabled()) { label_.set_tooltip_text(status_); } + // Call parent update + ALabel::update(); } bool waybar::modules::IdleInhibitor::handleToggle(GdkEventButton* const& e) { diff --git a/src/modules/memory.cpp b/src/modules/memory.cpp index 3e1ed746..c5b8b409 100644 --- a/src/modules/memory.cpp +++ b/src/modules/memory.cpp @@ -9,11 +9,6 @@ waybar::modules::Memory::Memory(const std::string& id, const Json::Value& config } auto waybar::modules::Memory::update() -> void { - // Run user-provided update handler if configured - if (config_["on-update"].isString()) { - AModule::update(); - } - parseMeminfo(); if (memtotal_ > 0 && memfree_ >= 0) { auto total_ram_gigabytes = memtotal_ / std::pow(1024, 2); @@ -35,6 +30,8 @@ auto waybar::modules::Memory::update() -> void { } else { event_box_.hide(); } + // Call parent update + ALabel::update(); } void waybar::modules::Memory::parseMeminfo() { diff --git a/src/modules/mpd.cpp b/src/modules/mpd.cpp index f61dfc40..6dca5eea 100644 --- a/src/modules/mpd.cpp +++ b/src/modules/mpd.cpp @@ -35,11 +35,6 @@ waybar::modules::MPD::MPD(const std::string& id, const Json::Value& config) } auto waybar::modules::MPD::update() -> void { - // Run user-provided update handler if configured - if (config_["on-update"].isString()) { - AModule::update(); - } - std::lock_guard guard(connection_lock_); tryConnect(); @@ -61,6 +56,9 @@ auto waybar::modules::MPD::update() -> void { } setLabel(); + + // Call parent update + ALabel::update(); } std::thread waybar::modules::MPD::event_listener() { diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 9513a93d..54a92ba5 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -228,11 +228,6 @@ const std::string waybar::modules::Network::getNetworkState() const { } auto waybar::modules::Network::update() -> void { - // Run user-provided update handler if configured - if (config_["on-update"].isString()) { - AModule::update(); - } - std::lock_guard lock(mutex_); std::string tooltip_format; auto down_octets = read_netstat(BANDWIDTH_CATEGORY, BANDWIDTH_DOWN_TOTAL_KEY); @@ -314,6 +309,9 @@ auto waybar::modules::Network::update() -> void { label_.set_tooltip_text(text); } } + + // Call parent update + ALabel::update(); } // Based on https://gist.github.com/Yawning/c70d804d4b8ae78cc698 diff --git a/src/modules/pulseaudio.cpp b/src/modules/pulseaudio.cpp index e336825c..06c0ad81 100644 --- a/src/modules/pulseaudio.cpp +++ b/src/modules/pulseaudio.cpp @@ -196,11 +196,6 @@ const std::string waybar::modules::Pulseaudio::getPortIcon() const { } auto waybar::modules::Pulseaudio::update() -> void { - // Run user-provided update handler if configured - if (config_["on-update"].isString()) { - AModule::update(); - } - auto format = format_; std::string format_name = "format"; if (monitor_.find("a2dp_sink") != std::string::npos) { @@ -215,7 +210,7 @@ auto waybar::modules::Pulseaudio::update() -> void { } else { label_.get_style_context()->remove_class("muted"); } - format = + format = config_[format_name].isString() ? config_[format_name].asString() : format; // TODO: find a better way to split source/sink std::string format_source = "{volume}%"; @@ -234,4 +229,7 @@ auto waybar::modules::Pulseaudio::update() -> void { if (tooltipEnabled()) { label_.set_tooltip_text(desc_); } + + // Call parent update + ALabel::update(); } diff --git a/src/modules/sway/mode.cpp b/src/modules/sway/mode.cpp index cd02c0ca..33e4f722 100644 --- a/src/modules/sway/mode.cpp +++ b/src/modules/sway/mode.cpp @@ -51,6 +51,8 @@ auto Mode::update() -> void { } event_box_.show(); } + // Call parent update + ALabel::update(); } } // namespace waybar::modules::sway diff --git a/src/modules/sway/window.cpp b/src/modules/sway/window.cpp index 2e4ec468..1f90ebaf 100644 --- a/src/modules/sway/window.cpp +++ b/src/modules/sway/window.cpp @@ -64,6 +64,8 @@ auto Window::update() -> void { if (tooltipEnabled()) { label_.set_tooltip_text(window_); } + // Call parent update + ALabel::update(); } std::tuple Window::getFocusedNode( diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp index b65e47db..d0c8cc3c 100644 --- a/src/modules/sway/workspaces.cpp +++ b/src/modules/sway/workspaces.cpp @@ -176,6 +176,8 @@ auto Workspaces::update() -> void { } onButtonReady(*it, button); } + // Call parent update + AModule::update(); } Gtk::Button &Workspaces::addButton(const Json::Value &node) { diff --git a/src/modules/temperature.cpp b/src/modules/temperature.cpp index d17c2ad8..5508fd2b 100644 --- a/src/modules/temperature.cpp +++ b/src/modules/temperature.cpp @@ -19,11 +19,6 @@ waybar::modules::Temperature::Temperature(const std::string& id, const Json::Val } auto waybar::modules::Temperature::update() -> void { - // Run user-provided update handler if configured - if (config_["on-update"].isString()) { - AModule::update(); - } - auto [temperature_c, temperature_f] = getTemperature(); auto critical = isCritical(temperature_c); auto format = format_; @@ -38,6 +33,8 @@ auto waybar::modules::Temperature::update() -> void { fmt::arg("temperatureC", temperature_c), fmt::arg("temperatureF", temperature_f), fmt::arg("icon", getIcon(temperature_c, "", max_temp)))); + // Call parent update + ALabel::update(); } std::tuple waybar::modules::Temperature::getTemperature() { From 687c50dc137c43eb519a227db03625f1a2ffbc97 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 12 Apr 2020 18:31:07 +0200 Subject: [PATCH 08/12] refactor: remove old stuff --- src/modules/backlight.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/modules/backlight.cpp b/src/modules/backlight.cpp index 759c7c60..6349dbb4 100644 --- a/src/modules/backlight.cpp +++ b/src/modules/backlight.cpp @@ -175,11 +175,6 @@ auto waybar::modules::Backlight::update() -> void { return; } - // Run user-provided update handler if configured - if (config_["on-update"].isString()) { - AModule::update(); - } - const auto percent = best->get_max() == 0 ? 100 : best->get_actual() * 100 / best->get_max(); label_.set_markup(fmt::format( format_, fmt::arg("percent", std::to_string(percent)), fmt::arg("icon", getIcon(percent)))); From d1c4897f3196bf1d1a24cac7fe27349a6cc25161 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 12 Apr 2020 18:35:41 +0200 Subject: [PATCH 09/12] feat: update man --- man/waybar-backlight.5.scd | 6 +++++- man/waybar-battery.5.scd | 6 +++++- man/waybar-clock.5.scd | 4 ++++ man/waybar-cpu.5.scd | 4 ++++ man/waybar-custom.5.scd | 4 ++++ man/waybar-disk.5.scd | 4 ++++ man/waybar-idle-inhibitor.5.scd | 4 ++++ man/waybar-memory.5.scd | 4 ++++ man/waybar-mpd.5.scd | 4 ++++ man/waybar-network.5.scd | 4 ++++ man/waybar-pulseaudio.5.scd | 4 ++++ man/waybar-sway-mode.5.scd | 4 ++++ man/waybar-sway-window.5.scd | 4 ++++ man/waybar-sway-workspaces.5.scd | 4 ++++ man/waybar-temperature.5.scd | 4 ++++ man/waybar-tray.5.scd | 4 ++++ src/modules/sni/tray.cpp | 2 ++ 17 files changed, 68 insertions(+), 2 deletions(-) diff --git a/man/waybar-backlight.5.scd b/man/waybar-backlight.5.scd index 5f2bb82b..2ebfe7c2 100644 --- a/man/waybar-backlight.5.scd +++ b/man/waybar-backlight.5.scd @@ -40,10 +40,14 @@ The *backlight* module displays the current backlight level. typeof: string ++ Command to execute when middle-clicked on the module using mousewheel. -*on-click-right* ++ +*on-click-right*: ++ typeof: string ++ Command to execute when the module is right clicked. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up* ++ typeof: string ++ Command to execute when performing a scroll up on the module. diff --git a/man/waybar-battery.5.scd b/man/waybar-battery.5.scd index 8bcd2e82..3b67fd71 100644 --- a/man/waybar-battery.5.scd +++ b/man/waybar-battery.5.scd @@ -62,10 +62,14 @@ The *battery* module displays the current capacity and state (eg. charging) of y typeof: string ++ Command to execute when middle-clicked on the module using mousewheel. -*on-click-right* ++ +*on-click-right*: ++ typeof: string ++ Command to execute when you right clicked on the module. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. diff --git a/man/waybar-clock.5.scd b/man/waybar-clock.5.scd index 6684d897..3610f19d 100644 --- a/man/waybar-clock.5.scd +++ b/man/waybar-clock.5.scd @@ -51,6 +51,10 @@ The *clock* module displays the current date and time. typeof: string ++ Command to execute when you right clicked on the module. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. diff --git a/man/waybar-cpu.5.scd b/man/waybar-cpu.5.scd index 27dde96f..cb83134f 100644 --- a/man/waybar-cpu.5.scd +++ b/man/waybar-cpu.5.scd @@ -44,6 +44,10 @@ The *cpu* module displays the current cpu utilization. typeof: string ++ Command to execute when you right clicked on the module. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. diff --git a/man/waybar-custom.5.scd b/man/waybar-custom.5.scd index 905dbc1a..121585a9 100644 --- a/man/waybar-custom.5.scd +++ b/man/waybar-custom.5.scd @@ -73,6 +73,10 @@ Addressed by *custom/* typeof: string ++ Command to execute when you right clicked on the module. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. diff --git a/man/waybar-disk.5.scd b/man/waybar-disk.5.scd index 25d00b1c..1a9320ce 100644 --- a/man/waybar-disk.5.scd +++ b/man/waybar-disk.5.scd @@ -47,6 +47,10 @@ Addressed by *disk* typeof: string ++ Command to execute when you right clicked on the module. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. diff --git a/man/waybar-idle-inhibitor.5.scd b/man/waybar-idle-inhibitor.5.scd index 1fba291e..9d231d86 100644 --- a/man/waybar-idle-inhibitor.5.scd +++ b/man/waybar-idle-inhibitor.5.scd @@ -39,6 +39,10 @@ screensaving, also known as "presentation mode". typeof: string ++ Command to execute when you right clicked on the module. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. diff --git a/man/waybar-memory.5.scd b/man/waybar-memory.5.scd index 70718e14..81c62165 100644 --- a/man/waybar-memory.5.scd +++ b/man/waybar-memory.5.scd @@ -46,6 +46,10 @@ Addressed by *memory* typeof: string ++ Command to execute when you right clicked on the module. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. diff --git a/man/waybar-mpd.5.scd b/man/waybar-mpd.5.scd index fc3b1b36..1ee7a988 100644 --- a/man/waybar-mpd.5.scd +++ b/man/waybar-mpd.5.scd @@ -89,6 +89,10 @@ Addressed by *mpd* typeof: string ++ Command to execute when you right clicked on the module. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. diff --git a/man/waybar-network.5.scd b/man/waybar-network.5.scd index a557aa32..6bf2c944 100644 --- a/man/waybar-network.5.scd +++ b/man/waybar-network.5.scd @@ -72,6 +72,10 @@ Addressed by *network* typeof: string ++ Command to execute when you right clicked on the module. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. diff --git a/man/waybar-pulseaudio.5.scd b/man/waybar-pulseaudio.5.scd index 487888a4..c3f50e0b 100644 --- a/man/waybar-pulseaudio.5.scd +++ b/man/waybar-pulseaudio.5.scd @@ -67,6 +67,10 @@ Additionally you can control the volume by scrolling *up* or *down* while the cu typeof: string ++ Command to execute when you right clicked on the module. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. This replaces the default behaviour of volume control. diff --git a/man/waybar-sway-mode.5.scd b/man/waybar-sway-mode.5.scd index 85a25d13..958a1edb 100644 --- a/man/waybar-sway-mode.5.scd +++ b/man/waybar-sway-mode.5.scd @@ -37,6 +37,10 @@ Addressed by *sway/mode* typeof: string ++ Command to execute when you right clicked on the module. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. diff --git a/man/waybar-sway-window.5.scd b/man/waybar-sway-window.5.scd index 6a9d4e31..4863a76c 100644 --- a/man/waybar-sway-window.5.scd +++ b/man/waybar-sway-window.5.scd @@ -37,6 +37,10 @@ Addressed by *sway/window* typeof: string ++ Command to execute when you right clicked on the module. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. diff --git a/man/waybar-sway-workspaces.5.scd b/man/waybar-sway-workspaces.5.scd index f9ef31d5..18fe6f40 100644 --- a/man/waybar-sway-workspaces.5.scd +++ b/man/waybar-sway-workspaces.5.scd @@ -60,6 +60,10 @@ Addressed by *sway/workspaces* default: empty ++ Lists workspaces that should always be shown, even when non existent +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + # FORMAT REPLACEMENTS *{value}*: Name of the workspace, as defined by sway. diff --git a/man/waybar-temperature.5.scd b/man/waybar-temperature.5.scd index eeae5462..7c25e88a 100644 --- a/man/waybar-temperature.5.scd +++ b/man/waybar-temperature.5.scd @@ -70,6 +70,10 @@ Addressed by *temperature* typeof: string ++ Command to execute when you right clicked on the module. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + *on-scroll-up*: ++ typeof: string ++ Command to execute when scrolling up on the module. diff --git a/man/waybar-tray.5.scd b/man/waybar-tray.5.scd index bb4510d9..cd0e93f6 100644 --- a/man/waybar-tray.5.scd +++ b/man/waybar-tray.5.scd @@ -20,6 +20,10 @@ Addressed by *tray* typeof: integer ++ Defines the spacing between the tray icons. +*on-update*: ++ + typeof: string ++ + Command to execute when the module is updated. + # EXAMPLES ``` diff --git a/src/modules/sni/tray.cpp b/src/modules/sni/tray.cpp index e16837f5..ae3702c2 100644 --- a/src/modules/sni/tray.cpp +++ b/src/modules/sni/tray.cpp @@ -40,6 +40,8 @@ auto Tray::update() -> void { } else { box_.show_all(); } + // Call parent update + AModule::update(); } } // namespace waybar::modules::SNI From acc3ae6e625bb1d34a53ab28d7a19b72f64611bc Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 12 Apr 2020 18:41:44 +0200 Subject: [PATCH 10/12] refactor(man): add missing : --- man/waybar-backlight.5.scd | 18 +++++++++--------- man/waybar-battery.5.scd | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/man/waybar-backlight.5.scd b/man/waybar-backlight.5.scd index 2ebfe7c2..e6116e3e 100644 --- a/man/waybar-backlight.5.scd +++ b/man/waybar-backlight.5.scd @@ -10,29 +10,29 @@ The *backlight* module displays the current backlight level. # CONFIGURATION -*interval* ++ +*interval*: ++ typeof: integer ++ default: 2 ++ The interval in which information gets polled. -*format* ++ +*format*: ++ typeof: string ++ default: {percent}% ++ The format, how information should be displayed. On {} data gets inserted. -*max-length* ++ +*max-length*: ++ typeof: integer ++ The maximum length in characters the module should display. -*rotate* ++ +*rotate*: ++ typeof: integer ++ Positive value to rotate the text label. -*states* ++ +*states*: ++ typeof: array ++ A number of backlight states which get activated on certain brightness levels. -*on-click* ++ +*on-click*: ++ typeof: string ++ Command to execute when the module is clicked. @@ -48,15 +48,15 @@ The *backlight* module displays the current backlight level. typeof: string ++ Command to execute when the module is updated. -*on-scroll-up* ++ +*on-scroll-up*: ++ typeof: string ++ Command to execute when performing a scroll up on the module. -*on-scroll-down* ++ +*on-scroll-down*: ++ typeof: string Command to execute when performing a scroll down on the module. -*smooth-scrolling-threshold* ++ +*smooth-scrolling-threshold*: ++ typeof: double Threshold to be used when scrolling. diff --git a/man/waybar-battery.5.scd b/man/waybar-battery.5.scd index 3b67fd71..75d41081 100644 --- a/man/waybar-battery.5.scd +++ b/man/waybar-battery.5.scd @@ -10,33 +10,33 @@ The *battery* module displays the current capacity and state (eg. charging) of y # CONFIGURATION -*bat* ++ +*bat*: ++ typeof: string ++ The battery to monitor, as in /sys/class/power_supply/ instead of auto detect. -*adapter* ++ +*adapter*: ++ typeof: string ++ The adapter to monitor, as in /sys/class/power_supply/ instead of auto detect. -*full-at* ++ +*full-at*: ++ typeof: integer ++ Define the max percentage of the battery, usefull for an old battery, e.g. 96 -*interval* ++ +*interval*: ++ typeof: integer ++ default: 60 ++ The interval in which the information gets polled. -*states* ++ +*states*: ++ typeof: array ++ A number of battery states which get activated on certain capacity levels. See *waybar-states(5)*. -*format* ++ +*format*: ++ typeof: string ++ default: {capacity}% ++ The format, how the time should be displayed. -*format-time* ++ +*format-time*: ++ typeof: string ++ default: {H} h {M} min ++ The format, how the time should be displayed. @@ -78,11 +78,11 @@ The *battery* module displays the current capacity and state (eg. charging) of y typeof: string ++ Command to execute when scrolling down on the module. -*smooth-scrolling-threshold* ++ +*smooth-scrolling-threshold*: ++ typeof: double ++ Threshold to be used when scrolling. -*tooltip* ++ +*tooltip*: ++ typeof: bool ++ default: true ++ Option to disable tooltip on hover. From 345c7da384ad238960d8ef3dcba9659430f0644c Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 13 Apr 2020 17:07:16 +0200 Subject: [PATCH 11/12] chore: update fedora base --- .travis.yml | 1 + Dockerfiles/fedora | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a8538295..fd94669f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ env: - distro: archlinux - distro: fedora - distro: alpine + - distro: opensuse before_install: - docker pull alexays/waybar:${distro} diff --git a/Dockerfiles/fedora b/Dockerfiles/fedora index 7bd9d767..d75083c8 100644 --- a/Dockerfiles/fedora +++ b/Dockerfiles/fedora @@ -1,6 +1,6 @@ # vim: ft=Dockerfile -FROM fedora:30 +FROM fedora:32 RUN dnf install sway meson git libinput-devel wayland-devel wayland-protocols-devel pugixml-devel egl-wayland-devel mesa-libEGL-devel mesa-libGLES-devel mesa-libgbm-devel libxkbcommon-devel libudev-devel pixman-devel gtkmm30-devel jsoncpp-devel scdoc -y && \ dnf group install "C Development Tools and Libraries" -y && \ From 09ec40e38dcbb1553ed62a3ad2a3f8b47f5c5247 Mon Sep 17 00:00:00 2001 From: Danilo Spinella Date: Mon, 13 Apr 2020 18:02:50 +0200 Subject: [PATCH 12/12] fix(memory): add missing unordered_map include --- include/modules/memory.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/modules/memory.hpp b/include/modules/memory.hpp index 5b0f51bb..59f0e787 100644 --- a/include/modules/memory.hpp +++ b/include/modules/memory.hpp @@ -2,6 +2,7 @@ #include #include +#include #include "ALabel.hpp" #include "util/sleeper_thread.hpp"