From d5c400c0cc5f2ba1e8a414abfafe74ed5e1aeb00 Mon Sep 17 00:00:00 2001 From: Kenny Phelps-McKeown Date: Wed, 9 Feb 2022 02:53:52 -0500 Subject: [PATCH 01/30] Initial commit for Waybar JACK monitoring module -DSP load -xruns -connected/disconnected state -only tested with Pipewire so far but should work with JACK2 as well On branch dsp Changes to be committed: modified: include/factory.hpp new file: include/modules/jack.hpp modified: meson.build modified: meson_options.txt modified: src/factory.cpp new file: src/modules/jack.cpp --- include/factory.hpp | 3 + include/modules/jack.hpp | 29 +++++++++ meson.build | 9 +++ meson_options.txt | 2 + src/factory.cpp | 5 ++ src/modules/jack.cpp | 127 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 175 insertions(+) create mode 100644 include/modules/jack.hpp create mode 100644 src/modules/jack.cpp diff --git a/include/factory.hpp b/include/factory.hpp index 3855ce22..8702632d 100644 --- a/include/factory.hpp +++ b/include/factory.hpp @@ -62,6 +62,9 @@ # include "modules/bluetooth.hpp" # endif #endif +#ifdef HAVE_LIBJACK +#include "modules/jack.hpp" +#endif namespace waybar { diff --git a/include/modules/jack.hpp b/include/modules/jack.hpp new file mode 100644 index 00000000..df020964 --- /dev/null +++ b/include/modules/jack.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include +#include +#include +#include +#include "ALabel.hpp" +#include "util/sleeper_thread.hpp" + +namespace waybar::modules { + +class JACK : public ALabel { + public: + JACK(const std::string&, const Json::Value&); + ~JACK() = default; + auto update() -> void; + jack_nframes_t bufsize_; + jack_client_t* client_; + unsigned int xruns_; + std::string state_; + + private: + std::string JACKState(); + + jack_nframes_t samplerate_; + util::SleeperThread thread_; +}; + +} // namespace waybar::modules diff --git a/meson.build b/meson.build index 2c644cc3..33085903 100644 --- a/meson.build +++ b/meson.build @@ -97,6 +97,8 @@ libudev = dependency('libudev', required: get_option('libudev')) libevdev = dependency('libevdev', required: get_option('libevdev')) libmpdclient = dependency('libmpdclient', required: get_option('mpd')) xkbregistry = dependency('xkbregistry') +libjack = dependency('jack', required: get_option('jack')) +libprocps = dependency('libprocps', required: get_option('jack')) libsndio = compiler.find_library('sndio', required: get_option('sndio')) if libsndio.found() @@ -207,6 +209,11 @@ if libpulse.found() src_files += 'src/modules/pulseaudio.cpp' endif +if libjack.found() and libprocps.found() + add_project_arguments('-DHAVE_LIBJACK', language: 'cpp') + src_files += 'src/modules/jack.cpp' +endif + if dbusmenu_gtk.found() add_project_arguments('-DHAVE_DBUSMENU', language: 'cpp') src_files += files( @@ -288,6 +295,8 @@ executable( libnl, libnlgen, libpulse, + libjack, + libprocps, libudev, libepoll, libmpdclient, diff --git a/meson_options.txt b/meson_options.txt index 230a53d6..a41f70a6 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -13,3 +13,5 @@ option('sndio', type: 'feature', value: 'auto', description: 'Enable support for option('logind', type: 'feature', value: 'auto', description: 'Enable support for logind') option('tests', type: 'feature', value: 'auto', description: 'Enable tests') option('experimental', type : 'boolean', value : false, description: 'Enable experimental features') +option('jack', type: 'feature', value: 'auto', description: 'Enable support for JACK DSP load monitoring') + diff --git a/src/factory.cpp b/src/factory.cpp index 900653b5..30325fef 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -85,6 +85,11 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name) const { return new waybar::modules::Pulseaudio(id, config_[name]); } #endif +#ifdef HAVE_LIBJACK + if (ref == "jack") { + return new waybar::modules::JACK(id, config_[name]); + } +#endif #ifdef HAVE_LIBMPDCLIENT if (ref == "mpd") { return new waybar::modules::MPD(id, config_[name]); diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp new file mode 100644 index 00000000..08d14140 --- /dev/null +++ b/src/modules/jack.cpp @@ -0,0 +1,127 @@ +#include "modules/jack.hpp" + +extern "C" { + + int bufSizeCallback(unsigned int size, void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + x->bufsize_ = size; + return size; + } + + int xrunCallback(void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + x->xruns_ += 1; + x->state_ = "xrun"; + return 0; + } + + void shutdownCallback(void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + x->client_ = NULL; + x->state_ = "disconnected"; + x->xruns_ = 0; + } + +} + +waybar::modules::JACK::JACK(const std::string& id, const Json::Value& config) + : ALabel(config, "jack", id, "{load}%", 1) { + xruns_ = 0; + state_ = "disconnected"; + client_ = NULL; + + state_ = JACKState(); + thread_ = [this] { + dp.emit(); + thread_.sleep_for(interval_); + }; +} + +std::string waybar::modules::JACK::JACKState() { + if(state_.compare("xrun") == 0) + return "xrun"; + if(state_.compare("connected") == 0) + return "connected"; + + std::string procname; + bool foundJACK = false; + proc_t** proctab = readproctab(PROC_FILLSTAT); + for(int i=0; proctab[i]; i++) { + procname = proctab[i]->cmd; + if(!procname.compare("jackd") || !procname.compare("pipewire")) + foundJACK = true; + freeproc(proctab[i]); + } + free(proctab); + if(!foundJACK) + return "disconnected"; + + client_ = jack_client_open("waybar", JackNoStartServer, NULL); + + if (client_) { + bufsize_ = jack_get_buffer_size(client_); + samplerate_ = jack_get_sample_rate(client_); + jack_set_buffer_size_callback(client_, bufSizeCallback, this); + jack_set_xrun_callback(client_, xrunCallback, this); + jack_on_shutdown(client_, shutdownCallback, this); + + if (!jack_activate(client_)) + return "connected"; + } + return "disconnected"; +} + +auto waybar::modules::JACK::update() -> void { + std::string format; + float latency = 1000 * (float)bufsize_ / (float)samplerate_; + auto state = JACKState(); + float load; + + if(label_.get_style_context()->has_class("xrun")) { + label_.get_style_context()->remove_class("xrun"); + state = "connected"; + } + + if(state.compare("disconnected") != 0) + load = jack_cpu_load(client_); + else { + load = 0; + bufsize_ = 0; + samplerate_ = 0; + latency = 0; + } + + if(label_.get_style_context()->has_class(state_)) + label_.get_style_context()->remove_class(state_); + + if (config_["format-" + state].isString()) { + format = config_["format-" + state].asString(); + } else if (config_["format"].isString()) { + format = config_["format"].asString(); + } else format = "DSP {load}%"; + + if(!label_.get_style_context()->has_class(state)) + label_.get_style_context()->add_class(state); + state_ = state; + + label_.set_markup(fmt::format(format, fmt::arg("load", std::round(load)), + fmt::arg("bufsize", bufsize_), + fmt::arg("samplerate", samplerate_), + fmt::arg("latency", fmt::format("{:.2f}", latency)), + fmt::arg("xruns", xruns_))); + + if (tooltipEnabled()) { + std::string tooltip_format = "{bufsize}/{samplerate} {latency}ms"; + if (config_["tooltip-format"].isString()) + tooltip_format = config_["tooltip-format"].asString(); + label_.set_tooltip_text(fmt::format(tooltip_format, fmt::arg("load", std::round(load)), + fmt::arg("bufsize", bufsize_), + fmt::arg("samplerate", samplerate_), + fmt::arg("latency", fmt::format("{:.2f}", latency)), + fmt::arg("xruns", xruns_))); + + } + + // Call parent update + ALabel::update(); +} From c1cda1553ae07409dd1e14092e83ae704e5154cb Mon Sep 17 00:00:00 2001 From: kennypm Date: Sat, 12 Feb 2022 01:51:11 -0500 Subject: [PATCH 02/30] fix callbacks --- include/modules/jack.hpp | 6 ++++++ src/modules/jack.cpp | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/modules/jack.hpp b/include/modules/jack.hpp index df020964..2433a43e 100644 --- a/include/modules/jack.hpp +++ b/include/modules/jack.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "ALabel.hpp" #include "util/sleeper_thread.hpp" @@ -18,6 +19,7 @@ class JACK : public ALabel { jack_client_t* client_; unsigned int xruns_; std::string state_; + pthread_t jack_thread_; private: std::string JACKState(); @@ -27,3 +29,7 @@ class JACK : public ALabel { }; } // namespace waybar::modules + +int bufSizeCallback(unsigned int size, void *obj); +int xrunCallback(void *obj); +void shutdownCallback(void *obj); diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index 08d14140..ab43c332 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -1,6 +1,6 @@ #include "modules/jack.hpp" -extern "C" { +//extern "C" { int bufSizeCallback(unsigned int size, void *obj) { waybar::modules::JACK* x = (waybar::modules::JACK*)obj; @@ -17,12 +17,13 @@ extern "C" { void shutdownCallback(void *obj) { waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + pthread_cancel(x->jack_thread_); x->client_ = NULL; x->state_ = "disconnected"; x->xruns_ = 0; } -} +//} waybar::modules::JACK::JACK(const std::string& id, const Json::Value& config) : ALabel(config, "jack", id, "{load}%", 1) { @@ -57,8 +58,11 @@ std::string waybar::modules::JACK::JACKState() { return "disconnected"; client_ = jack_client_open("waybar", JackNoStartServer, NULL); - if (client_) { + jack_thread_ = jack_client_thread_id(client_); + if(config_["realtime"].isBool() && !config_["realtime"].asBool()) + jack_drop_real_time_scheduling(jack_thread_); + bufsize_ = jack_get_buffer_size(client_); samplerate_ = jack_get_sample_rate(client_); jack_set_buffer_size_callback(client_, bufSizeCallback, this); From 3bf815f6def5e4e3a75187b9e3dc391772006ef1 Mon Sep 17 00:00:00 2001 From: kennypm Date: Sat, 12 Feb 2022 01:52:51 -0500 Subject: [PATCH 03/30] fix callbacks --- src/modules/jack.cpp | 46 ++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index ab43c332..fd183c7e 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -1,30 +1,5 @@ #include "modules/jack.hpp" -//extern "C" { - - int bufSizeCallback(unsigned int size, void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - x->bufsize_ = size; - return size; - } - - int xrunCallback(void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - x->xruns_ += 1; - x->state_ = "xrun"; - return 0; - } - - void shutdownCallback(void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - pthread_cancel(x->jack_thread_); - x->client_ = NULL; - x->state_ = "disconnected"; - x->xruns_ = 0; - } - -//} - waybar::modules::JACK::JACK(const std::string& id, const Json::Value& config) : ALabel(config, "jack", id, "{load}%", 1) { xruns_ = 0; @@ -129,3 +104,24 @@ auto waybar::modules::JACK::update() -> void { // Call parent update ALabel::update(); } + +int bufSizeCallback(unsigned int size, void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + x->bufsize_ = size; + return size; +} + +int xrunCallback(void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + x->xruns_ += 1; + x->state_ = "xrun"; + return 0; +} + +void shutdownCallback(void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + pthread_cancel(x->jack_thread_); + x->client_ = NULL; + x->state_ = "disconnected"; + x->xruns_ = 0; +} From 823ed887ab6d24920ceaefcce6ae1bd09ac7c505 Mon Sep 17 00:00:00 2001 From: Kenny Phelps-McKeown <64751911+kennypm@users.noreply.github.com> Date: Sat, 12 Feb 2022 05:53:32 -0500 Subject: [PATCH 04/30] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index c5806e3b..c8535738 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +## note: this fork depends on libjack and libprocps as well as the dependencies listed below + + + + + # Waybar [![Licence](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Paypal Donate](https://img.shields.io/badge/Donate-Paypal-2244dd.svg)](https://paypal.me/ARouillard)
![Waybar](https://raw.githubusercontent.com/alexays/waybar/master/preview-2.png) > Highly customizable Wayland bar for Sway and Wlroots based compositors.
From e6262b870cccd888240ff552d7cd7738d9072670 Mon Sep 17 00:00:00 2001 From: kennypm Date: Fri, 18 Feb 2022 02:13:43 -0500 Subject: [PATCH 05/30] changed callbacks to use static_cast --- include/modules/jack.hpp | 14 +++++++++----- src/modules/jack.cpp | 35 ++++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/include/modules/jack.hpp b/include/modules/jack.hpp index 2433a43e..71753985 100644 --- a/include/modules/jack.hpp +++ b/include/modules/jack.hpp @@ -15,16 +15,20 @@ class JACK : public ALabel { JACK(const std::string&, const Json::Value&); ~JACK() = default; auto update() -> void; - jack_nframes_t bufsize_; - jack_client_t* client_; - unsigned int xruns_; - std::string state_; - pthread_t jack_thread_; + + int bufSize(unsigned int size); + int xrun(); + void shutdown(); private: std::string JACKState(); + jack_client_t* client_; + jack_nframes_t bufsize_; jack_nframes_t samplerate_; + unsigned int xruns_; + std::string state_; + pthread_t jack_thread_; util::SleeperThread thread_; }; diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index fd183c7e..45dab230 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -105,23 +105,32 @@ auto waybar::modules::JACK::update() -> void { ALabel::update(); } -int bufSizeCallback(unsigned int size, void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - x->bufsize_ = size; +int waybar::modules::JACK::bufSize(unsigned int size) { + bufsize_ = size; return size; } -int xrunCallback(void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - x->xruns_ += 1; - x->state_ = "xrun"; +int waybar::modules::JACK::xrun() { + xruns_ += 1; + state_ = "xrun"; return 0; } -void shutdownCallback(void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - pthread_cancel(x->jack_thread_); - x->client_ = NULL; - x->state_ = "disconnected"; - x->xruns_ = 0; +void waybar::modules::JACK::shutdown() { + pthread_cancel(jack_thread_); + client_ = NULL; + state_ = "disconnected"; + xruns_ = 0; +} + +int bufSizeCallback(unsigned int size, void *obj) { + return static_cast(obj)->bufSize(size); +} + +int xrunCallback(void *obj) { + return static_cast(obj)->xrun(); +} + +void shutdownCallback(void *obj) { + return static_cast(obj)->shutdown(); } From ccce2b700b823be87ac91819d9611486675a42fe Mon Sep 17 00:00:00 2001 From: kennypm Date: Thu, 24 Feb 2022 02:46:45 -0500 Subject: [PATCH 06/30] fix segfault when stopping JACK2 server --- meson.build | 2 +- src/modules/jack.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 33085903..e0fb452b 100644 --- a/meson.build +++ b/meson.build @@ -5,7 +5,7 @@ project( meson_version: '>= 0.49.0', default_options : [ 'cpp_std=c++17', - 'buildtype=release', + 'buildtype=debug', 'default_library=static' ], ) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index 45dab230..af4870ed 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -24,7 +24,8 @@ std::string waybar::modules::JACK::JACKState() { proc_t** proctab = readproctab(PROC_FILLSTAT); for(int i=0; proctab[i]; i++) { procname = proctab[i]->cmd; - if(!procname.compare("jackd") || !procname.compare("pipewire")) + if(!procname.compare("jackd") || !procname.compare("jackdbus") || + !procname.compare("pipewire")) foundJACK = true; freeproc(proctab[i]); } @@ -116,8 +117,14 @@ int waybar::modules::JACK::xrun() { return 0; } +/* +** problem: pipewire leaves old client threads hanging around after server +** is killed. was handling this sloppily by calling pthread_cancel() on the +** JACK thread but since JACK2 cleans up after itself properly, this call +** led to segfault when using JACK2. probably best course of action is to +** submit a bug report to pipewire. +*/ void waybar::modules::JACK::shutdown() { - pthread_cancel(jack_thread_); client_ = NULL; state_ = "disconnected"; xruns_ = 0; From 8fc8bb40bff1d43f1db0aec61b207eb562bcd6ad Mon Sep 17 00:00:00 2001 From: Kenny Phelps-McKeown Date: Wed, 9 Feb 2022 02:53:52 -0500 Subject: [PATCH 07/30] Initial commit for Waybar JACK monitoring module -DSP load -xruns -connected/disconnected state -only tested with Pipewire so far but should work with JACK2 as well On branch dsp Changes to be committed: modified: include/factory.hpp new file: include/modules/jack.hpp modified: meson.build modified: meson_options.txt modified: src/factory.cpp new file: src/modules/jack.cpp --- include/factory.hpp | 4 ++ include/modules/jack.hpp | 29 +++++++++ meson.build | 9 +++ meson_options.txt | 2 + src/factory.cpp | 5 ++ src/modules/jack.cpp | 127 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 176 insertions(+) create mode 100644 include/modules/jack.hpp create mode 100644 src/modules/jack.cpp diff --git a/include/factory.hpp b/include/factory.hpp index 1e79bd79..14f2033b 100644 --- a/include/factory.hpp +++ b/include/factory.hpp @@ -67,6 +67,10 @@ #include "modules/custom.hpp" #include "modules/temperature.hpp" +#ifdef HAVE_LIBJACK +#include "modules/jack.hpp" +#endif + namespace waybar { class Factory { diff --git a/include/modules/jack.hpp b/include/modules/jack.hpp new file mode 100644 index 00000000..df020964 --- /dev/null +++ b/include/modules/jack.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include +#include +#include +#include +#include "ALabel.hpp" +#include "util/sleeper_thread.hpp" + +namespace waybar::modules { + +class JACK : public ALabel { + public: + JACK(const std::string&, const Json::Value&); + ~JACK() = default; + auto update() -> void; + jack_nframes_t bufsize_; + jack_client_t* client_; + unsigned int xruns_; + std::string state_; + + private: + std::string JACKState(); + + jack_nframes_t samplerate_; + util::SleeperThread thread_; +}; + +} // namespace waybar::modules diff --git a/meson.build b/meson.build index 441ccfb2..c6bdd7e2 100644 --- a/meson.build +++ b/meson.build @@ -98,6 +98,8 @@ libudev = dependency('libudev', required: get_option('libudev')) libevdev = dependency('libevdev', required: get_option('libevdev')) libmpdclient = dependency('libmpdclient', required: get_option('mpd')) xkbregistry = dependency('xkbregistry') +libjack = dependency('jack', required: get_option('jack')) +libprocps = dependency('libprocps', required: get_option('jack')) libsndio = compiler.find_library('sndio', required: get_option('sndio')) if libsndio.found() @@ -222,6 +224,11 @@ if libpulse.found() src_files += 'src/modules/pulseaudio.cpp' endif +if libjack.found() and libprocps.found() + add_project_arguments('-DHAVE_LIBJACK', language: 'cpp') + src_files += 'src/modules/jack.cpp' +endif + if dbusmenu_gtk.found() add_project_arguments('-DHAVE_DBUSMENU', language: 'cpp') src_files += files( @@ -302,6 +309,8 @@ executable( libnlgen, upower_glib, libpulse, + libjack, + libprocps, libudev, libepoll, libmpdclient, diff --git a/meson_options.txt b/meson_options.txt index d2e98476..acbcce73 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -14,3 +14,5 @@ option('sndio', type: 'feature', value: 'auto', description: 'Enable support for option('logind', type: 'feature', value: 'auto', description: 'Enable support for logind') option('tests', type: 'feature', value: 'auto', description: 'Enable tests') option('experimental', type : 'boolean', value : false, description: 'Enable experimental features') +option('jack', type: 'feature', value: 'auto', description: 'Enable support for JACK DSP load monitoring') + diff --git a/src/factory.cpp b/src/factory.cpp index 841465f4..76ff65f7 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -101,6 +101,11 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name) const { return new waybar::modules::Pulseaudio(id, config_[name]); } #endif +#ifdef HAVE_LIBJACK + if (ref == "jack") { + return new waybar::modules::JACK(id, config_[name]); + } +#endif #ifdef HAVE_LIBMPDCLIENT if (ref == "mpd") { return new waybar::modules::MPD(id, config_[name]); diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp new file mode 100644 index 00000000..08d14140 --- /dev/null +++ b/src/modules/jack.cpp @@ -0,0 +1,127 @@ +#include "modules/jack.hpp" + +extern "C" { + + int bufSizeCallback(unsigned int size, void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + x->bufsize_ = size; + return size; + } + + int xrunCallback(void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + x->xruns_ += 1; + x->state_ = "xrun"; + return 0; + } + + void shutdownCallback(void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + x->client_ = NULL; + x->state_ = "disconnected"; + x->xruns_ = 0; + } + +} + +waybar::modules::JACK::JACK(const std::string& id, const Json::Value& config) + : ALabel(config, "jack", id, "{load}%", 1) { + xruns_ = 0; + state_ = "disconnected"; + client_ = NULL; + + state_ = JACKState(); + thread_ = [this] { + dp.emit(); + thread_.sleep_for(interval_); + }; +} + +std::string waybar::modules::JACK::JACKState() { + if(state_.compare("xrun") == 0) + return "xrun"; + if(state_.compare("connected") == 0) + return "connected"; + + std::string procname; + bool foundJACK = false; + proc_t** proctab = readproctab(PROC_FILLSTAT); + for(int i=0; proctab[i]; i++) { + procname = proctab[i]->cmd; + if(!procname.compare("jackd") || !procname.compare("pipewire")) + foundJACK = true; + freeproc(proctab[i]); + } + free(proctab); + if(!foundJACK) + return "disconnected"; + + client_ = jack_client_open("waybar", JackNoStartServer, NULL); + + if (client_) { + bufsize_ = jack_get_buffer_size(client_); + samplerate_ = jack_get_sample_rate(client_); + jack_set_buffer_size_callback(client_, bufSizeCallback, this); + jack_set_xrun_callback(client_, xrunCallback, this); + jack_on_shutdown(client_, shutdownCallback, this); + + if (!jack_activate(client_)) + return "connected"; + } + return "disconnected"; +} + +auto waybar::modules::JACK::update() -> void { + std::string format; + float latency = 1000 * (float)bufsize_ / (float)samplerate_; + auto state = JACKState(); + float load; + + if(label_.get_style_context()->has_class("xrun")) { + label_.get_style_context()->remove_class("xrun"); + state = "connected"; + } + + if(state.compare("disconnected") != 0) + load = jack_cpu_load(client_); + else { + load = 0; + bufsize_ = 0; + samplerate_ = 0; + latency = 0; + } + + if(label_.get_style_context()->has_class(state_)) + label_.get_style_context()->remove_class(state_); + + if (config_["format-" + state].isString()) { + format = config_["format-" + state].asString(); + } else if (config_["format"].isString()) { + format = config_["format"].asString(); + } else format = "DSP {load}%"; + + if(!label_.get_style_context()->has_class(state)) + label_.get_style_context()->add_class(state); + state_ = state; + + label_.set_markup(fmt::format(format, fmt::arg("load", std::round(load)), + fmt::arg("bufsize", bufsize_), + fmt::arg("samplerate", samplerate_), + fmt::arg("latency", fmt::format("{:.2f}", latency)), + fmt::arg("xruns", xruns_))); + + if (tooltipEnabled()) { + std::string tooltip_format = "{bufsize}/{samplerate} {latency}ms"; + if (config_["tooltip-format"].isString()) + tooltip_format = config_["tooltip-format"].asString(); + label_.set_tooltip_text(fmt::format(tooltip_format, fmt::arg("load", std::round(load)), + fmt::arg("bufsize", bufsize_), + fmt::arg("samplerate", samplerate_), + fmt::arg("latency", fmt::format("{:.2f}", latency)), + fmt::arg("xruns", xruns_))); + + } + + // Call parent update + ALabel::update(); +} From 9439e4183c93ad77598112fe6add88e0b879b71d Mon Sep 17 00:00:00 2001 From: kennypm Date: Sat, 12 Feb 2022 01:51:11 -0500 Subject: [PATCH 08/30] fix callbacks --- include/modules/jack.hpp | 6 ++++++ src/modules/jack.cpp | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/modules/jack.hpp b/include/modules/jack.hpp index df020964..2433a43e 100644 --- a/include/modules/jack.hpp +++ b/include/modules/jack.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "ALabel.hpp" #include "util/sleeper_thread.hpp" @@ -18,6 +19,7 @@ class JACK : public ALabel { jack_client_t* client_; unsigned int xruns_; std::string state_; + pthread_t jack_thread_; private: std::string JACKState(); @@ -27,3 +29,7 @@ class JACK : public ALabel { }; } // namespace waybar::modules + +int bufSizeCallback(unsigned int size, void *obj); +int xrunCallback(void *obj); +void shutdownCallback(void *obj); diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index 08d14140..ab43c332 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -1,6 +1,6 @@ #include "modules/jack.hpp" -extern "C" { +//extern "C" { int bufSizeCallback(unsigned int size, void *obj) { waybar::modules::JACK* x = (waybar::modules::JACK*)obj; @@ -17,12 +17,13 @@ extern "C" { void shutdownCallback(void *obj) { waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + pthread_cancel(x->jack_thread_); x->client_ = NULL; x->state_ = "disconnected"; x->xruns_ = 0; } -} +//} waybar::modules::JACK::JACK(const std::string& id, const Json::Value& config) : ALabel(config, "jack", id, "{load}%", 1) { @@ -57,8 +58,11 @@ std::string waybar::modules::JACK::JACKState() { return "disconnected"; client_ = jack_client_open("waybar", JackNoStartServer, NULL); - if (client_) { + jack_thread_ = jack_client_thread_id(client_); + if(config_["realtime"].isBool() && !config_["realtime"].asBool()) + jack_drop_real_time_scheduling(jack_thread_); + bufsize_ = jack_get_buffer_size(client_); samplerate_ = jack_get_sample_rate(client_); jack_set_buffer_size_callback(client_, bufSizeCallback, this); From bc8517fd08e2f3ff5de7ec603a6fdf09bbbd699c Mon Sep 17 00:00:00 2001 From: kennypm Date: Sat, 12 Feb 2022 01:52:51 -0500 Subject: [PATCH 09/30] fix callbacks --- src/modules/jack.cpp | 46 ++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index ab43c332..fd183c7e 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -1,30 +1,5 @@ #include "modules/jack.hpp" -//extern "C" { - - int bufSizeCallback(unsigned int size, void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - x->bufsize_ = size; - return size; - } - - int xrunCallback(void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - x->xruns_ += 1; - x->state_ = "xrun"; - return 0; - } - - void shutdownCallback(void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - pthread_cancel(x->jack_thread_); - x->client_ = NULL; - x->state_ = "disconnected"; - x->xruns_ = 0; - } - -//} - waybar::modules::JACK::JACK(const std::string& id, const Json::Value& config) : ALabel(config, "jack", id, "{load}%", 1) { xruns_ = 0; @@ -129,3 +104,24 @@ auto waybar::modules::JACK::update() -> void { // Call parent update ALabel::update(); } + +int bufSizeCallback(unsigned int size, void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + x->bufsize_ = size; + return size; +} + +int xrunCallback(void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + x->xruns_ += 1; + x->state_ = "xrun"; + return 0; +} + +void shutdownCallback(void *obj) { + waybar::modules::JACK* x = (waybar::modules::JACK*)obj; + pthread_cancel(x->jack_thread_); + x->client_ = NULL; + x->state_ = "disconnected"; + x->xruns_ = 0; +} From c7b09eea1199bf166cfb66b8c6b16a27ad1e3713 Mon Sep 17 00:00:00 2001 From: kennypm Date: Fri, 18 Feb 2022 02:13:43 -0500 Subject: [PATCH 10/30] changed callbacks to use static_cast --- include/modules/jack.hpp | 14 +++++++++----- src/modules/jack.cpp | 35 ++++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/include/modules/jack.hpp b/include/modules/jack.hpp index 2433a43e..71753985 100644 --- a/include/modules/jack.hpp +++ b/include/modules/jack.hpp @@ -15,16 +15,20 @@ class JACK : public ALabel { JACK(const std::string&, const Json::Value&); ~JACK() = default; auto update() -> void; - jack_nframes_t bufsize_; - jack_client_t* client_; - unsigned int xruns_; - std::string state_; - pthread_t jack_thread_; + + int bufSize(unsigned int size); + int xrun(); + void shutdown(); private: std::string JACKState(); + jack_client_t* client_; + jack_nframes_t bufsize_; jack_nframes_t samplerate_; + unsigned int xruns_; + std::string state_; + pthread_t jack_thread_; util::SleeperThread thread_; }; diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index fd183c7e..45dab230 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -105,23 +105,32 @@ auto waybar::modules::JACK::update() -> void { ALabel::update(); } -int bufSizeCallback(unsigned int size, void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - x->bufsize_ = size; +int waybar::modules::JACK::bufSize(unsigned int size) { + bufsize_ = size; return size; } -int xrunCallback(void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - x->xruns_ += 1; - x->state_ = "xrun"; +int waybar::modules::JACK::xrun() { + xruns_ += 1; + state_ = "xrun"; return 0; } -void shutdownCallback(void *obj) { - waybar::modules::JACK* x = (waybar::modules::JACK*)obj; - pthread_cancel(x->jack_thread_); - x->client_ = NULL; - x->state_ = "disconnected"; - x->xruns_ = 0; +void waybar::modules::JACK::shutdown() { + pthread_cancel(jack_thread_); + client_ = NULL; + state_ = "disconnected"; + xruns_ = 0; +} + +int bufSizeCallback(unsigned int size, void *obj) { + return static_cast(obj)->bufSize(size); +} + +int xrunCallback(void *obj) { + return static_cast(obj)->xrun(); +} + +void shutdownCallback(void *obj) { + return static_cast(obj)->shutdown(); } From a1d046b2e729577dc8358920bfe5e3f0dde392aa Mon Sep 17 00:00:00 2001 From: Kenny Phelps-McKeown <64751911+kennypm@users.noreply.github.com> Date: Sat, 12 Feb 2022 05:53:32 -0500 Subject: [PATCH 11/30] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 248eef01..191e3097 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +## note: this fork depends on libjack and libprocps as well as the dependencies listed below + + + + + # Waybar [![Licence](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Paypal Donate](https://img.shields.io/badge/Donate-Paypal-2244dd.svg)](https://paypal.me/ARouillard)
![Waybar](https://raw.githubusercontent.com/alexays/waybar/master/preview-2.png) > Highly customizable Wayland bar for Sway and Wlroots based compositors.
From 318a6e09699f963ecb7db2e07d5d131d2a3ca9d1 Mon Sep 17 00:00:00 2001 From: kennypm Date: Thu, 24 Feb 2022 02:46:45 -0500 Subject: [PATCH 12/30] fix segfault when stopping JACK2 server --- meson.build | 2 +- src/modules/jack.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index c6bdd7e2..5300a0ed 100644 --- a/meson.build +++ b/meson.build @@ -5,7 +5,7 @@ project( meson_version: '>= 0.49.0', default_options : [ 'cpp_std=c++17', - 'buildtype=release', + 'buildtype=debug', 'default_library=static' ], ) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index 45dab230..af4870ed 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -24,7 +24,8 @@ std::string waybar::modules::JACK::JACKState() { proc_t** proctab = readproctab(PROC_FILLSTAT); for(int i=0; proctab[i]; i++) { procname = proctab[i]->cmd; - if(!procname.compare("jackd") || !procname.compare("pipewire")) + if(!procname.compare("jackd") || !procname.compare("jackdbus") || + !procname.compare("pipewire")) foundJACK = true; freeproc(proctab[i]); } @@ -116,8 +117,14 @@ int waybar::modules::JACK::xrun() { return 0; } +/* +** problem: pipewire leaves old client threads hanging around after server +** is killed. was handling this sloppily by calling pthread_cancel() on the +** JACK thread but since JACK2 cleans up after itself properly, this call +** led to segfault when using JACK2. probably best course of action is to +** submit a bug report to pipewire. +*/ void waybar::modules::JACK::shutdown() { - pthread_cancel(jack_thread_); client_ = NULL; state_ = "disconnected"; xruns_ = 0; From 5e7c9378dfafa732c6d7f168bd4d4a8e0fd8a9b8 Mon Sep 17 00:00:00 2001 From: kennypm Date: Tue, 19 Jul 2022 01:40:05 -0400 Subject: [PATCH 13/30] update fork --- include/factory.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/factory.hpp b/include/factory.hpp index eed33431..14f2033b 100644 --- a/include/factory.hpp +++ b/include/factory.hpp @@ -67,9 +67,6 @@ #include "modules/custom.hpp" #include "modules/temperature.hpp" -#ifdef HAVE_LIBJACK -#include "modules/jack.hpp" -#endif #ifdef HAVE_LIBJACK #include "modules/jack.hpp" #endif From b65c976bc109a7808a75acd126d17fa7502390b2 Mon Sep 17 00:00:00 2001 From: kennypm Date: Tue, 19 Jul 2022 01:41:32 -0400 Subject: [PATCH 14/30] fix build type --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 5300a0ed..c6bdd7e2 100644 --- a/meson.build +++ b/meson.build @@ -5,7 +5,7 @@ project( meson_version: '>= 0.49.0', default_options : [ 'cpp_std=c++17', - 'buildtype=debug', + 'buildtype=release', 'default_library=static' ], ) From 8b5f42d9343e7965ca118a2575872bb31205b522 Mon Sep 17 00:00:00 2001 From: kennypm Date: Tue, 19 Jul 2022 19:27:39 -0400 Subject: [PATCH 15/30] remove unnecessary libprocps dependency --- README.md | 6 ------ include/modules/jack.hpp | 2 -- meson.build | 4 +--- meson_options.txt | 2 +- src/modules/jack.cpp | 18 ++---------------- 5 files changed, 4 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 191e3097..248eef01 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,3 @@ -## note: this fork depends on libjack and libprocps as well as the dependencies listed below - - - - - # Waybar [![Licence](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Paypal Donate](https://img.shields.io/badge/Donate-Paypal-2244dd.svg)](https://paypal.me/ARouillard)
![Waybar](https://raw.githubusercontent.com/alexays/waybar/master/preview-2.png) > Highly customizable Wayland bar for Sway and Wlroots based compositors.
diff --git a/include/modules/jack.hpp b/include/modules/jack.hpp index 71753985..4c1921d6 100644 --- a/include/modules/jack.hpp +++ b/include/modules/jack.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include "ALabel.hpp" #include "util/sleeper_thread.hpp" @@ -28,7 +27,6 @@ class JACK : public ALabel { jack_nframes_t samplerate_; unsigned int xruns_; std::string state_; - pthread_t jack_thread_; util::SleeperThread thread_; }; diff --git a/meson.build b/meson.build index c6bdd7e2..f519380e 100644 --- a/meson.build +++ b/meson.build @@ -99,7 +99,6 @@ libevdev = dependency('libevdev', required: get_option('libevdev')) libmpdclient = dependency('libmpdclient', required: get_option('mpd')) xkbregistry = dependency('xkbregistry') libjack = dependency('jack', required: get_option('jack')) -libprocps = dependency('libprocps', required: get_option('jack')) libsndio = compiler.find_library('sndio', required: get_option('sndio')) if libsndio.found() @@ -224,7 +223,7 @@ if libpulse.found() src_files += 'src/modules/pulseaudio.cpp' endif -if libjack.found() and libprocps.found() +if libjack.found() add_project_arguments('-DHAVE_LIBJACK', language: 'cpp') src_files += 'src/modules/jack.cpp' endif @@ -310,7 +309,6 @@ executable( upower_glib, libpulse, libjack, - libprocps, libudev, libepoll, libmpdclient, diff --git a/meson_options.txt b/meson_options.txt index acbcce73..5fd1b7a7 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -9,7 +9,7 @@ option('dbusmenu-gtk', type: 'feature', value: 'auto', description: 'Enable supp option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages') option('mpd', type: 'feature', value: 'auto', description: 'Enable support for the Music Player Daemon') option('gtk-layer-shell', type: 'feature', value: 'auto', description: 'Use gtk-layer-shell library for popups support') -option('rfkill', type: 'feature', value: 'auto', description: 'Enable support for RFKILL') +option('rfkill', type: 'feature', value: 'enabled', description: 'Enable support for RFKILL') option('sndio', type: 'feature', value: 'auto', description: 'Enable support for sndio') option('logind', type: 'feature', value: 'auto', description: 'Enable support for logind') option('tests', type: 'feature', value: 'auto', description: 'Enable tests') diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index af4870ed..85268bbe 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -19,25 +19,11 @@ std::string waybar::modules::JACK::JACKState() { if(state_.compare("connected") == 0) return "connected"; - std::string procname; - bool foundJACK = false; - proc_t** proctab = readproctab(PROC_FILLSTAT); - for(int i=0; proctab[i]; i++) { - procname = proctab[i]->cmd; - if(!procname.compare("jackd") || !procname.compare("jackdbus") || - !procname.compare("pipewire")) - foundJACK = true; - freeproc(proctab[i]); - } - free(proctab); - if(!foundJACK) - return "disconnected"; - client_ = jack_client_open("waybar", JackNoStartServer, NULL); if (client_) { - jack_thread_ = jack_client_thread_id(client_); + pthread_t jack_thread = jack_client_thread_id(client_); if(config_["realtime"].isBool() && !config_["realtime"].asBool()) - jack_drop_real_time_scheduling(jack_thread_); + jack_drop_real_time_scheduling(jack_thread); bufsize_ = jack_get_buffer_size(client_); samplerate_ = jack_get_sample_rate(client_); From 4cd6024f07c71bd5e69fb8b5f2f69b770e160b2e Mon Sep 17 00:00:00 2001 From: kennypm Date: Tue, 19 Jul 2022 19:36:48 -0400 Subject: [PATCH 16/30] move issue from comment to Issues --- src/modules/jack.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index 85268bbe..932aa85b 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -103,13 +103,6 @@ int waybar::modules::JACK::xrun() { return 0; } -/* -** problem: pipewire leaves old client threads hanging around after server -** is killed. was handling this sloppily by calling pthread_cancel() on the -** JACK thread but since JACK2 cleans up after itself properly, this call -** led to segfault when using JACK2. probably best course of action is to -** submit a bug report to pipewire. -*/ void waybar::modules::JACK::shutdown() { client_ = NULL; state_ = "disconnected"; From 714451e4f93c25e7fccabce70c5c530c66b0eb4d Mon Sep 17 00:00:00 2001 From: kennypm Date: Tue, 19 Jul 2022 19:40:23 -0400 Subject: [PATCH 17/30] cleanup --- include/factory.hpp | 7 +++---- meson_options.txt | 2 +- src/factory.cpp | 10 +++++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/factory.hpp b/include/factory.hpp index 14f2033b..2d7a505a 100644 --- a/include/factory.hpp +++ b/include/factory.hpp @@ -63,13 +63,12 @@ #include "modules/bluetooth.hpp" #include "modules/inhibitor.hpp" #endif -#include "bar.hpp" -#include "modules/custom.hpp" -#include "modules/temperature.hpp" - #ifdef HAVE_LIBJACK #include "modules/jack.hpp" #endif +#include "bar.hpp" +#include "modules/custom.hpp" +#include "modules/temperature.hpp" namespace waybar { diff --git a/meson_options.txt b/meson_options.txt index 5fd1b7a7..acbcce73 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -9,7 +9,7 @@ option('dbusmenu-gtk', type: 'feature', value: 'auto', description: 'Enable supp option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages') option('mpd', type: 'feature', value: 'auto', description: 'Enable support for the Music Player Daemon') option('gtk-layer-shell', type: 'feature', value: 'auto', description: 'Use gtk-layer-shell library for popups support') -option('rfkill', type: 'feature', value: 'enabled', description: 'Enable support for RFKILL') +option('rfkill', type: 'feature', value: 'auto', description: 'Enable support for RFKILL') option('sndio', type: 'feature', value: 'auto', description: 'Enable support for sndio') option('logind', type: 'feature', value: 'auto', description: 'Enable support for logind') option('tests', type: 'feature', value: 'auto', description: 'Enable tests') diff --git a/src/factory.cpp b/src/factory.cpp index 76ff65f7..3e0c873c 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -101,11 +101,6 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name) const { return new waybar::modules::Pulseaudio(id, config_[name]); } #endif -#ifdef HAVE_LIBJACK - if (ref == "jack") { - return new waybar::modules::JACK(id, config_[name]); - } -#endif #ifdef HAVE_LIBMPDCLIENT if (ref == "mpd") { return new waybar::modules::MPD(id, config_[name]); @@ -123,6 +118,11 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name) const { if (ref == "inhibitor") { return new waybar::modules::Inhibitor(id, bar_, config_[name]); } +#endif +#ifdef HAVE_LIBJACK + if (ref == "jack") { + return new waybar::modules::JACK(id, config_[name]); + } #endif if (ref == "temperature") { return new waybar::modules::Temperature(id, config_[name]); From 23eaffc04ba7979a95c4e8bb21b9785331febd36 Mon Sep 17 00:00:00 2001 From: kennypm Date: Tue, 19 Jul 2022 21:49:56 -0400 Subject: [PATCH 18/30] fix Linter errors --- src/modules/jack.cpp | 50 +++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index 932aa85b..efb021f5 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -1,12 +1,12 @@ #include "modules/jack.hpp" -waybar::modules::JACK::JACK(const std::string& id, const Json::Value& config) +waybar::modules::JACK::JACK(const std::string &id, const Json::Value &config) : ALabel(config, "jack", id, "{load}%", 1) { - xruns_ = 0; - state_ = "disconnected"; + xruns_ = 0; + state_ = "disconnected"; client_ = NULL; - state_ = JACKState(); + state_ = JACKState(); thread_ = [this] { dp.emit(); thread_.sleep_for(interval_); @@ -14,15 +14,13 @@ waybar::modules::JACK::JACK(const std::string& id, const Json::Value& config) } std::string waybar::modules::JACK::JACKState() { - if(state_.compare("xrun") == 0) - return "xrun"; - if(state_.compare("connected") == 0) - return "connected"; + if (state_.compare("xrun") == 0) return "xrun"; + if (state_.compare("connected") == 0) return "connected"; client_ = jack_client_open("waybar", JackNoStartServer, NULL); if (client_) { pthread_t jack_thread = jack_client_thread_id(client_); - if(config_["realtime"].isBool() && !config_["realtime"].asBool()) + if (config_["realtime"].isBool() && !config_["realtime"].asBool()) jack_drop_real_time_scheduling(jack_thread); bufsize_ = jack_get_buffer_size(client_); @@ -31,8 +29,7 @@ std::string waybar::modules::JACK::JACKState() { jack_set_xrun_callback(client_, xrunCallback, this); jack_on_shutdown(client_, shutdownCallback, this); - if (!jack_activate(client_)) - return "connected"; + if (!jack_activate(client_)) return "connected"; } return "disconnected"; } @@ -43,12 +40,12 @@ auto waybar::modules::JACK::update() -> void { auto state = JACKState(); float load; - if(label_.get_style_context()->has_class("xrun")) { + if (label_.get_style_context()->has_class("xrun")) { label_.get_style_context()->remove_class("xrun"); state = "connected"; } - if(state.compare("disconnected") != 0) + if (state.compare("disconnected") != 0) load = jack_cpu_load(client_); else { load = 0; @@ -57,29 +54,28 @@ auto waybar::modules::JACK::update() -> void { latency = 0; } - if(label_.get_style_context()->has_class(state_)) + if (label_.get_style_context()->has_class(state_)) label_.get_style_context()->remove_class(state_); if (config_["format-" + state].isString()) { format = config_["format-" + state].asString(); } else if (config_["format"].isString()) { format = config_["format"].asString(); - } else format = "DSP {load}%"; + } else + format = "DSP {load}%"; - if(!label_.get_style_context()->has_class(state)) + if (!label_.get_style_context()->has_class(state)) label_.get_style_context()->add_class(state); state_ = state; label_.set_markup(fmt::format(format, fmt::arg("load", std::round(load)), - fmt::arg("bufsize", bufsize_), - fmt::arg("samplerate", samplerate_), - fmt::arg("latency", fmt::format("{:.2f}", latency)), - fmt::arg("xruns", xruns_))); + fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_), + fmt::arg("latency", fmt::format("{:.2f}", latency)), + fmt::arg("xruns", xruns_))); if (tooltipEnabled()) { std::string tooltip_format = "{bufsize}/{samplerate} {latency}ms"; - if (config_["tooltip-format"].isString()) - tooltip_format = config_["tooltip-format"].asString(); + if (config_["tooltip-format"].isString()) tooltip_format = config_["tooltip-format"].asString(); label_.set_tooltip_text(fmt::format(tooltip_format, fmt::arg("load", std::round(load)), fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_), @@ -110,13 +106,9 @@ void waybar::modules::JACK::shutdown() { } int bufSizeCallback(unsigned int size, void *obj) { - return static_cast(obj)->bufSize(size); + return static_cast(obj)->bufSize(size); } -int xrunCallback(void *obj) { - return static_cast(obj)->xrun(); -} +int xrunCallback(void *obj) { return static_cast(obj)->xrun(); } -void shutdownCallback(void *obj) { - return static_cast(obj)->shutdown(); -} +void shutdownCallback(void *obj) { return static_cast(obj)->shutdown(); } From 02df86182904ae4404474fdf7bd538d5459e42c6 Mon Sep 17 00:00:00 2001 From: kennypm Date: Tue, 19 Jul 2022 21:53:32 -0400 Subject: [PATCH 19/30] fix Linter errors --- src/modules/jack.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index efb021f5..6cbccfeb 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -64,8 +64,7 @@ auto waybar::modules::JACK::update() -> void { } else format = "DSP {load}%"; - if (!label_.get_style_context()->has_class(state)) - label_.get_style_context()->add_class(state); + if (!label_.get_style_context()->has_class(state)) label_.get_style_context()->add_class(state); state_ = state; label_.set_markup(fmt::format(format, fmt::arg("load", std::round(load)), @@ -76,11 +75,10 @@ auto waybar::modules::JACK::update() -> void { if (tooltipEnabled()) { std::string tooltip_format = "{bufsize}/{samplerate} {latency}ms"; if (config_["tooltip-format"].isString()) tooltip_format = config_["tooltip-format"].asString(); - label_.set_tooltip_text(fmt::format(tooltip_format, fmt::arg("load", std::round(load)), - fmt::arg("bufsize", bufsize_), - fmt::arg("samplerate", samplerate_), - fmt::arg("latency", fmt::format("{:.2f}", latency)), - fmt::arg("xruns", xruns_))); + label_.set_tooltip_text(fmt::format( + tooltip_format, fmt::arg("load", std::round(load)), fmt::arg("bufsize", bufsize_), + fmt::arg("samplerate", samplerate_), fmt::arg("latency", fmt::format("{:.2f}", latency)), + fmt::arg("xruns", xruns_))); } From 4cb2cc9f217a264914a17a43c319e4714d1002df Mon Sep 17 00:00:00 2001 From: kennypm Date: Tue, 19 Jul 2022 21:54:36 -0400 Subject: [PATCH 20/30] fix Linter errors --- src/modules/jack.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index 6cbccfeb..484a91da 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -79,7 +79,6 @@ auto waybar::modules::JACK::update() -> void { tooltip_format, fmt::arg("load", std::round(load)), fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_), fmt::arg("latency", fmt::format("{:.2f}", latency)), fmt::arg("xruns", xruns_))); - } // Call parent update From 92870cab2aeb4f9011fc8073edf79541e1d8ceed Mon Sep 17 00:00:00 2001 From: kennypm Date: Tue, 19 Jul 2022 22:30:42 -0400 Subject: [PATCH 21/30] namespace cleanup --- src/modules/jack.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index 484a91da..a5617df2 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -1,6 +1,8 @@ #include "modules/jack.hpp" -waybar::modules::JACK::JACK(const std::string &id, const Json::Value &config) +namespace waybar::modules { + +JACK::JACK(const std::string &id, const Json::Value &config) : ALabel(config, "jack", id, "{load}%", 1) { xruns_ = 0; state_ = "disconnected"; @@ -13,7 +15,7 @@ waybar::modules::JACK::JACK(const std::string &id, const Json::Value &config) }; } -std::string waybar::modules::JACK::JACKState() { +std::string JACK::JACKState() { if (state_.compare("xrun") == 0) return "xrun"; if (state_.compare("connected") == 0) return "connected"; @@ -34,7 +36,7 @@ std::string waybar::modules::JACK::JACKState() { return "disconnected"; } -auto waybar::modules::JACK::update() -> void { +auto JACK::update() -> void { std::string format; float latency = 1000 * (float)bufsize_ / (float)samplerate_; auto state = JACKState(); @@ -85,23 +87,27 @@ auto waybar::modules::JACK::update() -> void { ALabel::update(); } -int waybar::modules::JACK::bufSize(unsigned int size) { +int JACK::bufSize(unsigned int size) { bufsize_ = size; return size; } -int waybar::modules::JACK::xrun() { +int JACK::xrun() { xruns_ += 1; state_ = "xrun"; return 0; } -void waybar::modules::JACK::shutdown() { +void JACK::shutdown() { client_ = NULL; state_ = "disconnected"; xruns_ = 0; } +} // namespace waybar::modules + +namespace { + int bufSizeCallback(unsigned int size, void *obj) { return static_cast(obj)->bufSize(size); } @@ -109,3 +115,5 @@ int bufSizeCallback(unsigned int size, void *obj) { int xrunCallback(void *obj) { return static_cast(obj)->xrun(); } void shutdownCallback(void *obj) { return static_cast(obj)->shutdown(); } + +} // namespace From decc5bcd68389ba2882794823ae87140fdc68a16 Mon Sep 17 00:00:00 2001 From: kennypm Date: Tue, 19 Jul 2022 22:34:35 -0400 Subject: [PATCH 22/30] namespace cleanup --- src/modules/jack.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index a5617df2..92b09efa 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -106,8 +106,6 @@ void JACK::shutdown() { } // namespace waybar::modules -namespace { - int bufSizeCallback(unsigned int size, void *obj) { return static_cast(obj)->bufSize(size); } @@ -116,4 +114,3 @@ int xrunCallback(void *obj) { return static_cast(obj)-> void shutdownCallback(void *obj) { return static_cast(obj)->shutdown(); } -} // namespace From 15dbe8965e5f071300c2ffc5491f770de4a4ed38 Mon Sep 17 00:00:00 2001 From: kennypm Date: Tue, 19 Jul 2022 22:36:59 -0400 Subject: [PATCH 23/30] fix Linter error --- src/modules/jack.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index 92b09efa..b62a4207 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -113,4 +113,3 @@ int bufSizeCallback(unsigned int size, void *obj) { int xrunCallback(void *obj) { return static_cast(obj)->xrun(); } void shutdownCallback(void *obj) { return static_cast(obj)->shutdown(); } - From ddd5b4e1576480fe894c0a5aad1837cf294f30de Mon Sep 17 00:00:00 2001 From: kennypm Date: Sun, 7 Aug 2022 15:29:42 -0400 Subject: [PATCH 24/30] refactor --- include/modules/jack.hpp | 3 +++ src/modules/jack.cpp | 51 ++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/include/modules/jack.hpp b/include/modules/jack.hpp index 4c1921d6..e3a09cd6 100644 --- a/include/modules/jack.hpp +++ b/include/modules/jack.hpp @@ -26,6 +26,9 @@ class JACK : public ALabel { jack_nframes_t bufsize_; jack_nframes_t samplerate_; unsigned int xruns_; + float load_; + bool running_; + std::mutex mutex_; std::string state_; util::SleeperThread thread_; }; diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index b62a4207..14117785 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -1,14 +1,13 @@ #include "modules/jack.hpp" +#include namespace waybar::modules { JACK::JACK(const std::string &id, const Json::Value &config) : ALabel(config, "jack", id, "{load}%", 1) { - xruns_ = 0; - state_ = "disconnected"; + running_ = false; client_ = NULL; - state_ = JACKState(); thread_ = [this] { dp.emit(); thread_.sleep_for(interval_); @@ -16,8 +15,20 @@ JACK::JACK(const std::string &id, const Json::Value &config) } std::string JACK::JACKState() { - if (state_.compare("xrun") == 0) return "xrun"; - if (state_.compare("connected") == 0) return "connected"; + if (running_) { + load_ = jack_cpu_load(client_); + return state_; + } + + xruns_ = 0; + load_ = 0; + bufsize_ = 0; + samplerate_ = 0; + + if (client_) { +// jack_client_close(client_); + client_ = NULL; + } client_ = jack_client_open("waybar", JackNoStartServer, NULL); if (client_) { @@ -31,33 +42,28 @@ std::string JACK::JACKState() { jack_set_xrun_callback(client_, xrunCallback, this); jack_on_shutdown(client_, shutdownCallback, this); - if (!jack_activate(client_)) return "connected"; + if (!jack_activate(client_)) { + running_ = true; + return "connected"; + } } return "disconnected"; } auto JACK::update() -> void { std::string format; - float latency = 1000 * (float)bufsize_ / (float)samplerate_; auto state = JACKState(); - float load; + float latency = 1000 * (float)bufsize_ / (float)samplerate_; if (label_.get_style_context()->has_class("xrun")) { label_.get_style_context()->remove_class("xrun"); state = "connected"; } - if (state.compare("disconnected") != 0) - load = jack_cpu_load(client_); - else { - load = 0; - bufsize_ = 0; - samplerate_ = 0; - latency = 0; - } - if (label_.get_style_context()->has_class(state_)) label_.get_style_context()->remove_class(state_); + label_.get_style_context()->add_class(state); + state_ = state; if (config_["format-" + state].isString()) { format = config_["format-" + state].asString(); @@ -66,10 +72,7 @@ auto JACK::update() -> void { } else format = "DSP {load}%"; - if (!label_.get_style_context()->has_class(state)) label_.get_style_context()->add_class(state); - state_ = state; - - label_.set_markup(fmt::format(format, fmt::arg("load", std::round(load)), + label_.set_markup(fmt::format(format, fmt::arg("load", std::round(load_)), fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_), fmt::arg("latency", fmt::format("{:.2f}", latency)), fmt::arg("xruns", xruns_))); @@ -78,7 +81,7 @@ auto JACK::update() -> void { std::string tooltip_format = "{bufsize}/{samplerate} {latency}ms"; if (config_["tooltip-format"].isString()) tooltip_format = config_["tooltip-format"].asString(); label_.set_tooltip_text(fmt::format( - tooltip_format, fmt::arg("load", std::round(load)), fmt::arg("bufsize", bufsize_), + tooltip_format, fmt::arg("load", std::round(load_)), fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_), fmt::arg("latency", fmt::format("{:.2f}", latency)), fmt::arg("xruns", xruns_))); } @@ -99,9 +102,7 @@ int JACK::xrun() { } void JACK::shutdown() { - client_ = NULL; - state_ = "disconnected"; - xruns_ = 0; + running_ = false; } } // namespace waybar::modules From bfed2114e4fb1733484890ebbcc2e8f5225481d0 Mon Sep 17 00:00:00 2001 From: kennypm Date: Thu, 11 Aug 2022 15:49:24 -0400 Subject: [PATCH 25/30] jack_client_close working properly now --- src/modules/jack.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index 14117785..b423b00a 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -1,5 +1,4 @@ #include "modules/jack.hpp" -#include namespace waybar::modules { @@ -26,7 +25,7 @@ std::string JACK::JACKState() { samplerate_ = 0; if (client_) { -// jack_client_close(client_); + jack_client_close(client_); client_ = NULL; } @@ -52,7 +51,7 @@ std::string JACK::JACKState() { auto JACK::update() -> void { std::string format; - auto state = JACKState(); + std::string state = JACKState(); float latency = 1000 * (float)bufsize_ / (float)samplerate_; if (label_.get_style_context()->has_class("xrun")) { From a7979a3e56d516d9c5173fe7834eab8ef939cc35 Mon Sep 17 00:00:00 2001 From: kennypm Date: Thu, 11 Aug 2022 17:26:27 -0400 Subject: [PATCH 26/30] add locks and refactor for clarity --- src/modules/jack.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index b423b00a..72c50581 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -14,6 +14,7 @@ JACK::JACK(const std::string &id, const Json::Value &config) } std::string JACK::JACKState() { + std::lock_guard lock(mutex_); if (running_) { load_ = jack_cpu_load(client_); return state_; @@ -30,23 +31,22 @@ std::string JACK::JACKState() { } client_ = jack_client_open("waybar", JackNoStartServer, NULL); - if (client_) { + if (!client_) return "disconnected"; + + if (config_["realtime"].isBool() && !config_["realtime"].asBool()) { pthread_t jack_thread = jack_client_thread_id(client_); - if (config_["realtime"].isBool() && !config_["realtime"].asBool()) - jack_drop_real_time_scheduling(jack_thread); - - bufsize_ = jack_get_buffer_size(client_); - samplerate_ = jack_get_sample_rate(client_); - jack_set_buffer_size_callback(client_, bufSizeCallback, this); - jack_set_xrun_callback(client_, xrunCallback, this); - jack_on_shutdown(client_, shutdownCallback, this); - - if (!jack_activate(client_)) { - running_ = true; - return "connected"; - } + jack_drop_real_time_scheduling(jack_thread); } - return "disconnected"; + + bufsize_ = jack_get_buffer_size(client_); + samplerate_ = jack_get_sample_rate(client_); + jack_set_buffer_size_callback(client_, bufSizeCallback, this); + jack_set_xrun_callback(client_, xrunCallback, this); + jack_on_shutdown(client_, shutdownCallback, this); + if (jack_activate(client_)) return "disconnected"; + + running_ = true; + return "connected"; } auto JACK::update() -> void { @@ -101,6 +101,7 @@ int JACK::xrun() { } void JACK::shutdown() { + std::lock_guard lock(mutex_); running_ = false; } From 89a57f672246b328d73aa4c0f596c4afcf4e3a9b Mon Sep 17 00:00:00 2001 From: kennypm Date: Thu, 11 Aug 2022 18:35:33 -0400 Subject: [PATCH 27/30] simplify build option description --- meson_options.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index acbcce73..b8eb9213 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -14,5 +14,4 @@ option('sndio', type: 'feature', value: 'auto', description: 'Enable support for option('logind', type: 'feature', value: 'auto', description: 'Enable support for logind') option('tests', type: 'feature', value: 'auto', description: 'Enable tests') option('experimental', type : 'boolean', value : false, description: 'Enable experimental features') -option('jack', type: 'feature', value: 'auto', description: 'Enable support for JACK DSP load monitoring') - +option('jack', type: 'feature', value: 'auto', description: 'Enable support for JACK') From 56d46e62c178d1931c3879d5f8b2ce59d273e83f Mon Sep 17 00:00:00 2001 From: kennypm Date: Fri, 12 Aug 2022 11:30:12 -0400 Subject: [PATCH 28/30] add samplerate callback since pipewire supports dynamic samplerate changes --- include/modules/jack.hpp | 6 ++++-- src/modules/jack.cpp | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/modules/jack.hpp b/include/modules/jack.hpp index e3a09cd6..a3555be6 100644 --- a/include/modules/jack.hpp +++ b/include/modules/jack.hpp @@ -15,7 +15,8 @@ class JACK : public ALabel { ~JACK() = default; auto update() -> void; - int bufSize(unsigned int size); + int bufSize(jack_nframes_t size); + int sampleRate(jack_nframes_t rate); int xrun(); void shutdown(); @@ -35,6 +36,7 @@ class JACK : public ALabel { } // namespace waybar::modules -int bufSizeCallback(unsigned int size, void *obj); +int bufSizeCallback(jack_nframes_t size, void *obj); +int sampleRateCallback(jack_nframes_t rate, void *obj); int xrunCallback(void *obj); void shutdownCallback(void *obj); diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index 72c50581..7e5ae630 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -40,6 +40,7 @@ std::string JACK::JACKState() { bufsize_ = jack_get_buffer_size(client_); samplerate_ = jack_get_sample_rate(client_); + jack_set_sample_rate_callback(client_, sampleRateCallback, this); jack_set_buffer_size_callback(client_, bufSizeCallback, this); jack_set_xrun_callback(client_, xrunCallback, this); jack_on_shutdown(client_, shutdownCallback, this); @@ -89,9 +90,14 @@ auto JACK::update() -> void { ALabel::update(); } -int JACK::bufSize(unsigned int size) { +int JACK::bufSize(jack_nframes_t size) { bufsize_ = size; - return size; + return 0; +} + +int JACK::sampleRate(jack_nframes_t rate) { + samplerate_ = rate; + return 0; } int JACK::xrun() { @@ -107,10 +113,14 @@ void JACK::shutdown() { } // namespace waybar::modules -int bufSizeCallback(unsigned int size, void *obj) { +int bufSizeCallback(jack_nframes_t size, void *obj) { return static_cast(obj)->bufSize(size); } +int sampleRateCallback(jack_nframes_t rate, void *obj) { + return static_cast(obj)->sampleRate(rate); +} + int xrunCallback(void *obj) { return static_cast(obj)->xrun(); } void shutdownCallback(void *obj) { return static_cast(obj)->shutdown(); } From 59e57ab9a018122fa3db87e0de3b722d64cb2e02 Mon Sep 17 00:00:00 2001 From: kennypm Date: Thu, 18 Aug 2022 17:05:04 -0400 Subject: [PATCH 29/30] man page and adjust default format --- man/waybar-jack.5.scd | 112 ++++++++++++++++++++++++++++++++++++++++++ src/modules/jack.cpp | 2 +- 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 man/waybar-jack.5.scd diff --git a/man/waybar-jack.5.scd b/man/waybar-jack.5.scd new file mode 100644 index 00000000..a06678c1 --- /dev/null +++ b/man/waybar-jack.5.scd @@ -0,0 +1,112 @@ +waybar-jack(5) + +# NAME + +waybar - JACK module + +# DESCRIPTION + +The *jack* module displays the current state of the JACK server. + +# CONFIGURATION + +Addressed by *jack* + +*format*: ++ + typeof: string ++ + default: *{load}%* ++ + The format, how information should be displayed. This format is used when other formats aren't specified. + +*format-connected*: ++ + typeof: string ++ + This format is used when the module is connected to the JACK server. + +*format-disconnected*: ++ + typeof: string ++ + This format is used when the module is not connected to the JACK server. + +*format-xrun*: ++ + typeof: string ++ + This format is used for one polling interval, when the JACK server reports an xrun. + +*realtime*: ++ + typeof: bool ++ + default: *true* ++ + Option to drop real-time privileges for the JACK client opened by Waybar. + +*tooltip*: ++ + typeof: bool ++ + default: *true* ++ + Option to disable tooltip on hover. + +*tooltip-format*: ++ + typeof: string ++ + default: *{bufsize}/{samplerate} {latency}ms* ++ + The format of information displayed in the tooltip. + +*interval*: ++ + typeof: integer ++ + default: 1 ++ + Positive value to rotate the text label. + +*rotate*: ++ + typeof: integer ++ + Positive value to rotate the text label. + +*max-length*: ++ + typeof: integer ++ + The maximum length in character the module should display. + +*min-length*: ++ + typeof: integer ++ + The minimum length in characters the module should take up. + +*align*: ++ + typeof: float ++ + The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text. + +*on-click*: ++ + typeof: string ++ + Command to execute when clicked on the module. + +*on-click-middle*: ++ + typeof: string ++ + Command to execute when middle-clicked on the module using mousewheel. + +*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. + +# FORMAT REPLACEMENTS + +*{load}*: The current CPU load estimated by JACK. + +*{bufsize}*: The size of the JACK buffer. + +*{samplerate}*: The samplerate at which the JACK server is running. + +*{latency}*: The duration, in ms, of the current buffer size. + +*{xruns}*: The number of xruns reported by the JACK server since starting Waybar. + +# EXAMPLES + +``` +"jack": { + "format": "DSP {}%", + "format-xrun": "{xruns} xruns", + "format-disconnected": "DSP off", + "realtime": true +} +``` + +# STYLE + +- *#jack* +- *#jack.connected* +- *#jack.disconnected* +- *#jack.xrun* diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index 7e5ae630..3a92110c 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -70,7 +70,7 @@ auto JACK::update() -> void { } else if (config_["format"].isString()) { format = config_["format"].asString(); } else - format = "DSP {load}%"; + format = "{load}%"; label_.set_markup(fmt::format(format, fmt::arg("load", std::round(load_)), fmt::arg("bufsize", bufsize_), fmt::arg("samplerate", samplerate_), From f4bfe777d9356e08db9dc3f410bb8df4802b8e22 Mon Sep 17 00:00:00 2001 From: kennypm Date: Thu, 18 Aug 2022 20:56:26 -0400 Subject: [PATCH 30/30] oops --- man/waybar-jack.5.scd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/waybar-jack.5.scd b/man/waybar-jack.5.scd index a06678c1..b8a4cebe 100644 --- a/man/waybar-jack.5.scd +++ b/man/waybar-jack.5.scd @@ -47,7 +47,7 @@ Addressed by *jack* *interval*: ++ typeof: integer ++ default: 1 ++ - Positive value to rotate the text label. + The interval in which the information gets polled. *rotate*: ++ typeof: integer ++