Compare commits
148 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f94435014 | ||
|
|
1639dec7d8 | ||
|
|
b4854f96a3 | ||
|
|
8f5fc990a5 | ||
|
|
a02180a815 | ||
|
|
af7eebba5e | ||
|
|
479ea9f3e8 | ||
|
|
f990486a40 | ||
|
|
d0f5fab52b | ||
|
|
a05e6c6f74 | ||
|
|
99867005a0 | ||
|
|
959f41ca9c | ||
|
|
06484547d1 | ||
|
|
46a6f60138 | ||
|
|
83a6998fcb | ||
|
|
386036a67a | ||
|
|
e3186abdce | ||
|
|
c8c3287be3 | ||
|
|
601b5f0241 | ||
|
|
97eb60677e | ||
|
|
3d0b942956 | ||
|
|
c3d29b1185 | ||
|
|
c6844781ea | ||
|
|
c1218fa889 | ||
|
|
11c4e55376 | ||
|
|
6b05d73a64 | ||
|
|
374ccbb878 | ||
|
|
d012de3cde | ||
|
|
7ecad3229d | ||
|
|
278e8822ff | ||
|
|
a23cef457f | ||
|
|
a9ef11a2b3 | ||
|
|
07cb2c02d2 | ||
|
|
e03119fe94 | ||
|
|
5ee3bd5325 | ||
|
|
3773021546 | ||
|
|
52f4db1154 | ||
|
|
e362550e27 | ||
|
|
cb0ee665a3 | ||
|
|
e189649c33 | ||
|
|
13519ca5bf | ||
|
|
097c00c7bd | ||
|
|
73808dfacc | ||
|
|
ce1da5a178 | ||
|
|
4e25871655 | ||
|
|
ca62481dc9 | ||
|
|
b701d7f70b | ||
|
|
68cbb507d9 | ||
|
|
161367d961 | ||
|
|
a62455e1b9 | ||
|
|
588c344c8a | ||
|
|
bf0ccfd90c | ||
|
|
8b0a82ad34 | ||
|
|
37ac2daac8 | ||
|
|
97682a1332 | ||
|
|
4beb7ddac7 | ||
|
|
84ec25bbeb | ||
|
|
b475399a22 | ||
|
|
15a503ae21 | ||
|
|
46d3e80bce | ||
|
|
9221508e51 | ||
|
|
9d37dedb57 | ||
|
|
6021261383 | ||
|
|
966da11f3b | ||
|
|
7add8b2726 | ||
|
|
bef35e48fe | ||
|
|
559079e9a6 | ||
|
|
0c41cf47c2 | ||
|
|
a16d53b30d | ||
|
|
151cf54532 | ||
|
|
b3f1d02b16 | ||
|
|
bea012d06d | ||
|
|
197ee78080 | ||
|
|
d8e2392410 | ||
|
|
801319f024 | ||
|
|
6f308d8ea1 | ||
|
|
18a9835b7c | ||
|
|
632af16b19 | ||
|
|
9acf032c0c | ||
|
|
9dd75d4f6b | ||
|
|
4f16ec16f9 | ||
|
|
b4c80cfb56 | ||
|
|
e00db5886e | ||
|
|
a613cd54b0 | ||
|
|
5c01ad75f1 | ||
|
|
3cc5943c08 | ||
|
|
c7a77f2c08 | ||
|
|
a15565ac48 | ||
|
|
23220eb541 | ||
|
|
32d4cf4c7b | ||
|
|
f29e843d6e | ||
|
|
97f1e54b70 | ||
|
|
6824a76595 | ||
|
|
0f1d31147a | ||
|
|
d3b094503e | ||
|
|
fbec045492 | ||
|
|
c31d15045a | ||
|
|
8bb19a9505 | ||
|
|
08b36955de | ||
|
|
6978193c6a | ||
|
|
7092244402 | ||
|
|
8013556d2b | ||
|
|
5f1db15c2e | ||
|
|
db2dfb6f3c | ||
|
|
862ba2f568 | ||
|
|
76d3b47ffd | ||
|
|
cbab9c9713 | ||
|
|
cbd8930e22 | ||
|
|
b08d0c21f3 | ||
|
|
9e3a9f7d35 | ||
|
|
45cfaf4a0b | ||
|
|
4a5358e8c5 | ||
|
|
0c3e82219f | ||
|
|
fd601801b4 | ||
|
|
e87ece4462 | ||
|
|
3435e33845 | ||
|
|
09a07cd429 | ||
|
|
e8a2e6c66f | ||
|
|
d45ce841e3 | ||
|
|
97fa6aa4dd | ||
|
|
af9c31ccd3 | ||
|
|
19468d4365 | ||
|
|
9720d80524 | ||
|
|
8e488b4d5e | ||
|
|
5a29473080 | ||
|
|
3c3164eb8e | ||
|
|
556c5f5a30 | ||
|
|
45d01ce6e5 | ||
|
|
691b7d427b | ||
|
|
5a87a9d60a | ||
|
|
2b81782fa9 | ||
|
|
2b552f7fb6 | ||
|
|
6dc5a73a02 | ||
|
|
e8755b1a7f | ||
|
|
25ac6b7a80 | ||
|
|
8fe76317fb | ||
|
|
691e66a7fd | ||
|
|
5ac28f3947 | ||
|
|
089b9a20fc | ||
|
|
d09a4072e5 | ||
|
|
a0c21318f9 | ||
|
|
be48f6bff2 | ||
|
|
5079884b78 | ||
|
|
83f16a2092 | ||
|
|
64b64d0316 | ||
|
|
be819be8bd | ||
|
|
08a39dd9eb | ||
|
|
649a98a679 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,6 +7,7 @@ vgcore.*
|
||||
*.swp
|
||||
packagecache
|
||||
/subprojects/**/
|
||||
/subprojects/.wraplock
|
||||
/build*
|
||||
/dist
|
||||
/meson.egg-info
|
||||
|
||||
6
Makefile
6
Makefile
@@ -20,8 +20,12 @@ debug-run: build-debug
|
||||
./build/waybar --log-level debug
|
||||
|
||||
test:
|
||||
meson test -C build --no-rebuild --verbose --suite waybar
|
||||
meson test -C build --verbose --suite waybar
|
||||
.PHONY: test
|
||||
|
||||
test-detailed:
|
||||
meson test -C build --verbose --print-errorlogs --test-args='--reporter console -s'
|
||||
.PHONY: test-detailed
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
||||
@@ -119,7 +119,7 @@ sudo apt install \
|
||||
On Arch, you can use this command:
|
||||
|
||||
```
|
||||
pacman -S \
|
||||
pacman -S --asdeps \
|
||||
gtkmm3 \
|
||||
jsoncpp \
|
||||
libsigc++ \
|
||||
|
||||
5
asan.supp
Normal file
5
asan.supp
Normal file
@@ -0,0 +1,5 @@
|
||||
# Suppress common address sanitizer issues in dependencies, these are often non-fixable or not an issue.
|
||||
# Use it like this (when in repo root): ASAN_OPTIONS="suppressions=./asan.supp" ./build/waybar
|
||||
leak:libpangoft2-1.0.so.0
|
||||
leak:libgtk-3.so.0
|
||||
leak:libfontconfig.so.1
|
||||
12
flake.lock
generated
12
flake.lock
generated
@@ -3,11 +3,11 @@
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1747046372,
|
||||
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
|
||||
"lastModified": 1767039857,
|
||||
"narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
|
||||
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -18,11 +18,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1753694789,
|
||||
"narHash": "sha256-cKgvtz6fKuK1Xr5LQW/zOUiAC0oSQoA9nOISB0pJZqM=",
|
||||
"lastModified": 1766902085,
|
||||
"narHash": "sha256-coBu0ONtFzlwwVBzmjacUQwj3G+lybcZ1oeNSQkgC0M=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "dc9637876d0dcc8c9e5e22986b857632effeb727",
|
||||
"rev": "c0b0e0fddf73fd517c3471e546c0df87a42d53f4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
42
flake.nix
42
flake.nix
@@ -65,7 +65,7 @@
|
||||
nativeBuildInputs =
|
||||
pkgs.waybar.nativeBuildInputs
|
||||
++ (with pkgs; [
|
||||
nixfmt-rfc-style
|
||||
nixfmt
|
||||
clang-tools
|
||||
gdb
|
||||
]);
|
||||
@@ -75,28 +75,26 @@
|
||||
formatter = genSystems (
|
||||
pkgs:
|
||||
pkgs.treefmt.withConfig {
|
||||
settings = [
|
||||
{
|
||||
formatter = {
|
||||
clang-format = {
|
||||
options = [ "-i" ];
|
||||
command = lib.getExe' pkgs.clang-tools "clang-format";
|
||||
excludes = [ ];
|
||||
includes = [
|
||||
"*.c"
|
||||
"*.cpp"
|
||||
"*.h"
|
||||
"*.hpp"
|
||||
];
|
||||
};
|
||||
nixfmt = {
|
||||
command = lib.getExe pkgs.nixfmt-rfc-style;
|
||||
includes = [ "*.nix" ];
|
||||
};
|
||||
settings = {
|
||||
formatter = {
|
||||
clang-format = {
|
||||
options = [ "-i" ];
|
||||
command = lib.getExe' pkgs.clang-tools "clang-format";
|
||||
excludes = [ ];
|
||||
includes = [
|
||||
"*.c"
|
||||
"*.cpp"
|
||||
"*.h"
|
||||
"*.hpp"
|
||||
];
|
||||
};
|
||||
tree-root-file = ".git/index";
|
||||
}
|
||||
];
|
||||
nixfmt = {
|
||||
command = lib.getExe pkgs.nixfmt;
|
||||
includes = [ "*.nix" ];
|
||||
};
|
||||
};
|
||||
tree-root-file = ".git/index";
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class ALabel : public AModule {
|
||||
protected:
|
||||
Gtk::Label label_;
|
||||
std::string format_;
|
||||
const std::chrono::seconds interval_;
|
||||
const std::chrono::milliseconds interval_;
|
||||
bool alt_ = false;
|
||||
std::string default_format_;
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ class Client {
|
||||
std::list<struct waybar_output> outputs_;
|
||||
std::unique_ptr<CssReloadHelper> m_cssReloadHelper;
|
||||
std::string m_cssFile;
|
||||
sigc::connection monitor_added_connection_;
|
||||
sigc::connection monitor_removed_connection_;
|
||||
};
|
||||
|
||||
} // namespace waybar
|
||||
|
||||
@@ -35,7 +35,8 @@ class Config {
|
||||
void setupConfig(Json::Value &dst, const std::string &config_file, int depth);
|
||||
void resolveConfigIncludes(Json::Value &config, int depth);
|
||||
void mergeConfig(Json::Value &a_config_, Json::Value &b_config_);
|
||||
static std::optional<std::string> findIncludePath(const std::string &name);
|
||||
static std::vector<std::string> findIncludePath(
|
||||
const std::string &name, const std::vector<std::string> &dirs = CONFIG_DIRS);
|
||||
|
||||
std::string config_file_;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#if defined(__linux__)
|
||||
#include <sys/inotify.h>
|
||||
#endif
|
||||
#include <sys/poll.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
@@ -15,6 +16,7 @@
|
||||
#include "ALabel.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
#include "util/udev_deleter.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
@@ -37,15 +39,17 @@ class Battery : public ALabel {
|
||||
void setBarClass(std::string&);
|
||||
void processEvents(std::string& state, std::string& status, uint8_t capacity);
|
||||
|
||||
int global_watch;
|
||||
std::map<fs::path, int> batteries_;
|
||||
std::unique_ptr<udev, util::UdevDeleter> udev_;
|
||||
std::array<pollfd, 1> poll_fds_;
|
||||
std::unique_ptr<udev_monitor, util::UdevMonitorDeleter> mon_;
|
||||
fs::path adapter_;
|
||||
int battery_watch_fd_;
|
||||
int global_watch_fd_;
|
||||
std::mutex battery_list_mutex_;
|
||||
std::string old_status_;
|
||||
std::string last_event_;
|
||||
bool warnFirstTime_{true};
|
||||
bool weightedAverage_{true};
|
||||
const Bar& bar_;
|
||||
|
||||
util::SleeperThread thread_;
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace cava {
|
||||
extern "C" {
|
||||
// Need sdl_glsl output feature to be enabled on libcava
|
||||
#ifndef SDL_GLSL
|
||||
#define SDL_GLSL
|
||||
#endif
|
||||
|
||||
#include <cava/common.h>
|
||||
|
||||
#ifdef SDL_GLSL
|
||||
#undef SDL_GLSL
|
||||
#endif
|
||||
}
|
||||
} // namespace cava
|
||||
|
||||
namespace waybar::modules {
|
||||
using namespace std::literals::chrono_literals;
|
||||
|
||||
class Cava final : public ALabel {
|
||||
public:
|
||||
Cava(const std::string&, const Json::Value&);
|
||||
virtual ~Cava();
|
||||
auto update() -> void override;
|
||||
auto doAction(const std::string& name) -> void override;
|
||||
|
||||
private:
|
||||
util::SleeperThread thread_;
|
||||
util::SleeperThread thread_fetch_input_;
|
||||
|
||||
struct cava::error_s error_{}; // cava errors
|
||||
struct cava::config_params prm_{}; // cava parameters
|
||||
struct cava::audio_raw audio_raw_{}; // cava handled raw audio data(is based on audio_data)
|
||||
struct cava::audio_data audio_data_{}; // cava audio data
|
||||
struct cava::cava_plan* plan_; //{new cava_plan{}};
|
||||
// Cava API to read audio source
|
||||
cava::ptr input_source_;
|
||||
// Delay to handle audio source
|
||||
std::chrono::milliseconds frame_time_milsec_{1s};
|
||||
// Text to display
|
||||
std::string text_{""};
|
||||
int rePaint_{1};
|
||||
std::chrono::seconds fetch_input_delay_{4};
|
||||
std::chrono::seconds suspend_silence_delay_{0};
|
||||
bool silence_{false};
|
||||
bool hide_on_silence_{false};
|
||||
std::string format_silent_{""};
|
||||
int sleep_counter_{0};
|
||||
// Cava method
|
||||
void pause_resume();
|
||||
// ModuleActionMap
|
||||
static inline std::map<const std::string, void (waybar::modules::Cava::* const)()> actionMap_{
|
||||
{"mode", &waybar::modules::Cava::pause_resume}};
|
||||
};
|
||||
} // namespace waybar::modules
|
||||
43
include/modules/cava/cavaGLSL.hpp
Normal file
43
include/modules/cava/cavaGLSL.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <epoxy/gl.h>
|
||||
|
||||
#include "AModule.hpp"
|
||||
#include "cava_backend.hpp"
|
||||
|
||||
namespace waybar::modules::cava {
|
||||
|
||||
class CavaGLSL final : public AModule, public Gtk::GLArea {
|
||||
public:
|
||||
CavaGLSL(const std::string&, const Json::Value&);
|
||||
~CavaGLSL() = default;
|
||||
|
||||
private:
|
||||
std::shared_ptr<CavaBackend> backend_;
|
||||
struct ::cava::config_params prm_;
|
||||
int frame_counter{0};
|
||||
bool silence_{false};
|
||||
bool hide_on_silence_{false};
|
||||
// Cava method
|
||||
auto onUpdate(const ::cava::audio_raw& input) -> void;
|
||||
auto onSilence() -> void;
|
||||
// Member variable to store the shared pointer
|
||||
std::shared_ptr<::cava::audio_raw> m_data_;
|
||||
GLuint shaderProgram_;
|
||||
// OpenGL variables
|
||||
GLuint fbo_;
|
||||
GLuint texture_;
|
||||
GLint uniform_bars_;
|
||||
GLint uniform_previous_bars_;
|
||||
GLint uniform_bars_count_;
|
||||
GLint uniform_time_;
|
||||
// Methods
|
||||
void onRealize();
|
||||
bool onRender(const Glib::RefPtr<Gdk::GLContext>& context);
|
||||
|
||||
void initShaders();
|
||||
void initSurface();
|
||||
void initGLSL();
|
||||
GLuint loadShader(const std::string& fileName, GLenum type);
|
||||
};
|
||||
} // namespace waybar::modules::cava
|
||||
30
include/modules/cava/cavaRaw.hpp
Normal file
30
include/modules/cava/cavaRaw.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "cava_backend.hpp"
|
||||
|
||||
namespace waybar::modules::cava {
|
||||
|
||||
class Cava final : public ALabel, public sigc::trackable {
|
||||
public:
|
||||
Cava(const std::string&, const Json::Value&);
|
||||
~Cava() = default;
|
||||
auto doAction(const std::string& name) -> void override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<CavaBackend> backend_;
|
||||
// Text to display
|
||||
Glib::ustring label_text_{""};
|
||||
bool silence_{false};
|
||||
bool hide_on_silence_{false};
|
||||
std::string format_silent_{""};
|
||||
int ascii_range_{0};
|
||||
// Cava method
|
||||
void pause_resume();
|
||||
auto onUpdate(const std::string& input) -> void;
|
||||
auto onSilence() -> void;
|
||||
// ModuleActionMap
|
||||
static inline std::map<const std::string, void (waybar::modules::cava::Cava::* const)()>
|
||||
actionMap_{{"mode", &waybar::modules::cava::Cava::pause_resume}};
|
||||
};
|
||||
} // namespace waybar::modules::cava
|
||||
84
include/modules/cava/cava_backend.hpp
Normal file
84
include/modules/cava/cava_backend.hpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include <json/json.h>
|
||||
#include <sigc++/sigc++.h>
|
||||
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace cava {
|
||||
extern "C" {
|
||||
// Need sdl_glsl output feature to be enabled on libcava
|
||||
#ifndef SDL_GLSL
|
||||
#define SDL_GLSL
|
||||
#endif
|
||||
|
||||
#include <cava/common.h>
|
||||
|
||||
#ifdef SDL_GLSL
|
||||
#undef SDL_GLSL
|
||||
#endif
|
||||
}
|
||||
} // namespace cava
|
||||
|
||||
namespace waybar::modules::cava {
|
||||
using namespace std::literals::chrono_literals;
|
||||
|
||||
class CavaBackend final {
|
||||
public:
|
||||
static std::shared_ptr<CavaBackend> inst(const Json::Value& config);
|
||||
|
||||
virtual ~CavaBackend();
|
||||
// Methods
|
||||
int getAsciiRange();
|
||||
void doPauseResume();
|
||||
void Update();
|
||||
const struct ::cava::config_params* getPrm();
|
||||
std::chrono::milliseconds getFrameTimeMilsec();
|
||||
|
||||
// Signal accessor
|
||||
using type_signal_update = sigc::signal<void(const std::string&)>;
|
||||
type_signal_update signal_update();
|
||||
using type_signal_audio_raw_update = sigc::signal<void(const ::cava::audio_raw&)>;
|
||||
type_signal_audio_raw_update signal_audio_raw_update();
|
||||
using type_signal_silence = sigc::signal<void()>;
|
||||
type_signal_silence signal_silence();
|
||||
|
||||
private:
|
||||
CavaBackend(const Json::Value& config);
|
||||
util::SleeperThread read_thread_;
|
||||
util::SleeperThread out_thread_;
|
||||
|
||||
// Cava API to read audio source
|
||||
::cava::ptr input_source_{NULL};
|
||||
|
||||
struct ::cava::error_s error_{}; // cava errors
|
||||
struct ::cava::config_params prm_{}; // cava parameters
|
||||
struct ::cava::audio_raw audio_raw_{}; // cava handled raw audio data(is based on audio_data)
|
||||
struct ::cava::audio_data audio_data_{}; // cava audio data
|
||||
struct ::cava::cava_plan* plan_{NULL}; //{new cava_plan{}};
|
||||
|
||||
std::chrono::seconds fetch_input_delay_{4};
|
||||
// Delay to handle audio source
|
||||
std::chrono::milliseconds frame_time_milsec_{1s};
|
||||
|
||||
const Json::Value& config_;
|
||||
int re_paint_{0};
|
||||
bool silence_{false};
|
||||
bool silence_prev_{false};
|
||||
std::chrono::seconds suspend_silence_delay_{0};
|
||||
int sleep_counter_{0};
|
||||
std::string output_{};
|
||||
// Methods
|
||||
void invoke();
|
||||
void execute();
|
||||
bool isSilence();
|
||||
void doUpdate(bool force = false);
|
||||
void loadConfig();
|
||||
void freeBackend();
|
||||
|
||||
// Signal
|
||||
type_signal_update m_signal_update_;
|
||||
type_signal_audio_raw_update m_signal_audio_raw_;
|
||||
type_signal_silence m_signal_silence_;
|
||||
};
|
||||
} // namespace waybar::modules::cava
|
||||
27
include/modules/cava/cava_frontend.hpp
Normal file
27
include/modules/cava/cava_frontend.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef HAVE_LIBCAVA
|
||||
#include "cavaRaw.hpp"
|
||||
#include "cava_backend.hpp"
|
||||
#ifdef HAVE_LIBCAVAGLSL
|
||||
#include "cavaGLSL.hpp"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace waybar::modules::cava {
|
||||
AModule* getModule(const std::string& id, const Json::Value& config) {
|
||||
#ifdef HAVE_LIBCAVA
|
||||
const std::shared_ptr<CavaBackend> backend_{waybar::modules::cava::CavaBackend::inst(config)};
|
||||
switch (backend_->getPrm()->output) {
|
||||
#ifdef HAVE_LIBCAVAGLSL
|
||||
case ::cava::output_method::OUTPUT_SDL_GLSL:
|
||||
return new waybar::modules::cava::CavaGLSL(id, config);
|
||||
#endif
|
||||
default:
|
||||
return new waybar::modules::cava::Cava(id, config);
|
||||
}
|
||||
#else
|
||||
throw std::runtime_error("Unknown module");
|
||||
#endif
|
||||
};
|
||||
} // namespace waybar::modules::cava
|
||||
@@ -48,8 +48,9 @@ class Clock final : public ALabel {
|
||||
std::string cldYearCached_; // calendar Year mode. Cached calendar
|
||||
date::year_month cldMonShift_; // calendar Month mode. Cached ym
|
||||
std::string cldMonCached_; // calendar Month mode. Cached calendar
|
||||
date::day cldBaseDay_{0}; // calendar Cached day. Is used when today is changing(midnight)
|
||||
std::string cldText_{""}; // calendar text to print
|
||||
date::day cldBaseDay_{0}; // calendar Cached day. Is used when today is changing(midnight)
|
||||
std::string cldText_{""}; // calendar text to print
|
||||
bool iso8601Calendar_{false}; // whether the calendar is in ISO8601
|
||||
CldMode cldMode_{CldMode::MONTH};
|
||||
auto get_calendar(const date::year_month_day& today, const date::year_month_day& ymd,
|
||||
const date::time_zone* tz) -> const std::string;
|
||||
@@ -62,6 +63,7 @@ class Clock final : public ALabel {
|
||||
std::vector<const date::time_zone*> tzList_; // time zones list
|
||||
int tzCurrIdx_; // current time zone index for tzList_
|
||||
std::string tzText_{""}; // time zones text to print
|
||||
std::string tzTooltipFormat_{""}; // optional timezone tooltip format
|
||||
util::SleeperThread thread_;
|
||||
|
||||
// ordinal date in tooltip
|
||||
|
||||
@@ -136,8 +136,6 @@ class Workspace {
|
||||
Gtk::Button button_;
|
||||
Gtk::Box content_;
|
||||
Gtk::Label label_;
|
||||
|
||||
bool needs_updating_ = false;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::ext
|
||||
|
||||
@@ -17,9 +17,13 @@ class EventHandler {
|
||||
virtual ~EventHandler() = default;
|
||||
};
|
||||
|
||||
/// If you want to use the Hyprland IPC, simply use IPC::inst() to get the singleton instance.
|
||||
/// Do not create multiple instances.
|
||||
class IPC {
|
||||
protected:
|
||||
IPC(); // use IPC::inst() instead.
|
||||
|
||||
public:
|
||||
IPC();
|
||||
~IPC();
|
||||
static IPC& inst();
|
||||
|
||||
@@ -42,9 +46,7 @@ class IPC {
|
||||
util::JsonParser parser_;
|
||||
std::list<std::pair<std::string, EventHandler*>> callbacks_;
|
||||
int socketfd_; // the hyprland socket file descriptor
|
||||
bool running_ = true;
|
||||
pid_t socketOwnerPid_;
|
||||
bool running_ = true; // the ipcThread will stop running when this is false
|
||||
};
|
||||
|
||||
inline bool modulesReady = false;
|
||||
inline std::unique_ptr<IPC> gIPC;
|
||||
}; // namespace waybar::modules::hyprland
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "AAppIconLabel.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/hyprland/backend.hpp"
|
||||
#include "util/json.hpp"
|
||||
|
||||
namespace waybar::modules::hyprland {
|
||||
|
||||
@@ -26,8 +25,8 @@ class WindowCount : public waybar::AAppIconLabel, public EventHandler {
|
||||
static auto parse(const Json::Value& value) -> Workspace;
|
||||
};
|
||||
|
||||
static auto getActiveWorkspace(const std::string&) -> Workspace;
|
||||
static auto getActiveWorkspace() -> Workspace;
|
||||
auto getActiveWorkspace(const std::string&) -> Workspace;
|
||||
auto getActiveWorkspace() -> Workspace;
|
||||
void onEvent(const std::string& ev) override;
|
||||
void queryActiveWorkspace();
|
||||
void setClass(const std::string&, bool enable);
|
||||
@@ -36,6 +35,7 @@ class WindowCount : public waybar::AAppIconLabel, public EventHandler {
|
||||
std::mutex mutex_;
|
||||
const Bar& bar_;
|
||||
Workspace workspace_;
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
||||
@@ -42,7 +42,6 @@ class Workspace {
|
||||
bool isPersistentConfig() const { return m_isPersistentConfig; };
|
||||
bool isPersistentRule() const { return m_isPersistentRule; };
|
||||
bool isVisible() const { return m_isVisible; };
|
||||
bool isEmpty() const { return m_windows == 0; };
|
||||
bool isUrgent() const { return m_isUrgent; };
|
||||
|
||||
bool handleClicked(GdkEventButton* bt) const;
|
||||
@@ -88,6 +87,7 @@ class Workspace {
|
||||
Gtk::Label m_labelBefore;
|
||||
Gtk::Label m_labelAfter;
|
||||
|
||||
bool isEmpty() const;
|
||||
void updateTaskbar(const std::string& workspace_icon);
|
||||
bool handleClick(const GdkEventButton* event_button, WindowAddress const& addr) const;
|
||||
bool shouldSkipWindow(const WindowRepr& window_repr) const;
|
||||
|
||||
@@ -51,9 +51,13 @@ class Workspaces : public AModule, public EventHandler {
|
||||
auto taskbarFormatAfter() const -> std::string { return m_taskbarFormatAfter; }
|
||||
auto taskbarIconSize() const -> int { return m_taskbarIconSize; }
|
||||
auto taskbarOrientation() const -> Gtk::Orientation { return m_taskbarOrientation; }
|
||||
auto taskbarReverseDirection() const -> bool { return m_taskbarReverseDirection; }
|
||||
auto onClickWindow() const -> std::string { return m_onClickWindow; }
|
||||
auto getIgnoredWindows() const -> std::vector<std::regex> { return m_ignoreWindows; }
|
||||
|
||||
enum class ActiveWindowPosition { NONE, FIRST, LAST };
|
||||
auto activeWindowPosition() const -> ActiveWindowPosition { return m_activeWindowPosition; }
|
||||
|
||||
std::string getRewrite(std::string window_class, std::string window_title);
|
||||
std::string& getWindowSeparator() { return m_formatWindowSeparator; }
|
||||
bool isWorkspaceIgnored(std::string const& workspace_name);
|
||||
@@ -183,6 +187,14 @@ class Workspaces : public AModule, public EventHandler {
|
||||
std::string m_taskbarFormatAfter;
|
||||
int m_taskbarIconSize = 16;
|
||||
Gtk::Orientation m_taskbarOrientation = Gtk::ORIENTATION_HORIZONTAL;
|
||||
bool m_taskbarReverseDirection = false;
|
||||
util::EnumParser<ActiveWindowPosition> m_activeWindowEnumParser;
|
||||
ActiveWindowPosition m_activeWindowPosition = ActiveWindowPosition::NONE;
|
||||
std::map<std::string, ActiveWindowPosition> m_activeWindowPositionMap = {
|
||||
{"NONE", ActiveWindowPosition::NONE},
|
||||
{"FIRST", ActiveWindowPosition::FIRST},
|
||||
{"LAST", ActiveWindowPosition::LAST},
|
||||
};
|
||||
std::string m_onClickWindow;
|
||||
std::string m_currentActiveWindowAddress;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class Image : public AModule {
|
||||
std::string path_;
|
||||
std::string tooltip_;
|
||||
int size_;
|
||||
int interval_;
|
||||
std::chrono::milliseconds interval_;
|
||||
util::command::res output_;
|
||||
|
||||
util::SleeperThread thread_;
|
||||
|
||||
@@ -33,6 +33,7 @@ class Language : public ALabel, public EventHandler {
|
||||
|
||||
std::vector<Layout> layouts_;
|
||||
unsigned current_idx_;
|
||||
std::string last_short_name_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::niri
|
||||
|
||||
@@ -21,6 +21,7 @@ class Tags : public waybar::AModule {
|
||||
void handle_view_tags(struct wl_array *tags);
|
||||
void handle_urgent_tags(uint32_t tags);
|
||||
|
||||
void handle_show();
|
||||
void handle_primary_clicked(uint32_t tag);
|
||||
bool handle_button_press(GdkEventButton *event_button, uint32_t tag);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ struct ToolTip {
|
||||
class Item : public sigc::trackable {
|
||||
public:
|
||||
Item(const std::string&, const std::string&, const Json::Value&, const Bar&);
|
||||
~Item() = default;
|
||||
~Item();
|
||||
|
||||
std::string bus_name;
|
||||
std::string object_path;
|
||||
|
||||
@@ -30,15 +30,16 @@ class JsonParser {
|
||||
|
||||
std::istringstream jsonStream(modifiedJsonStr);
|
||||
std::string errs;
|
||||
if (!Json::parseFromStream(m_readerBuilder, jsonStream, &root, &errs)) {
|
||||
// Use local CharReaderBuilder for thread safety - the IPC singleton's
|
||||
// parser can be called concurrently from multiple module threads
|
||||
Json::CharReaderBuilder readerBuilder;
|
||||
if (!Json::parseFromStream(readerBuilder, jsonStream, &root, &errs)) {
|
||||
throw std::runtime_error("Error parsing JSON: " + errs);
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
private:
|
||||
Json::CharReaderBuilder m_readerBuilder;
|
||||
|
||||
static std::string replaceHexadecimalEscape(const std::string& str) {
|
||||
static std::regex re("\\\\x");
|
||||
return std::regex_replace(str, re, "\\u00");
|
||||
|
||||
21
include/util/udev_deleter.hpp
Normal file
21
include/util/udev_deleter.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <libudev.h>
|
||||
|
||||
namespace waybar::util {
|
||||
struct UdevDeleter {
|
||||
void operator()(udev *ptr) const { udev_unref(ptr); }
|
||||
};
|
||||
|
||||
struct UdevDeviceDeleter {
|
||||
void operator()(udev_device *ptr) const { udev_device_unref(ptr); }
|
||||
};
|
||||
|
||||
struct UdevEnumerateDeleter {
|
||||
void operator()(udev_enumerate *ptr) const { udev_enumerate_unref(ptr); }
|
||||
};
|
||||
|
||||
struct UdevMonitorDeleter {
|
||||
void operator()(udev_monitor *ptr) const { udev_monitor_unref(ptr); }
|
||||
};
|
||||
} // namespace waybar::util
|
||||
@@ -91,6 +91,11 @@ The *battery* module displays the current capacity and state (eg. charging) of y
|
||||
typeof: string ++
|
||||
Command to execute when scrolling up on the module.
|
||||
|
||||
*weighted-average*: ++
|
||||
typeof: bool ++
|
||||
default: true ++
|
||||
Option to combine multiple batteries with different capacities.
|
||||
|
||||
*on-scroll-down*: ++
|
||||
typeof: string ++
|
||||
Command to execute when scrolling down on the module.
|
||||
@@ -175,7 +180,7 @@ The *battery* module allows one to define custom formats based on up to two fact
|
||||
Every entry in the *events* object consists of a *<event-name>* (typeof: *string*) and a *<command>* (typeof: *string*). ++
|
||||
*<event-name>* can be in one of the following formats:
|
||||
|
||||
- *on-<status>-<state>*
|
||||
- *on-<status>-<state>*
|
||||
- *on-<status>-<capacity>*
|
||||
|
||||
Where:
|
||||
|
||||
@@ -8,6 +8,8 @@ waybar - cava module
|
||||
|
||||
*cava* module for karlstav/cava project. See it on github: https://github.com/karlstav/cava.
|
||||
|
||||
Module supports two different frontends starting from the 0.15.0 release. The frontend that
|
||||
will be used is managed by the method parameter in the [output] section of the cava configuration file.
|
||||
|
||||
# FILES
|
||||
|
||||
@@ -32,6 +34,10 @@ libcava lives in:
|
||||
:[ string
|
||||
:[
|
||||
:< Path where cava configuration file is placed to
|
||||
|[ *method* \[output\]
|
||||
:[ string
|
||||
:[
|
||||
:< Manages which frontend Waybar cava module should use. Values: raw, sdl_glsl
|
||||
|[ *framerate*
|
||||
:[ integer
|
||||
:[ 30
|
||||
@@ -43,7 +49,7 @@ libcava lives in:
|
||||
|[ *sensitivity*
|
||||
:[ integer
|
||||
:[ 100
|
||||
:[ Manual sensitivity in %. It's recommended to be omitted when *autosens* = 1
|
||||
:[ Manual sensitivity in %. If autosens is enabled, this will only be the initial value. 200 means double height. Accepts only non-negative values
|
||||
|[ *bars*
|
||||
:[ integer
|
||||
:[ 12
|
||||
@@ -68,7 +74,7 @@ libcava lives in:
|
||||
:[ string
|
||||
:[
|
||||
:[ Widget's text after sleep_timer elapsed (hide_on_silence has to be false)
|
||||
|[ *method*
|
||||
|[ *method* \[input\]
|
||||
:[ string
|
||||
:[ pulse
|
||||
:[ Audio capturing method. Possible methods are: pipewire, pulse, alsa, fifo, sndio or shmem
|
||||
@@ -105,9 +111,9 @@ libcava lives in:
|
||||
:[ false
|
||||
:[ Disables or enables the so-called "Monstercat smoothing" with or without "waves"
|
||||
|[ *noise_reduction*
|
||||
:[ double
|
||||
:[ 0.77
|
||||
:[ Range between 0 - 1. The raw visualization is very noisy, this factor adjusts the integral and gravity filters to keep the signal smooth. 1 - will be very slow and smooth, 0 - will be fast but noisy
|
||||
:[ integer
|
||||
:[ 77
|
||||
:[ Range between 0 - 100. The raw visualization is very noisy, this factor adjusts the integral and gravity filters to keep the signal smooth. 100 will be very slow and smooth, 0 will be fast but noisy
|
||||
|[ *input_delay*
|
||||
:[ integer
|
||||
:[ 2
|
||||
@@ -119,11 +125,11 @@ libcava lives in:
|
||||
|[ *data_format*
|
||||
:[ string
|
||||
:[ asci
|
||||
:[ It's impossible to set it. Waybar sets it to = asci for internal needs
|
||||
:[ Raw data format. Can be 'binary' or 'ascii'
|
||||
|[ *raw_target*
|
||||
:[ string
|
||||
:[ /dev/stdout
|
||||
:[ It's impossible to set it. Waybar sets it to = /dev/stdout for internal needs
|
||||
:[ Raw output target. A fifo will be created if target does not exist
|
||||
|[ *menu*
|
||||
:[ string
|
||||
:[
|
||||
@@ -136,6 +142,50 @@ libcava lives in:
|
||||
:[ array
|
||||
:[
|
||||
:[ The actions corresponding to the buttons of the menu.
|
||||
|[ *bar_spacing*
|
||||
:[ integer
|
||||
:[
|
||||
:[ Bars' space between bars in number of characters
|
||||
|[ *bar_width*
|
||||
:[ integer
|
||||
:[
|
||||
:[ Bars' width between bars in number of characters
|
||||
|[ *bar_height*
|
||||
:[ integer
|
||||
:[
|
||||
:[ Useless. bar_height is only used for output in "noritake" format
|
||||
|[ *background*
|
||||
:[ string
|
||||
:[
|
||||
:[ GLSL actual. Support hex code colors only. Must be within ''
|
||||
|[ *foreground*
|
||||
:[ string
|
||||
:[
|
||||
:[ GLSL actual. Support hex code colors only. Must be within ''
|
||||
|[ *gradient*
|
||||
:[ integer
|
||||
:[ 0
|
||||
:[ GLSL actual. Gradient mode(0/1 - on/off)
|
||||
|[ *gradient_count*
|
||||
:[ integer
|
||||
:[ 0
|
||||
:[ GLSL actual. The count of colors for the gradient
|
||||
|[ *gradient_color_N*
|
||||
:[ string
|
||||
:[
|
||||
:[ GLSL actual. N - the number of the gradient color between 1 and 8. Only hex defined colors are supported. Must be within ''
|
||||
|[ *sdl_width*
|
||||
:[ integer
|
||||
:[
|
||||
:[ GLSL actual. Manages the width of the waybar cava GLSL frontend module
|
||||
|[ *sdl_height*
|
||||
:[ integer
|
||||
:[
|
||||
:[ GLSL actual. Manages the height of the waybar cava GLSL frontend module
|
||||
|[ *continuous_rendering*
|
||||
:[ integer
|
||||
:[ 0
|
||||
:[ GLSL actual. Keep rendering even if no audio. Recommended to set to 1
|
||||
|
||||
Configuration can be provided as:
|
||||
- The only cava configuration file which is provided through *cava_config*. The rest configuration can be skipped
|
||||
@@ -153,16 +203,17 @@ Configuration can be provided as:
|
||||
|
||||
- iniparser
|
||||
- fftw3
|
||||
- epoxy (GLSL frontend only)
|
||||
|
||||
# SOLVING ISSUES
|
||||
|
||||
. On start Waybar throws an exception "error while loading shared libraries: libcava.so: cannot open shared object file: No such file or directory".
|
||||
It might happen when libcava for some reason hasn't been registered in the system. sudo ldconfig should help
|
||||
. Waybar is starting but cava module doesn't react to the music
|
||||
1. In such cases at first need to make sure usual cava application is working as well
|
||||
2. If so, need to comment all configuration options. Uncomment cava_config and provide the path to the working cava config
|
||||
3. You might set too huge or too small input_delay. Try to setup to 4 seconds, restart waybar, and check again 4 seconds past. Usual even on weak machines it should be enough
|
||||
4. You might accidentally switch action mode to pause mode
|
||||
1. In such cases at first need to make sure usual cava application is working as well
|
||||
2. If so, need to comment all configuration options. Uncomment cava_config and provide the path to the working cava config
|
||||
3. You might set too huge or too small input_delay. Try to setup to 4 seconds, restart waybar, and check again 4 seconds past. Usual even on weak machines it should be enough
|
||||
4. You might accidentally switch action mode to pause mode
|
||||
|
||||
# RISING ISSUES
|
||||
|
||||
@@ -205,3 +256,453 @@ In case when cava releases new version and you're wanna get it, it should be rai
|
||||
- *#cava*
|
||||
- *#cava.silent* Applied after no sound has been detected for sleep_timer seconds
|
||||
- *#cava.updated* Applied when a new frame is shown
|
||||
# FRONTENDS
|
||||
|
||||
## RAW
|
||||
The cava raw frontend uses ASCII characters to visualize incoming audio data. Each ASCII symbol position corresponds to the value of the audio power pulse.
|
||||
|
||||
Under the hood:
|
||||
```
|
||||
. Incoming audio power pulse list is : 12684
|
||||
. Configured array of ASCII codes is: ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" ]. See `format-icons` https://github.com/Alexays/Waybar/wiki/Module:-Cava#example
|
||||
```
|
||||
As a result cava frontend will give ▁▂▆█▄
|
||||
|
||||
Examples:
|
||||
|
||||
waybar config
|
||||
```
|
||||
"cava": {
|
||||
"cava_config": "$XDG_CONFIG_HOME/cava/waybar_raw.conf",
|
||||
"input_delay": 2,
|
||||
"format-icons" : ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" ],
|
||||
"actions": {
|
||||
"on-click-right": "mode"
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
waybar_raw.conf
|
||||
```
|
||||
## Configuration file for CAVA.
|
||||
# Remove the ; to change parameters.
|
||||
|
||||
|
||||
[general]
|
||||
|
||||
# Smoothing mode. Can be 'normal', 'scientific' or 'waves'. DEPRECATED as of 0.6.0
|
||||
|
||||
# Accepts only non-negative values.
|
||||
|
||||
# 'autosens' will attempt to decrease sensitivity if the bars peak. 1 = on, 0 = off
|
||||
# new as of 0.6.0 autosens of low values (dynamic range)
|
||||
# 'overshoot' allows bars to overshoot (in % of terminal height) without initiating autosens. DEPRECATED as of 0.6.0
|
||||
|
||||
# Manual sensitivity in %. If autosens is enabled, this will only be the initial value.
|
||||
# 200 means double height. Accepts only non-negative values.
|
||||
|
||||
# The number of bars (0-512). 0 sets it to auto (fill up console).
|
||||
# Bars' width and space between bars in number of characters.
|
||||
bars = 12
|
||||
# bar_height is only used for output in "noritake" format
|
||||
|
||||
# For SDL width and space between bars is in pixels, defaults are:
|
||||
|
||||
# sdl_glsl have these default values, they are only used to calculate max number of bars.
|
||||
|
||||
|
||||
# Lower and higher cutoff frequencies for lowest and highest bars
|
||||
# the bandwidth of the visualizer.
|
||||
# Note: there is a minimum total bandwidth of 43Mhz x number of bars.
|
||||
# Cava will automatically increase the higher cutoff if a too low band is specified.
|
||||
|
||||
# Seconds with no input before cava goes to sleep mode. Cava will not perform FFT or drawing and
|
||||
# only check for input once per second. Cava will wake up once input is detected. 0 = disable.
|
||||
sleep_timer = 5
|
||||
|
||||
|
||||
[input]
|
||||
|
||||
# Audio capturing method. Possible methods are: 'fifo', 'portaudio', 'pipewire', 'alsa', 'pulse', 'sndio', 'oss', 'jack' or 'shmem'
|
||||
# Defaults to 'oss', 'pipewire', 'sndio', 'jack', 'pulse', 'alsa', 'portaudio' or 'fifo', in that order, dependent on what support cava was built with.
|
||||
# On Mac it defaults to 'portaudio' or 'fifo'
|
||||
# On windows this is automatic and no input settings are needed.
|
||||
#
|
||||
# All input methods uses the same config variable 'source'
|
||||
# to define where it should get the audio.
|
||||
#
|
||||
# For pulseaudio and pipewire 'source' will be the source. Default: 'auto', which uses the monitor source of the default sink
|
||||
# (all pulseaudio sinks(outputs) have 'monitor' sources(inputs) associated with them).
|
||||
#
|
||||
# For pipewire 'source' will be the object name or object.serial of the device to capture from.
|
||||
# Both input and output devices are supported.
|
||||
#
|
||||
# For alsa 'source' will be the capture device.
|
||||
# For fifo 'source' will be the path to fifo-file.
|
||||
# For shmem 'source' will be /squeezelite-AA:BB:CC:DD:EE:FF where 'AA:BB:CC:DD:EE:FF' will be squeezelite's MAC address
|
||||
#
|
||||
# For sndio 'source' will be a raw recording audio descriptor or a monitoring sub-device, e.g. 'rsnd/2' or 'snd/1'. Default: 'default'.
|
||||
# README.md contains further information on how to setup CAVA for sndio.
|
||||
#
|
||||
# For oss 'source' will be the path to a audio device, e.g. '/dev/dsp2'. Default: '/dev/dsp', i.e. the default audio device.
|
||||
# README.md contains further information on how to setup CAVA for OSS on FreeBSD.
|
||||
#
|
||||
# For jack 'source' will be the name of the JACK server to connect to, e.g. 'foobar'. Default: 'default'.
|
||||
# README.md contains further information on how to setup CAVA for JACK.
|
||||
#
|
||||
|
||||
# The options 'sample_rate', 'sample_bits', 'channels' and 'autoconnect' can be configured for some input methods:
|
||||
# sample_rate: fifo, pipewire, sndio, oss
|
||||
# sample_bits: fifo, pipewire, sndio, oss
|
||||
# channels: sndio, oss, jack
|
||||
# autoconnect: jack
|
||||
# Other methods ignore these settings.
|
||||
#
|
||||
# For 'sndio' and 'oss' they are only preferred values, i.e. if the values are not supported
|
||||
# by the chosen audio device, the device will use other supported values instead.
|
||||
# Example: 48000, 32 and 2, but the device only supports 44100, 16 and 1, then it
|
||||
# will use 44100, 16 and 1.
|
||||
#
|
||||
|
||||
|
||||
[output]
|
||||
|
||||
# Output method. Can be 'ncurses', 'noncurses', 'raw', 'noritake', 'sdl'
|
||||
# or 'sdl_glsl'.
|
||||
# 'noncurses' (default) uses a buffer and cursor movements to only print
|
||||
# changes from frame to frame in the terminal. Uses less resources and is less
|
||||
# prone to tearing (vsync issues) than 'ncurses'.
|
||||
#
|
||||
# 'raw' is an 8 or 16 bit (configurable via the 'bit_format' option) data
|
||||
# stream of the bar heights that can be used to send to other applications.
|
||||
# 'raw' defaults to 200 bars, which can be adjusted in the 'bars' option above.
|
||||
#
|
||||
# 'noritake' outputs a bitmap in the format expected by a Noritake VFD display
|
||||
# in graphic mode. It only support the 3000 series graphical VFDs for now.
|
||||
#
|
||||
# 'sdl' uses the Simple DirectMedia Layer to render in a graphical context.
|
||||
# 'sdl_glsl' uses SDL to create an OpenGL context. Write your own shaders or
|
||||
# use one of the predefined ones.
|
||||
method = raw
|
||||
|
||||
# Orientation of the visualization. Can be 'bottom', 'top', 'left', 'right' or
|
||||
# 'horizontal'. Default is 'bottom'. 'left and 'right' are only supported on sdl
|
||||
# and ncruses output. 'horizontal' (bars go up and down from center) is only supported
|
||||
# on noncurses output.
|
||||
# Note: many fonts have weird or missing glyphs for characters used in orientations
|
||||
# other than 'bottom', which can make output not look right.
|
||||
|
||||
# Visual channels. Can be 'stereo' or 'mono'.
|
||||
# 'stereo' mirrors both channels with low frequencies in center.
|
||||
# 'mono' outputs left to right lowest to highest frequencies.
|
||||
# 'mono_option' set mono to either take input from 'left', 'right' or 'average'.
|
||||
# set 'reverse' to 1 to display frequencies the other way around.
|
||||
|
||||
# Raw output target. A fifo will be created if target does not exist.
|
||||
raw_target = /dev/stdout
|
||||
|
||||
# Raw data format. Can be 'binary' or 'ascii'.
|
||||
data_format = ascii
|
||||
|
||||
# Binary bit format, can be '8bit' (0-255) or '16bit' (0-65530).
|
||||
|
||||
# Ascii max value. In 'ascii' mode range will run from 0 to value specified here
|
||||
|
||||
# Ascii delimiters. In ascii format each bar and frame is separated by a delimiters.
|
||||
# Use decimal value in ascii table (i.e. 59 = ';' and 10 = '\n' (line feed)).
|
||||
bar_delimiter = 0
|
||||
|
||||
# sdl window size and position. -1,-1 is centered.
|
||||
|
||||
# set label on bars on the x-axis. Can be 'frequency' or 'none'. Default: 'none'
|
||||
# 'frequency' displays the lower cut off frequency of the bar above.
|
||||
# Only supported on ncurses and noncurses output.
|
||||
|
||||
# enable synchronized sync. 1 = on, 0 = off
|
||||
# removes flickering in alacritty terminal emulator.
|
||||
# defaults to off since the behaviour in other terminal emulators is unknown
|
||||
|
||||
# Shaders for sdl_glsl, located in $HOME/.config/cava/shaders
|
||||
|
||||
; for glsl output mode, keep rendering even if no audio
|
||||
|
||||
# disable console blank (screen saver) in tty
|
||||
# (Not supported on FreeBSD)
|
||||
|
||||
# show a flat bar at the bottom of the screen when idle, 1 = on, 0 = off
|
||||
|
||||
# show waveform instead of frequency spectrum, 1 = on, 0 = off
|
||||
|
||||
[color]
|
||||
|
||||
# Colors can be one of seven predefined: black, blue, cyan, green, magenta, red, white, yellow.
|
||||
# Or defined by hex code '#xxxxxx' (hex code must be within ''). User defined colors requires
|
||||
# a terminal that can change color definitions such as Gnome-terminal or rxvt.
|
||||
# default is to keep current terminal color
|
||||
|
||||
# SDL and sdl_glsl only support hex code colors, these are the default:
|
||||
|
||||
# Gradient mode, only hex defined colors are supported,
|
||||
# background must also be defined in hex or remain commented out. 1 = on, 0 = off.
|
||||
# You can define as many as 8 different colors. They range from bottom to top of screen
|
||||
|
||||
[smoothing]
|
||||
|
||||
# Disables or enables the so-called "Monstercat smoothing" with or without "waves". Set to 0 to disable.
|
||||
|
||||
# Noise reduction, int 0 - 100. default 77
|
||||
# the raw visualization is very noisy, this factor adjusts the integral and gravity filters to keep the signal smooth
|
||||
# 100 will be very slow and smooth, 0 will be fast but noisy.
|
||||
|
||||
|
||||
[eq]
|
||||
|
||||
# This one is tricky. You can have as much keys as you want.
|
||||
# Remember to uncomment more than one key! More keys = more precision.
|
||||
# Look at readme.md on github for further explanations and examples.
|
||||
```
|
||||
## GLSL
|
||||
The Cava GLSL frontend delegates the visualization of incoming audio data to the GPU via OpenGL.
|
||||
|
||||
There are some mandatory dependencies that need to be satisfied in order for Cava GLSL to be built and function properly:
|
||||
|
||||
. epoxy library must be installed on the system
|
||||
. Vertex and fragment shaders from the original project must be used. They should be downloaded, and the file paths must be configured correctly in the Waybar Cava configuration:
|
||||
1. cava shaders [cava shaders](https://github.com/karlstav/cava/tree/master/output/shaders)
|
||||
2. libcava shaders [libcava shaders](https://github.com/LukashonakV/cava/tree/master/output/shaders)
|
||||
. It is highly recommended to have a separate cava configuration for the Waybar Cava GLSL module and to use this as the cava_config in the Waybar configuration.
|
||||
. It is common for cava configurations to be placed in the XDG_CONFIG_HOME directory, including shaders as well. Consider keeping them in the $XDG_CONFIG_HOME/cava/shaders folder.
|
||||
|
||||
Key configuration options:
|
||||
|
||||
. bars. The more values the parameter has, the more interesting the visualization becomes.
|
||||
. method in output section must be set to sdl_glsl
|
||||
. sdl_width and sdl_height manage the size of the module. Adjust them according to your needs.
|
||||
. Shaders for sdl_glsl, located in $HOME/.config/cava/shaders. Example: "vertex_shader" = "pass_through.vert" "fragment_shader" = "spectrogram.frag"
|
||||
. Set continuous_rendering to 1 to enable smooth rendering; set it to 0 otherwise. It is recommended to keep it set to 1.
|
||||
. background, foreground, and gradient_color_N (where N is a number between 1 and 8) must be defined using hex code
|
||||
|
||||
Example:
|
||||
|
||||
waybar config
|
||||
```
|
||||
"cava": {
|
||||
"cava_config": "$XDG_CONFIG_HOME/cava/waybar_cava#3.conf",
|
||||
"input_delay": 2,
|
||||
"actions": {
|
||||
"on-click-right": "mode"
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
waybar_raw.conf
|
||||
```
|
||||
## Configuration file for CAVA.
|
||||
# Remove the ; to change parameters.
|
||||
|
||||
|
||||
[general]
|
||||
|
||||
# Smoothing mode. Can be 'normal', 'scientific' or 'waves'. DEPRECATED as of 0.6.0
|
||||
|
||||
# Accepts only non-negative values.
|
||||
|
||||
# 'autosens' will attempt to decrease sensitivity if the bars peak. 1 = on, 0 = off
|
||||
# new as of 0.6.0 autosens of low values (dynamic range)
|
||||
# 'overshoot' allows bars to overshoot (in % of terminal height) without initiating autosens. DEPRECATED as of 0.6.0
|
||||
|
||||
# Manual sensitivity in %. If autosens is enabled, this will only be the initial value.
|
||||
# 200 means double height. Accepts only non-negative values.
|
||||
|
||||
# The number of bars (0-512). 0 sets it to auto (fill up console).
|
||||
# Bars' width and space between bars in number of characters.
|
||||
bars = 50
|
||||
|
||||
# bar_height is only used for output in "noritake" format
|
||||
|
||||
# For SDL width and space between bars is in pixels, defaults are:
|
||||
|
||||
# sdl_glsl have these default values, they are only used to calculate max number of bars.
|
||||
|
||||
# Lower and higher cutoff frequencies for lowest and highest bars
|
||||
# the bandwidth of the visualizer.
|
||||
# Note: there is a minimum total bandwidth of 43Mhz x number of bars.
|
||||
# Cava will automatically increase the higher cutoff if a too low band is specified.
|
||||
|
||||
# Seconds with no input before cava goes to sleep mode. Cava will not perform FFT or drawing and
|
||||
# only check for input once per second. Cava will wake up once input is detected. 0 = disable.
|
||||
sleep_timer = 5
|
||||
|
||||
|
||||
[input]
|
||||
|
||||
# Audio capturing method. Possible methods are: 'fifo', 'portaudio', 'pipewire', 'alsa', 'pulse', 'sndio', 'oss', 'jack' or 'shmem'
|
||||
# Defaults to 'oss', 'pipewire', 'sndio', 'jack', 'pulse', 'alsa', 'portaudio' or 'fifo', in that order, dependent on what support cava was built with.
|
||||
# On Mac it defaults to 'portaudio' or 'fifo'
|
||||
# On windows this is automatic and no input settings are needed.
|
||||
#
|
||||
# All input methods uses the same config variable 'source'
|
||||
# to define where it should get the audio.
|
||||
#
|
||||
# For pulseaudio and pipewire 'source' will be the source. Default: 'auto', which uses the monitor source of the default sink
|
||||
# (all pulseaudio sinks(outputs) have 'monitor' sources(inputs) associated with them).
|
||||
#
|
||||
# For pipewire 'source' will be the object name or object.serial of the device to capture from.
|
||||
# Both input and output devices are supported.
|
||||
#
|
||||
# For alsa 'source' will be the capture device.
|
||||
# For fifo 'source' will be the path to fifo-file.
|
||||
# For shmem 'source' will be /squeezelite-AA:BB:CC:DD:EE:FF where 'AA:BB:CC:DD:EE:FF' will be squeezelite's MAC address
|
||||
#
|
||||
# For sndio 'source' will be a raw recording audio descriptor or a monitoring sub-device, e.g. 'rsnd/2' or 'snd/1'. Default: 'default'.
|
||||
# README.md contains further information on how to setup CAVA for sndio.
|
||||
#
|
||||
# For oss 'source' will be the path to a audio device, e.g. '/dev/dsp2'. Default: '/dev/dsp', i.e. the default audio device.
|
||||
# README.md contains further information on how to setup CAVA for OSS on FreeBSD.
|
||||
#
|
||||
# For jack 'source' will be the name of the JACK server to connect to, e.g. 'foobar'. Default: 'default'.
|
||||
# README.md contains further information on how to setup CAVA for JACK.
|
||||
#
|
||||
|
||||
|
||||
# The options 'sample_rate', 'sample_bits', 'channels' and 'autoconnect' can be configured for some input methods:
|
||||
# sample_rate: fifo, pipewire, sndio, oss
|
||||
# sample_bits: fifo, pipewire, sndio, oss
|
||||
# channels: sndio, oss, jack
|
||||
# autoconnect: jack
|
||||
# Other methods ignore these settings.
|
||||
#
|
||||
# For 'sndio' and 'oss' they are only preferred values, i.e. if the values are not supported
|
||||
# by the chosen audio device, the device will use other supported values instead.
|
||||
# Example: 48000, 32 and 2, but the device only supports 44100, 16 and 1, then it
|
||||
# will use 44100, 16 and 1.
|
||||
#
|
||||
|
||||
|
||||
[output]
|
||||
|
||||
# Output method. Can be 'ncurses', 'noncurses', 'raw', 'noritake', 'sdl'
|
||||
# or 'sdl_glsl'.
|
||||
# 'noncurses' (default) uses a buffer and cursor movements to only print
|
||||
# changes from frame to frame in the terminal. Uses less resources and is less
|
||||
# prone to tearing (vsync issues) than 'ncurses'.
|
||||
#
|
||||
# 'raw' is an 8 or 16 bit (configurable via the 'bit_format' option) data
|
||||
# stream of the bar heights that can be used to send to other applications.
|
||||
# 'raw' defaults to 200 bars, which can be adjusted in the 'bars' option above.
|
||||
#
|
||||
# 'noritake' outputs a bitmap in the format expected by a Noritake VFD display
|
||||
# in graphic mode. It only support the 3000 series graphical VFDs for now.
|
||||
#
|
||||
# 'sdl' uses the Simple DirectMedia Layer to render in a graphical context.
|
||||
# 'sdl_glsl' uses SDL to create an OpenGL context. Write your own shaders or
|
||||
# use one of the predefined ones.
|
||||
method = sdl_glsl
|
||||
|
||||
# Orientation of the visualization. Can be 'bottom', 'top', 'left', 'right' or
|
||||
# 'horizontal'. Default is 'bottom'. 'left and 'right' are only supported on sdl
|
||||
# and ncruses output. 'horizontal' (bars go up and down from center) is only supported
|
||||
# on noncurses output.
|
||||
# Note: many fonts have weird or missing glyphs for characters used in orientations
|
||||
# other than 'bottom', which can make output not look right.
|
||||
|
||||
# Visual channels. Can be 'stereo' or 'mono'.
|
||||
# 'stereo' mirrors both channels with low frequencies in center.
|
||||
# 'mono' outputs left to right lowest to highest frequencies.
|
||||
# 'mono_option' set mono to either take input from 'left', 'right' or 'average'.
|
||||
# set 'reverse' to 1 to display frequencies the other way around.
|
||||
|
||||
# Raw output target. A fifo will be created if target does not exist.
|
||||
|
||||
# Raw data format. Can be 'binary' or 'ascii'.
|
||||
|
||||
# Binary bit format, can be '8bit' (0-255) or '16bit' (0-65530).
|
||||
|
||||
# Ascii max value. In 'ascii' mode range will run from 0 to value specified here
|
||||
|
||||
# Ascii delimiters. In ascii format each bar and frame is separated by a delimiters.
|
||||
# Use decimal value in ascii table (i.e. 59 = ';' and 10 = '\n' (line feed)).
|
||||
bar_delimiter = 0
|
||||
|
||||
# sdl window size and position. -1,-1 is centered.
|
||||
sdl_width = 150
|
||||
sdl_height = 39
|
||||
|
||||
# set label on bars on the x-axis. Can be 'frequency' or 'none'. Default: 'none'
|
||||
# 'frequency' displays the lower cut off frequency of the bar above.
|
||||
# Only supported on ncurses and noncurses output.
|
||||
|
||||
# enable synchronized sync. 1 = on, 0 = off
|
||||
# removes flickering in alacritty terminal emulator.
|
||||
# defaults to off since the behaviour in other terminal emulators is unknown
|
||||
|
||||
# Shaders for sdl_glsl, located in $HOME/.config/cava/shaders
|
||||
vertex_shader = pass_through.vert
|
||||
fragment_shader = bar_spectrum.frag
|
||||
|
||||
; for glsl output mode, keep rendering even if no audio
|
||||
continuous_rendering = 1;
|
||||
|
||||
# disable console blank (screen saver) in tty
|
||||
# (Not supported on FreeBSD)
|
||||
|
||||
# show a flat bar at the bottom of the screen when idle, 1 = on, 0 = off
|
||||
|
||||
# show waveform instead of frequency spectrum, 1 = on, 0 = off
|
||||
|
||||
[color]
|
||||
|
||||
|
||||
# Colors can be one of seven predefined: black, blue, cyan, green, magenta, red, white, yellow.
|
||||
# Or defined by hex code '#xxxxxx' (hex code must be within ''). User defined colors requires
|
||||
# a terminal that can change color definitions such as Gnome-terminal or rxvt.
|
||||
# default is to keep current terminal color
|
||||
|
||||
# SDL and sdl_glsl only support hex code colors, these are the default:
|
||||
background = '#282C34'
|
||||
|
||||
# Gradient mode, only hex defined colors are supported,
|
||||
# background must also be defined in hex or remain commented out. 1 = on, 0 = off.
|
||||
# You can define as many as 8 different colors. They range from bottom to top of screen
|
||||
gradient = 1
|
||||
gradient_count = 2
|
||||
gradient_color_1 = '#282C34'
|
||||
gradient_color_2 = '#45475A'
|
||||
|
||||
; gradient_color_1 = '#59cc33'
|
||||
; gradient_color_2 = '#80cc33'
|
||||
gradient_color_3 = '#a6cc33'
|
||||
gradient_color_4 = '#cccc33'
|
||||
gradient_color_5 = '#cca633'
|
||||
gradient_color_6 = '#cc8033'
|
||||
gradient_color_7 = '#cc5933'
|
||||
gradient_color_8 = '#cc3333'
|
||||
|
||||
[smoothing]
|
||||
|
||||
# Percentage value for integral smoothing. Takes values from 0 - 100.
|
||||
# Higher values means smoother, but less precise. 0 to disable.
|
||||
# DEPRECATED as of 0.8.0, use noise_reduction instead
|
||||
|
||||
# Disables or enables the so-called "Monstercat smoothing" with or without "waves". Set to 0 to disable.
|
||||
|
||||
# Set gravity percentage for "drop off". Higher values means bars will drop faster.
|
||||
# Accepts only non-negative values. 50 means half gravity, 200 means double. Set to 0 to disable "drop off".
|
||||
# DEPRECATED as of 0.8.0, use noise_reduction instead
|
||||
|
||||
|
||||
# In bar height, bars that would have been lower that this will not be drawn.
|
||||
# DEPRECATED as of 0.8.0
|
||||
|
||||
# Noise reduction, int 0 - 100. default 77
|
||||
# the raw visualization is very noisy, this factor adjusts the integral and gravity filters to keep the signal smooth
|
||||
# 100 will be very slow and smooth, 0 will be fast but noisy.
|
||||
|
||||
[eq]
|
||||
|
||||
# This one is tricky. You can have as much keys as you want.
|
||||
# Remember to uncomment more than one key! More keys = more precision.
|
||||
# Look at readme.md on github for further explanations and examples.
|
||||
```
|
||||
|
||||
Different waybar_cava#N.conf see at [cava GLSL](https://github.com/Alexays/Waybar/wiki/Module:-Cava:-GLSL)
|
||||
|
||||
@@ -39,6 +39,12 @@ $XDG_CONFIG_HOME/waybar/config ++
|
||||
:[ A list of timezones (as in *timezone*) to use for time display, changed using
|
||||
the scroll wheel. Do not specify *timezone* option when *timezones* is specified.
|
||||
"" represents the system's local timezone
|
||||
|[ *timezone-tooltip-format*
|
||||
:[ string
|
||||
:[
|
||||
:[ Format to use for displaying timezones in the tooltip. When set, this allows showing
|
||||
timezone information (like timezone abbreviations) in the tooltip while keeping the
|
||||
main display clean. Uses the same format options as *format*
|
||||
|[ *locale*
|
||||
:[ string
|
||||
:[
|
||||
@@ -126,6 +132,12 @@ View all valid format options in *strftime(3)* or have a look https://en.cpprefe
|
||||
:[ 1
|
||||
:[ Value to scroll months/years forward/backward. Can be negative. Is
|
||||
configured under *on-scroll* option
|
||||
|[ *iso8601*
|
||||
:[ bool
|
||||
:[ false
|
||||
:[ When enabled, the calendar follows the ISO 8601 standard: weeks begin on
|
||||
Monday, and the first week of the year is numbered 1. The default week format is
|
||||
'{:%V}'.
|
||||
|
||||
3. Addressed by *clock: calendar: format*
|
||||
[- *Option*
|
||||
@@ -229,6 +241,25 @@ View all valid format options in *strftime(3)* or have a look https://en.cpprefe
|
||||
}
|
||||
```
|
||||
|
||||
4. Show timezone in tooltip only
|
||||
|
||||
```
|
||||
"clock": {
|
||||
"interval": 60,
|
||||
"format": "{:%H:%M}",
|
||||
"timezone-tooltip-format": "{:%H:%M %Z}",
|
||||
"timezones": [
|
||||
"",
|
||||
"America/Chicago",
|
||||
"America/Los_Angeles",
|
||||
"Europe/Paris",
|
||||
"UTC"
|
||||
],
|
||||
"tooltip": true,
|
||||
"tooltip-format": "{tz_list}"
|
||||
}
|
||||
```
|
||||
|
||||
# STYLE
|
||||
|
||||
- *#clock*
|
||||
|
||||
@@ -11,9 +11,10 @@ The *cpu* module displays the current CPU utilization.
|
||||
# CONFIGURATION
|
||||
|
||||
*interval*: ++
|
||||
typeof: integer ++
|
||||
typeof: integer or float ++
|
||||
default: 10 ++
|
||||
The interval in which the information gets polled.
|
||||
The interval in which the information gets polled. ++
|
||||
Minimum value is 0.001 (1ms). Values smaller than 1ms will be set to 1ms.
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
|
||||
@@ -35,15 +35,17 @@ Addressed by *custom/<name>*
|
||||
See *return-type*
|
||||
|
||||
*interval*: ++
|
||||
typeof: integer ++
|
||||
typeof: integer or float ++
|
||||
The interval (in seconds) in which the information gets polled. ++
|
||||
Minimum value is 0.001 (1ms). Values smaller than 1ms will be set to 1ms. ++
|
||||
Use *once* if you want to execute the module only on startup. ++
|
||||
You can update it manually with a signal. If no *interval* or *signal* is defined, it is assumed that the out script loops itself. ++
|
||||
If a *signal* is defined then the script will run once on startup and will only update with a signal.
|
||||
|
||||
*restart-interval*: ++
|
||||
typeof: integer ++
|
||||
typeof: integer or float ++
|
||||
The restart interval (in seconds). ++
|
||||
Minimum value is 0.001 (1ms). Values smaller than 1ms will be set to 1ms. ++
|
||||
Can't be used with the *interval* option, so only with continuous scripts. ++
|
||||
Once the script exits, it'll be re-executed after the *restart-interval*.
|
||||
|
||||
@@ -232,7 +234,6 @@ $text\\n$tooltip\\n$class*
|
||||
```
|
||||
"custom/pacman": {
|
||||
"format": "{text} ",
|
||||
"interval": 3600, // every hour
|
||||
"exec": "checkupdates | wc -l", // # of updates
|
||||
"exec-if": "exit 0", // always run; consider advanced run conditions
|
||||
"on-click": "termite -e 'sudo pacman -Syu'; pkill -SIGRTMIN+8 waybar", // update system
|
||||
@@ -240,7 +241,7 @@ $text\\n$tooltip\\n$class*
|
||||
}
|
||||
```
|
||||
|
||||
You can use the signal and update the number of available packages with *pkill -RTMIN+8 waybar*.
|
||||
Under the premise that interval is not defined, you can use the signal and update the number of available packages with *pkill -RTMIN+8 waybar*.
|
||||
|
||||
# STYLE
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ Addressed by *dwl/tags*
|
||||
|
||||
- *#tags button*
|
||||
- *#tags button.occupied*
|
||||
- *#tags button.empty*
|
||||
- *#tags button.focused*
|
||||
- *#tags button.urgent*
|
||||
|
||||
|
||||
@@ -64,6 +64,8 @@ Addressed by *ext/workspaces*
|
||||
|
||||
*activate*: Switch to workspace.
|
||||
|
||||
*deactivate*: Deactivate the workspace.
|
||||
|
||||
*close*: Close the workspace.
|
||||
|
||||
# ICONS
|
||||
|
||||
@@ -50,6 +50,21 @@ This setting is ignored if *workspace-taskbar.enable* is set to true.
|
||||
default: false ++
|
||||
Enables the workspace taskbar mode.
|
||||
|
||||
*update-active-window*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If true, the active/focused window will have an 'active' class. Could cause higher CPU usage due to more frequent redraws.
|
||||
|
||||
*reverse-direction*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If true, the taskbar windows will be added in reverse order (right to left if orientation is horizontal, bottom to top if vertical).
|
||||
|
||||
*active-window-position*: ++
|
||||
typeof: "none" | "first" | "last" ++
|
||||
default: "none" ++
|
||||
If set to "first", the active window will be moved at the beginning of the taskbar. If set to "last", it will be moved at the end. It will only work if *update-active-window* is set to true.
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {icon} ++
|
||||
@@ -70,6 +85,19 @@ This setting is ignored if *workspace-taskbar.enable* is set to true.
|
||||
default: horizontal ++
|
||||
Direction in which the workspace taskbar is displayed.
|
||||
|
||||
*ignore-list*: ++
|
||||
typeof: array ++
|
||||
default: [] ++
|
||||
Regex patterns to match against window class or window title. If a window's class OR title matches any of the patterns, it will not be shown.
|
||||
|
||||
*on-click-window*: ++
|
||||
typeof: string ++
|
||||
default: "" ++
|
||||
Command to run when a window is clicked. Available placeholders are: ++
|
||||
- {address} Hyprland address of the clicked window. ++
|
||||
- {button} Pressed button number, see https://api.gtkd.org/gdk.c.types.GdkEventButton.button.html. ++
|
||||
See https://github.com/Alexays/Waybar/wiki/Module:-Hyprland#workspace-taskbars-example for a full example.
|
||||
|
||||
*show-special*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
@@ -216,4 +244,6 @@ Additional to workspace name matching, the following *format-icons* can be set.
|
||||
- *#workspaces button.special*
|
||||
- *#workspaces button.urgent*
|
||||
- *#workspaces button.hosting-monitor* (gets applied if workspace-monitor == waybar-monitor)
|
||||
- *#workspaces .taskbar-window* (each window in the taskbar)
|
||||
- *#workspaces .workspace-label*
|
||||
- *#workspaces .taskbar-window* (each window in the taskbar, only if 'workspace-taskbar.enable' is true)
|
||||
- *#workspaces .taskbar-window.active* (applied to the focused window, only if 'workspace-taskbar.update-active-window' is true)
|
||||
|
||||
@@ -24,8 +24,9 @@ The *image* module displays an image from a path.
|
||||
The width/height to render the image.
|
||||
|
||||
*interval*: ++
|
||||
typeof: integer ++
|
||||
typeof: integer or float ++
|
||||
The interval (in seconds) to re-render the image. ++
|
||||
Minimum value is 0.001 (1ms). Values smaller than 1ms will be set to 1ms. ++
|
||||
This is useful if the contents of *path* changes. ++
|
||||
If no *interval* is defined, the image will only be rendered once.
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ Addressed by *jack*
|
||||
The format of information displayed in the tooltip.
|
||||
|
||||
*interval*: ++
|
||||
typeof: integer ++
|
||||
typeof: integer or float ++
|
||||
default: 1 ++
|
||||
The interval in which the information gets polled.
|
||||
|
||||
|
||||
@@ -87,15 +87,15 @@ Module config :
|
||||
```
|
||||
"custom/power": {
|
||||
"format" : "⏻ ",
|
||||
"tooltip": false,
|
||||
"menu": "on-click",
|
||||
"menu-file": "~/.config/waybar/power_menu.xml",
|
||||
"menu-actions": {
|
||||
"shutdown": "shutdown",
|
||||
"reboot": "reboot",
|
||||
"suspend": "systemctl suspend",
|
||||
"hibernate": "systemctl hibernate",
|
||||
},
|
||||
"tooltip": false,
|
||||
"menu": "on-click",
|
||||
"menu-file": "~/.config/waybar/power_menu.xml",
|
||||
"menu-actions": {
|
||||
"shutdown": "shutdown",
|
||||
"reboot": "reboot",
|
||||
"suspend": "systemctl suspend",
|
||||
"hibernate": "systemctl hibernate",
|
||||
},
|
||||
},
|
||||
```
|
||||
|
||||
@@ -104,28 +104,28 @@ Module config :
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkMenu" id="menu">
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="suspend">
|
||||
<property name="label">Suspend</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="hibernat">
|
||||
<property name="label">Hibernate</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="suspend">
|
||||
<property name="label">Suspend</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="hibernate">
|
||||
<property name="label">Hibernate</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="shutdown">
|
||||
<property name="label">Shutdown</property>
|
||||
</object>
|
||||
<object class="GtkMenuItem" id="shutdown">
|
||||
<property name="label">Shutdown</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="delimiter1"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="reboot">
|
||||
<property name="label">Reboot</property>
|
||||
</object>
|
||||
<object class="GtkMenuItem" id="reboot">
|
||||
<property name="label">Reboot</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
||||
@@ -52,8 +52,8 @@ Addressed by *niri/language*
|
||||
|
||||
```
|
||||
"niri/language": {
|
||||
"format": "Lang: {long}"
|
||||
"format-en": "AMERICA, HELL YEAH!"
|
||||
"format": "Lang: {long}",
|
||||
"format-en": "AMERICA, HELL YEAH!",
|
||||
"format-tr": "As bayrakları"
|
||||
}
|
||||
```
|
||||
@@ -61,3 +61,12 @@ Addressed by *niri/language*
|
||||
# STYLE
|
||||
|
||||
- *#language*
|
||||
|
||||
Additionally, a CSS class matching the current layout's short name is added to the widget. This
|
||||
allows per-language styling, for example:
|
||||
|
||||
```
|
||||
#language.us { color: #00ff00; }
|
||||
#language.de { color: #ff0000; }
|
||||
#language.fr { color: #0000ff; }
|
||||
```
|
||||
|
||||
@@ -77,12 +77,12 @@ The slider is a component with multiple CSS Nodes, of which the following are ex
|
||||
min-height: 80px;
|
||||
min-width: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: black;
|
||||
background: black;
|
||||
}
|
||||
|
||||
#pulseaudio-slider highlight {
|
||||
min-width: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: green;
|
||||
background: green;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -97,7 +97,11 @@ Additionally, you can control the volume by scrolling *up* or *down* while the c
|
||||
|
||||
*reverse-scrolling*: ++
|
||||
typeof: bool ++
|
||||
Option to reverse the scroll direction.
|
||||
Option to reverse the scroll direction for touchpads.
|
||||
|
||||
*reverse-mouse-scrolling*: ++
|
||||
typeof: bool ++
|
||||
Option to reverse the scroll direction for mice.
|
||||
|
||||
*tooltip*: ++
|
||||
typeof: bool ++
|
||||
@@ -173,8 +177,8 @@ to be selected when the corresponding audio device is muted. This applies to *de
|
||||
"format-icons": {
|
||||
"alsa_output.pci-0000_00_1f.3.analog-stereo": "",
|
||||
"alsa_output.pci-0000_00_1f.3.analog-stereo-muted": "",
|
||||
"headphones": "",
|
||||
"handsfree": "",
|
||||
"headphone": "",
|
||||
"hands-free": "",
|
||||
"headset": "",
|
||||
"phone": "",
|
||||
"phone-muted": "",
|
||||
|
||||
@@ -179,7 +179,6 @@ n.b.: the list of outputs can be obtained from command line using *swaymsg -t ge
|
||||
"format": "<span size='larger'>{name}</span> {windows}",
|
||||
"format-window-separator": " | ",
|
||||
"window-rewrite-default": "{name}",
|
||||
"window-format": "<span color='#e0e0e0'>{name}</span>",
|
||||
"window-rewrite": {
|
||||
"class<firefox>": "",
|
||||
"class<kitty>": "k",
|
||||
|
||||
@@ -40,7 +40,7 @@ Addressed by *temperature*
|
||||
The threshold before it is considered critical (Celsius).
|
||||
|
||||
*interval*: ++
|
||||
typeof: integer ++
|
||||
typeof: integer or float ++
|
||||
default: 10 ++
|
||||
The interval in which the information gets polled.
|
||||
|
||||
@@ -160,4 +160,5 @@ Addressed by *temperature*
|
||||
# STYLE
|
||||
|
||||
- *#temperature*
|
||||
- *#temperature.warning*
|
||||
- *#temperature.critical*
|
||||
|
||||
@@ -437,4 +437,4 @@ A group may hide all but one element, showing them only on mouse hover. In order
|
||||
# SEE ALSO
|
||||
|
||||
*sway-output(5)*
|
||||
*waybar-styles(5)"
|
||||
*waybar-styles(5)*
|
||||
|
||||
19
meson.build
19
meson.build
@@ -69,7 +69,7 @@ is_openbsd = host_machine.system() == 'openbsd'
|
||||
|
||||
thread_dep = dependency('threads')
|
||||
fmt = dependency('fmt', version : ['>=8.1.1'], fallback : ['fmt', 'fmt_dep'])
|
||||
spdlog = dependency('spdlog', version : ['>=1.10.0'], fallback : ['spdlog', 'spdlog_dep'], default_options : ['external_fmt=enabled', 'std_format=disabled', 'tests=disabled'])
|
||||
spdlog = dependency('spdlog', version : ['>=1.15.2'], fallback : ['spdlog', 'spdlog_dep'], default_options : ['std_format=disabled', 'tests=disabled'])
|
||||
wayland_client = dependency('wayland-client')
|
||||
wayland_cursor = dependency('wayland-cursor')
|
||||
wayland_protos = dependency('wayland-protocols')
|
||||
@@ -497,16 +497,24 @@ else
|
||||
man_files += files('man/waybar-clock.5.scd')
|
||||
endif
|
||||
|
||||
cava = dependency('cava',
|
||||
version : '>=0.10.4',
|
||||
cava = dependency('libcava',
|
||||
version : '>=0.10.7',
|
||||
required: get_option('cava'),
|
||||
fallback : ['cava', 'cava_dep'],
|
||||
fallback : ['libcava', 'cava_dep'],
|
||||
not_found_message: 'cava is not found. Building waybar without cava')
|
||||
|
||||
eproxy = dependency('epoxy', required: false)
|
||||
|
||||
if cava.found()
|
||||
add_project_arguments('-DHAVE_LIBCAVA', language: 'cpp')
|
||||
src_files += files('src/modules/cava.cpp')
|
||||
src_files += files('src/modules/cava/cavaRaw.cpp',
|
||||
'src/modules/cava/cava_backend.cpp')
|
||||
man_files += files('man/waybar-cava.5.scd')
|
||||
|
||||
if eproxy.found()
|
||||
add_project_arguments('-DHAVE_LIBCAVAGLSL', language: 'cpp')
|
||||
src_files += files('src/modules/cava/cavaGLSL.cpp')
|
||||
endif
|
||||
endif
|
||||
|
||||
if libgps.found()
|
||||
@@ -554,6 +562,7 @@ executable(
|
||||
tz_dep,
|
||||
xkbregistry,
|
||||
cava,
|
||||
eproxy,
|
||||
libgps
|
||||
],
|
||||
include_directories: inc_dirs,
|
||||
|
||||
@@ -6,16 +6,17 @@
|
||||
}:
|
||||
let
|
||||
libcava = rec {
|
||||
version = "0.10.4";
|
||||
version = "0.10.7-beta";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "LukashonakV";
|
||||
repo = "cava";
|
||||
tag = version;
|
||||
hash = "sha256-9eTDqM+O1tA/3bEfd1apm8LbEcR9CVgELTIspSVPMKM=";
|
||||
# NOTE: Needs to match the cava.wrap
|
||||
tag = "v${version}";
|
||||
hash = "sha256-IX1B375gTwVDRjpRfwKGuzTAZOV2pgDWzUd4bW2cTDU=";
|
||||
};
|
||||
};
|
||||
in
|
||||
(waybar.overrideAttrs (oldAttrs: {
|
||||
waybar.overrideAttrs (oldAttrs: {
|
||||
inherit version;
|
||||
|
||||
src = lib.cleanSourceWith {
|
||||
@@ -30,13 +31,12 @@ in
|
||||
# nixpkgs checks version, no need when building locally
|
||||
nativeInstallCheckInputs = [ ];
|
||||
|
||||
buildInputs = (builtins.filter (p:
|
||||
p.pname != "wireplumber" &&
|
||||
p.pname != "gps"
|
||||
) oldAttrs.buildInputs) ++ [
|
||||
pkgs.wireplumber
|
||||
pkgs.gpsd
|
||||
];
|
||||
buildInputs =
|
||||
(builtins.filter (p: p.pname != "wireplumber" && p.pname != "gps") oldAttrs.buildInputs)
|
||||
++ [
|
||||
pkgs.wireplumber
|
||||
pkgs.gpsd
|
||||
];
|
||||
|
||||
postUnpack = ''
|
||||
pushd "$sourceRoot"
|
||||
@@ -44,4 +44,4 @@ in
|
||||
patchShebangs .
|
||||
popd
|
||||
'';
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -63,7 +63,7 @@ button:hover {
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
#workspaces button.focused {
|
||||
#workspaces button.focused, #workspaces button.active {
|
||||
background-color: #64727D;
|
||||
box-shadow: inset 0 -3px #ffffff;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,8 @@ std::optional<std::string> getDesktopFilePath(const std::string& app_identifier,
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto data_dirs = Glib::get_system_data_dirs();
|
||||
auto data_dirs = Glib::get_system_data_dirs();
|
||||
data_dirs.insert(data_dirs.begin(), Glib::get_user_data_dir());
|
||||
for (const auto& data_dir : data_dirs) {
|
||||
const auto data_app_dir = data_dir + "/applications/";
|
||||
auto desktop_file_suffix = app_identifier + ".desktop";
|
||||
|
||||
@@ -36,10 +36,13 @@ AIconLabel::AIconLabel(const Json::Value &config, const std::string &name, const
|
||||
box_.set_spacing(spacing);
|
||||
|
||||
bool swap_icon_label = false;
|
||||
if (not config_["swap-icon-label"].isBool())
|
||||
spdlog::warn("'swap-icon-label' must be a bool.");
|
||||
else
|
||||
if (config_["swap-icon-label"].isNull()) {
|
||||
} else if (config_["swap-icon-label"].isBool()) {
|
||||
swap_icon_label = config_["swap-icon-label"].asBool();
|
||||
} else {
|
||||
spdlog::warn("'swap-icon-label' must be a bool, found '{}'. Using default value (false).",
|
||||
config_["swap-icon-label"].asString());
|
||||
}
|
||||
|
||||
if ((rot == 0 || rot == 3) ^ swap_icon_label) {
|
||||
box_.add(image_);
|
||||
|
||||
@@ -17,10 +17,17 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st
|
||||
config["format-alt"].isString() || config["menu"].isString() || enable_click,
|
||||
enable_scroll),
|
||||
format_(config_["format"].isString() ? config_["format"].asString() : format),
|
||||
|
||||
// Leave the default option outside of the std::max(1L, ...), because the zero value
|
||||
// (default) is used in modules/custom.cpp to make the difference between
|
||||
// two types of custom scripts. Fixes #4521.
|
||||
interval_(config_["interval"] == "once"
|
||||
? std::chrono::seconds::max()
|
||||
: std::chrono::seconds(
|
||||
config_["interval"].isUInt() ? config_["interval"].asUInt() : interval)),
|
||||
? std::chrono::milliseconds::max()
|
||||
: std::chrono::milliseconds(
|
||||
(config_["interval"].isNumeric()
|
||||
? std::max(1L, // Minimum 1ms due to millisecond precision
|
||||
static_cast<long>(config_["interval"].asDouble()) * 1000)
|
||||
: 1000 * (long)interval))),
|
||||
default_format_(format_) {
|
||||
label_.set_name(name);
|
||||
if (!id.empty()) {
|
||||
|
||||
@@ -172,6 +172,10 @@ bool AModule::handleUserEvent(GdkEventButton* const& e) {
|
||||
// Popup the menu
|
||||
gtk_widget_show_all(GTK_WIDGET(menu_));
|
||||
gtk_menu_popup_at_pointer(GTK_MENU(menu_), reinterpret_cast<GdkEvent*>(e));
|
||||
// Manually reset prelight to make sure the module doesn't stay in a hover state
|
||||
if (auto* module = event_box_.get_child(); module != nullptr) {
|
||||
module->unset_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Second call user scripts
|
||||
|
||||
13
src/bar.cpp
13
src/bar.cpp
@@ -433,7 +433,18 @@ void waybar::Bar::onMap(GdkEventAny* /*unused*/) {
|
||||
/*
|
||||
* Obtain a pointer to the custom layer surface for modules that require it (idle_inhibitor).
|
||||
*/
|
||||
auto* gdk_window = window.get_window()->gobj();
|
||||
auto gdk_window_ref = window.get_window();
|
||||
if (!gdk_window_ref) {
|
||||
spdlog::warn("Failed to get GDK window during onMap, deferring surface initialization");
|
||||
return;
|
||||
}
|
||||
|
||||
auto* gdk_window = gdk_window_ref->gobj();
|
||||
if (!gdk_window) {
|
||||
spdlog::warn("GDK window object is null during onMap, deferring surface initialization");
|
||||
return;
|
||||
}
|
||||
|
||||
surface = gdk_wayland_window_get_wl_surface(gdk_window);
|
||||
configureGlobalOffset(gdk_window_get_width(gdk_window), gdk_window_get_height(gdk_window));
|
||||
|
||||
|
||||
@@ -183,16 +183,24 @@ const std::string waybar::Client::getStyle(const std::string &style,
|
||||
};
|
||||
|
||||
auto waybar::Client::setupCss(const std::string &css_file) -> void {
|
||||
css_provider_ = Gtk::CssProvider::create();
|
||||
style_context_ = Gtk::StyleContext::create();
|
||||
auto screen = Gdk::Screen::get_default();
|
||||
if (!screen) {
|
||||
throw std::runtime_error("No default screen");
|
||||
}
|
||||
|
||||
// Load our css file, wherever that may be hiding
|
||||
if (css_provider_) {
|
||||
Gtk::StyleContext::remove_provider_for_screen(screen, css_provider_);
|
||||
css_provider_.reset();
|
||||
}
|
||||
|
||||
css_provider_ = Gtk::CssProvider::create();
|
||||
if (!css_provider_->load_from_path(css_file)) {
|
||||
css_provider_.reset();
|
||||
throw std::runtime_error("Can't open style file");
|
||||
}
|
||||
// there's always only one screen
|
||||
style_context_->add_provider_for_screen(Gdk::Screen::get_default(), css_provider_,
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
Gtk::StyleContext::add_provider_for_screen(screen, css_provider_,
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
}
|
||||
|
||||
void waybar::Client::bindInterfaces() {
|
||||
@@ -211,13 +219,22 @@ void waybar::Client::bindInterfaces() {
|
||||
if (xdg_output_manager == nullptr) {
|
||||
throw std::runtime_error("Failed to acquire required resources.");
|
||||
}
|
||||
|
||||
// Disconnect previous signal handlers to prevent duplicate handlers on reload
|
||||
monitor_added_connection_.disconnect();
|
||||
monitor_removed_connection_.disconnect();
|
||||
|
||||
// Clear stale outputs from previous run
|
||||
outputs_.clear();
|
||||
|
||||
// add existing outputs and subscribe to updates
|
||||
for (auto i = 0; i < gdk_display->get_n_monitors(); ++i) {
|
||||
auto monitor = gdk_display->get_monitor(i);
|
||||
handleMonitorAdded(monitor);
|
||||
}
|
||||
gdk_display->signal_monitor_added().connect(sigc::mem_fun(*this, &Client::handleMonitorAdded));
|
||||
gdk_display->signal_monitor_removed().connect(
|
||||
monitor_added_connection_ = gdk_display->signal_monitor_added().connect(
|
||||
sigc::mem_fun(*this, &Client::handleMonitorAdded));
|
||||
monitor_removed_connection_ = gdk_display->signal_monitor_removed().connect(
|
||||
sigc::mem_fun(*this, &Client::handleMonitorRemoved));
|
||||
}
|
||||
|
||||
|
||||
@@ -106,12 +106,24 @@ void Config::setupConfig(Json::Value &dst, const std::string &config_file, int d
|
||||
mergeConfig(dst, tmp_config);
|
||||
}
|
||||
|
||||
std::optional<std::string> Config::findIncludePath(const std::string &name) {
|
||||
std::vector<std::string> Config::findIncludePath(const std::string &name,
|
||||
const std::vector<std::string> &dirs) {
|
||||
auto match1 = tryExpandPath(name, "");
|
||||
if (!match1.empty()) {
|
||||
return match1.front();
|
||||
return match1;
|
||||
}
|
||||
return findConfigPath({name});
|
||||
if (const char *dir = std::getenv(Config::CONFIG_PATH_ENV)) {
|
||||
if (auto res = tryExpandPath(dir, name); !res.empty()) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
for (const auto &dir : dirs) {
|
||||
if (auto res = tryExpandPath(dir, name); !res.empty()) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void Config::resolveConfigIncludes(Json::Value &config, int depth) {
|
||||
@@ -119,18 +131,22 @@ void Config::resolveConfigIncludes(Json::Value &config, int depth) {
|
||||
if (includes.isArray()) {
|
||||
for (const auto &include : includes) {
|
||||
spdlog::info("Including resource file: {}", include.asString());
|
||||
auto match = findIncludePath(include.asString());
|
||||
if (match.has_value()) {
|
||||
setupConfig(config, match.value(), depth + 1);
|
||||
auto matches = findIncludePath(include.asString());
|
||||
if (!matches.empty()) {
|
||||
for (const auto &match : matches) {
|
||||
setupConfig(config, match, depth + 1);
|
||||
}
|
||||
} else {
|
||||
spdlog::warn("Unable to find resource file: {}", include.asString());
|
||||
}
|
||||
}
|
||||
} else if (includes.isString()) {
|
||||
spdlog::info("Including resource file: {}", includes.asString());
|
||||
auto match = findIncludePath(includes.asString());
|
||||
if (match.has_value()) {
|
||||
setupConfig(config, match.value(), depth + 1);
|
||||
auto matches = findIncludePath(includes.asString());
|
||||
if (!matches.empty()) {
|
||||
for (const auto &match : matches) {
|
||||
setupConfig(config, match, depth + 1);
|
||||
}
|
||||
} else {
|
||||
spdlog::warn("Unable to find resource file: {}", includes.asString());
|
||||
}
|
||||
|
||||
@@ -108,15 +108,13 @@
|
||||
#ifdef HAVE_LIBWIREPLUMBER
|
||||
#include "modules/wireplumber.hpp"
|
||||
#endif
|
||||
#ifdef HAVE_LIBCAVA
|
||||
#include "modules/cava.hpp"
|
||||
#endif
|
||||
#ifdef HAVE_SYSTEMD_MONITOR
|
||||
#include "modules/systemd_failed_units.hpp"
|
||||
#endif
|
||||
#ifdef HAVE_LIBGPS
|
||||
#include "modules/gps.hpp"
|
||||
#endif
|
||||
#include "modules/cava/cava_frontend.hpp"
|
||||
#include "modules/cffi.hpp"
|
||||
#include "modules/custom.hpp"
|
||||
#include "modules/image.hpp"
|
||||
@@ -341,11 +339,9 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
|
||||
return new waybar::modules::Wireplumber(id, config_[name]);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_LIBCAVA
|
||||
if (ref == "cava") {
|
||||
return new waybar::modules::Cava(id, config_[name]);
|
||||
return waybar::modules::cava::getModule(id, config_[name]);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_SYSTEMD_MONITOR
|
||||
if (ref == "systemd-failed-units") {
|
||||
return new waybar::modules::SystemdFailedUnits(id, config_[name]);
|
||||
|
||||
@@ -26,7 +26,7 @@ Gtk::RevealerTransitionType getPreferredTransitionType(bool is_vertical) {
|
||||
|
||||
Group::Group(const std::string& name, const std::string& id, const Json::Value& config,
|
||||
bool vertical)
|
||||
: AModule(config, name, id, true, true),
|
||||
: AModule(config, name, id, true, false),
|
||||
box{vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0},
|
||||
revealer_box{vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0} {
|
||||
box.set_name(name_);
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#include <libudev.h>
|
||||
#include <poll.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <sys/signalfd.h>
|
||||
|
||||
waybar::modules::Battery::Battery(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
: ALabel(config, "battery", id, "{capacity}%", 60), last_event_(""), bar_(bar) {
|
||||
@@ -16,17 +19,21 @@ waybar::modules::Battery::Battery(const std::string& id, const Bar& bar, const J
|
||||
if (battery_watch_fd_ == -1) {
|
||||
throw std::runtime_error("Unable to listen batteries.");
|
||||
}
|
||||
|
||||
global_watch_fd_ = inotify_init1(IN_CLOEXEC);
|
||||
if (global_watch_fd_ == -1) {
|
||||
throw std::runtime_error("Unable to listen batteries.");
|
||||
udev_ = std::unique_ptr<udev, util::UdevDeleter>(udev_new());
|
||||
if (udev_ == nullptr) {
|
||||
throw std::runtime_error("udev_new failed");
|
||||
}
|
||||
|
||||
// Watch the directory for any added or removed batteries
|
||||
global_watch = inotify_add_watch(global_watch_fd_, data_dir_.c_str(), IN_CREATE | IN_DELETE);
|
||||
if (global_watch < 0) {
|
||||
throw std::runtime_error("Could not watch for battery plug/unplug");
|
||||
mon_ = std::unique_ptr<udev_monitor, util::UdevMonitorDeleter>(
|
||||
udev_monitor_new_from_netlink(udev_.get(), "kernel"));
|
||||
if (mon_ == nullptr) {
|
||||
throw std::runtime_error("udev monitor new failed");
|
||||
}
|
||||
if (udev_monitor_filter_add_match_subsystem_devtype(mon_.get(), "power_supply", nullptr) < 0) {
|
||||
throw std::runtime_error("udev failed to add monitor filter");
|
||||
}
|
||||
udev_monitor_enable_receiving(mon_.get());
|
||||
|
||||
if (config_["weighted-average"].isBool()) weightedAverage_ = config_["weighted-average"].asBool();
|
||||
#endif
|
||||
spdlog::debug("battery: worker interval is {}", interval_.count());
|
||||
worker();
|
||||
@@ -36,11 +43,6 @@ waybar::modules::Battery::~Battery() {
|
||||
#if defined(__linux__)
|
||||
std::lock_guard<std::mutex> guard(battery_list_mutex_);
|
||||
|
||||
if (global_watch >= 0) {
|
||||
inotify_rm_watch(global_watch_fd_, global_watch);
|
||||
}
|
||||
close(global_watch_fd_);
|
||||
|
||||
for (auto it = batteries_.cbegin(), next_it = it; it != batteries_.cend(); it = next_it) {
|
||||
++next_it;
|
||||
auto watch_id = (*it).second;
|
||||
@@ -77,12 +79,18 @@ void waybar::modules::Battery::worker() {
|
||||
dp.emit();
|
||||
};
|
||||
thread_battery_update_ = [this] {
|
||||
struct inotify_event event = {0};
|
||||
int nbytes = read(global_watch_fd_, &event, sizeof(event));
|
||||
if (nbytes != sizeof(event) || event.mask & IN_IGNORED) {
|
||||
poll_fds_[0].revents = 0;
|
||||
poll_fds_[0].events = POLLIN;
|
||||
poll_fds_[0].fd = udev_monitor_get_fd(mon_.get());
|
||||
int ret = poll(poll_fds_.data(), poll_fds_.size(), -1);
|
||||
if (ret < 0) {
|
||||
thread_.stop();
|
||||
return;
|
||||
}
|
||||
if ((poll_fds_[0].revents & POLLIN) != 0) {
|
||||
signalfd_siginfo signal_info;
|
||||
read(poll_fds_[0].fd, &signal_info, sizeof(signal_info));
|
||||
}
|
||||
refreshBatteries();
|
||||
dp.emit();
|
||||
};
|
||||
@@ -585,8 +593,7 @@ waybar::modules::Battery::getInfos() {
|
||||
}
|
||||
|
||||
// Handle weighted-average
|
||||
if ((config_["weighted-average"].isBool() ? config_["weighted-average"].asBool() : false) &&
|
||||
total_energy_exists && total_energy_full_exists) {
|
||||
if (weightedAverage_ && total_energy_exists && total_energy_full_exists) {
|
||||
if (total_energy_full > 0.0f)
|
||||
calculated_capacity = ((float)total_energy * 100.0f / (float)total_energy_full);
|
||||
}
|
||||
@@ -679,6 +686,7 @@ auto waybar::modules::Battery::update() -> void {
|
||||
status = getAdapterStatus(capacity);
|
||||
}
|
||||
auto status_pretty = status;
|
||||
puts(status.c_str());
|
||||
// Transform to lowercase and replace space with dash
|
||||
std::ranges::transform(status.begin(), status.end(), status.begin(),
|
||||
[](char ch) { return ch == ' ' ? '-' : std::tolower(ch); });
|
||||
|
||||
@@ -1,211 +0,0 @@
|
||||
#include "modules/cava.hpp"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
waybar::modules::Cava::Cava(const std::string& id, const Json::Value& config)
|
||||
: ALabel(config, "cava", id, "{}", 60, false, false, false) {
|
||||
// Load waybar module config
|
||||
char cfgPath[PATH_MAX];
|
||||
cfgPath[0] = '\0';
|
||||
|
||||
if (config_["cava_config"].isString()) strcpy(cfgPath, config_["cava_config"].asString().data());
|
||||
// Load cava config
|
||||
error_.length = 0;
|
||||
|
||||
if (!load_config(cfgPath, &prm_, false, &error_)) {
|
||||
spdlog::error("Error loading config. {0}", error_.message);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Override cava parameters by the user config
|
||||
prm_.inAtty = 0;
|
||||
prm_.output = cava::output_method::OUTPUT_RAW;
|
||||
strcpy(prm_.data_format, "ascii");
|
||||
strcpy(prm_.raw_target, "/dev/stdout");
|
||||
prm_.ascii_range = config_["format-icons"].size() - 1;
|
||||
|
||||
prm_.bar_width = 2;
|
||||
prm_.bar_spacing = 0;
|
||||
prm_.bar_height = 32;
|
||||
prm_.bar_width = 1;
|
||||
prm_.orientation = cava::ORIENT_TOP;
|
||||
prm_.xaxis = cava::xaxis_scale::NONE;
|
||||
prm_.mono_opt = cava::AVERAGE;
|
||||
prm_.autobars = 0;
|
||||
prm_.gravity = 0;
|
||||
prm_.integral = 1;
|
||||
|
||||
if (config_["framerate"].isInt()) prm_.framerate = config_["framerate"].asInt();
|
||||
if (config_["autosens"].isInt()) prm_.autosens = config_["autosens"].asInt();
|
||||
if (config_["sensitivity"].isInt()) prm_.sens = config_["sensitivity"].asInt();
|
||||
if (config_["bars"].isInt()) prm_.fixedbars = config_["bars"].asInt();
|
||||
if (config_["lower_cutoff_freq"].isNumeric())
|
||||
prm_.lower_cut_off = config_["lower_cutoff_freq"].asLargestInt();
|
||||
if (config_["higher_cutoff_freq"].isNumeric())
|
||||
prm_.upper_cut_off = config_["higher_cutoff_freq"].asLargestInt();
|
||||
if (config_["sleep_timer"].isInt()) prm_.sleep_timer = config_["sleep_timer"].asInt();
|
||||
if (config_["method"].isString())
|
||||
prm_.input = cava::input_method_by_name(config_["method"].asString().c_str());
|
||||
if (config_["source"].isString()) prm_.audio_source = config_["source"].asString().data();
|
||||
if (config_["sample_rate"].isNumeric()) prm_.samplerate = config_["sample_rate"].asLargestInt();
|
||||
if (config_["sample_bits"].isInt()) prm_.samplebits = config_["sample_bits"].asInt();
|
||||
if (config_["stereo"].isBool()) prm_.stereo = config_["stereo"].asBool();
|
||||
if (config_["reverse"].isBool()) prm_.reverse = config_["reverse"].asBool();
|
||||
if (config_["bar_delimiter"].isInt()) prm_.bar_delim = config_["bar_delimiter"].asInt();
|
||||
if (config_["monstercat"].isBool()) prm_.monstercat = config_["monstercat"].asBool();
|
||||
if (config_["waves"].isBool()) prm_.waves = config_["waves"].asBool();
|
||||
if (config_["noise_reduction"].isDouble())
|
||||
prm_.noise_reduction = config_["noise_reduction"].asDouble();
|
||||
if (config_["input_delay"].isInt())
|
||||
fetch_input_delay_ = std::chrono::seconds(config_["input_delay"].asInt());
|
||||
if (config_["hide_on_silence"].isBool()) hide_on_silence_ = config_["hide_on_silence"].asBool();
|
||||
if (config_["format_silent"].isString()) format_silent_ = config_["format_silent"].asString();
|
||||
// Make cava parameters configuration
|
||||
plan_ = new cava::cava_plan{};
|
||||
|
||||
audio_raw_.height = prm_.ascii_range;
|
||||
audio_data_.format = -1;
|
||||
audio_data_.source = new char[1 + strlen(prm_.audio_source)];
|
||||
audio_data_.source[0] = '\0';
|
||||
strcpy(audio_data_.source, prm_.audio_source);
|
||||
|
||||
audio_data_.rate = 0;
|
||||
audio_data_.samples_counter = 0;
|
||||
audio_data_.channels = 2;
|
||||
audio_data_.IEEE_FLOAT = 0;
|
||||
|
||||
audio_data_.input_buffer_size = BUFFER_SIZE * audio_data_.channels;
|
||||
audio_data_.cava_buffer_size = audio_data_.input_buffer_size * 8;
|
||||
|
||||
audio_data_.cava_in = new double[audio_data_.cava_buffer_size]{0.0};
|
||||
|
||||
audio_data_.terminate = 0;
|
||||
audio_data_.suspendFlag = false;
|
||||
input_source_ = get_input(&audio_data_, &prm_);
|
||||
|
||||
if (!input_source_) {
|
||||
spdlog::error("cava API didn't provide input audio source method");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Calculate delay for Update() thread
|
||||
frame_time_milsec_ = std::chrono::milliseconds((int)(1e3 / prm_.framerate));
|
||||
|
||||
// Init cava plan, audio_raw structure
|
||||
audio_raw_init(&audio_data_, &audio_raw_, &prm_, plan_);
|
||||
if (!plan_) spdlog::error("cava plan is not provided");
|
||||
audio_raw_.previous_frame[0] = -1; // For first Update() call need to rePaint text message
|
||||
// Read audio source trough cava API. Cava orginizes this process via infinity loop
|
||||
thread_fetch_input_ = [this] {
|
||||
thread_fetch_input_.sleep_for(fetch_input_delay_);
|
||||
input_source_(&audio_data_);
|
||||
};
|
||||
|
||||
thread_ = [this] {
|
||||
dp.emit();
|
||||
thread_.sleep_for(frame_time_milsec_);
|
||||
};
|
||||
}
|
||||
|
||||
waybar::modules::Cava::~Cava() {
|
||||
thread_fetch_input_.stop();
|
||||
thread_.stop();
|
||||
delete plan_;
|
||||
plan_ = nullptr;
|
||||
}
|
||||
|
||||
void upThreadDelay(std::chrono::milliseconds& delay, std::chrono::seconds& delta) {
|
||||
if (delta == std::chrono::seconds{0}) {
|
||||
delta += std::chrono::seconds{1};
|
||||
delay += delta;
|
||||
}
|
||||
}
|
||||
|
||||
void downThreadDelay(std::chrono::milliseconds& delay, std::chrono::seconds& delta) {
|
||||
if (delta > std::chrono::seconds{0}) {
|
||||
delay -= delta;
|
||||
delta -= std::chrono::seconds{1};
|
||||
}
|
||||
}
|
||||
|
||||
auto waybar::modules::Cava::update() -> void {
|
||||
if (audio_data_.suspendFlag) return;
|
||||
silence_ = true;
|
||||
|
||||
for (int i{0}; i < audio_data_.input_buffer_size; ++i) {
|
||||
if (audio_data_.cava_in[i]) {
|
||||
silence_ = false;
|
||||
sleep_counter_ = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (silence_ && prm_.sleep_timer != 0) {
|
||||
if (sleep_counter_ <=
|
||||
(int)(std::chrono::milliseconds(prm_.sleep_timer * 1s) / frame_time_milsec_)) {
|
||||
++sleep_counter_;
|
||||
silence_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!silence_ || prm_.sleep_timer == 0) {
|
||||
downThreadDelay(frame_time_milsec_, suspend_silence_delay_);
|
||||
// Process: execute cava
|
||||
pthread_mutex_lock(&audio_data_.lock);
|
||||
cava::cava_execute(audio_data_.cava_in, audio_data_.samples_counter, audio_raw_.cava_out,
|
||||
plan_);
|
||||
if (audio_data_.samples_counter > 0) audio_data_.samples_counter = 0;
|
||||
pthread_mutex_unlock(&audio_data_.lock);
|
||||
|
||||
// Do transformation under raw data
|
||||
audio_raw_fetch(&audio_raw_, &prm_, &rePaint_, plan_);
|
||||
|
||||
if (rePaint_ == 1) {
|
||||
text_.clear();
|
||||
|
||||
for (int i{0}; i < audio_raw_.number_of_bars; ++i) {
|
||||
audio_raw_.previous_frame[i] = audio_raw_.bars[i];
|
||||
text_.append(
|
||||
getIcon((audio_raw_.bars[i] > prm_.ascii_range) ? prm_.ascii_range : audio_raw_.bars[i],
|
||||
"", prm_.ascii_range + 1));
|
||||
if (prm_.bar_delim != 0) text_.push_back(prm_.bar_delim);
|
||||
}
|
||||
|
||||
label_.set_markup(text_);
|
||||
label_.show();
|
||||
ALabel::update();
|
||||
label_.get_style_context()->add_class("updated");
|
||||
}
|
||||
|
||||
label_.get_style_context()->remove_class("silent");
|
||||
} else {
|
||||
upThreadDelay(frame_time_milsec_, suspend_silence_delay_);
|
||||
if (hide_on_silence_)
|
||||
label_.hide();
|
||||
else if (config_["format_silent"].isString())
|
||||
label_.set_markup(format_silent_);
|
||||
|
||||
label_.get_style_context()->add_class("silent");
|
||||
label_.get_style_context()->remove_class("updated");
|
||||
}
|
||||
}
|
||||
|
||||
auto waybar::modules::Cava::doAction(const std::string& name) -> void {
|
||||
if ((actionMap_[name])) {
|
||||
(this->*actionMap_[name])();
|
||||
} else
|
||||
spdlog::error("Cava. Unsupported action \"{0}\"", name);
|
||||
}
|
||||
|
||||
// Cava actions
|
||||
void waybar::modules::Cava::pause_resume() {
|
||||
pthread_mutex_lock(&audio_data_.lock);
|
||||
if (audio_data_.suspendFlag) {
|
||||
audio_data_.suspendFlag = false;
|
||||
pthread_cond_broadcast(&audio_data_.resumeCond);
|
||||
downThreadDelay(frame_time_milsec_, suspend_silence_delay_);
|
||||
} else {
|
||||
audio_data_.suspendFlag = true;
|
||||
upThreadDelay(frame_time_milsec_, suspend_silence_delay_);
|
||||
}
|
||||
pthread_mutex_unlock(&audio_data_.lock);
|
||||
}
|
||||
271
src/modules/cava/cavaGLSL.cpp
Normal file
271
src/modules/cava/cavaGLSL.cpp
Normal file
@@ -0,0 +1,271 @@
|
||||
#include "modules/cava/cavaGLSL.hpp"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
waybar::modules::cava::CavaGLSL::CavaGLSL(const std::string& id, const Json::Value& config)
|
||||
: AModule(config, "cavaGLSL", id, false, false),
|
||||
backend_{waybar::modules::cava::CavaBackend::inst(config)} {
|
||||
set_name(name_);
|
||||
if (config_["hide_on_silence"].isBool()) hide_on_silence_ = config_["hide_on_silence"].asBool();
|
||||
if (!id.empty()) {
|
||||
get_style_context()->add_class(id);
|
||||
}
|
||||
get_style_context()->add_class(MODULE_CLASS);
|
||||
|
||||
set_use_es(true);
|
||||
// set_auto_render(true);
|
||||
signal_realize().connect(sigc::mem_fun(*this, &CavaGLSL::onRealize));
|
||||
signal_render().connect(sigc::mem_fun(*this, &CavaGLSL::onRender), false);
|
||||
|
||||
// Get parameters_config struct from the backend
|
||||
prm_ = *backend_->getPrm();
|
||||
|
||||
// Set widget length
|
||||
int length{0};
|
||||
if (config_["min-length"].isUInt())
|
||||
length = config_["min-length"].asUInt();
|
||||
else if (config_["max-length"].isUInt())
|
||||
length = config_["max-length"].asUInt();
|
||||
else
|
||||
length = prm_.sdl_width;
|
||||
|
||||
set_size_request(length, prm_.sdl_height);
|
||||
|
||||
// Subscribe for changes
|
||||
backend_->signal_audio_raw_update().connect(sigc::mem_fun(*this, &CavaGLSL::onUpdate));
|
||||
// Subscribe for silence
|
||||
backend_->signal_silence().connect(sigc::mem_fun(*this, &CavaGLSL::onSilence));
|
||||
event_box_.add(*this);
|
||||
}
|
||||
|
||||
auto waybar::modules::cava::CavaGLSL::onUpdate(const ::cava::audio_raw& input) -> void {
|
||||
Glib::signal_idle().connect_once([this, input]() {
|
||||
m_data_ = std::make_shared<::cava::audio_raw>(input);
|
||||
if (silence_) {
|
||||
get_style_context()->remove_class("silent");
|
||||
if (!get_style_context()->has_class("updated")) get_style_context()->add_class("updated");
|
||||
show();
|
||||
silence_ = false;
|
||||
}
|
||||
|
||||
queue_render();
|
||||
});
|
||||
}
|
||||
|
||||
auto waybar::modules::cava::CavaGLSL::onSilence() -> void {
|
||||
Glib::signal_idle().connect_once([this]() {
|
||||
if (!silence_) {
|
||||
if (get_style_context()->has_class("updated")) get_style_context()->remove_class("updated");
|
||||
|
||||
if (hide_on_silence_) hide();
|
||||
silence_ = true;
|
||||
get_style_context()->add_class("silent");
|
||||
// Set clear color to black
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
queue_render();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool waybar::modules::cava::CavaGLSL::onRender(const Glib::RefPtr<Gdk::GLContext>& context) {
|
||||
if (!m_data_) return true;
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture_);
|
||||
glUniform1i(glGetUniformLocation(shaderProgram_, "inputTexture"), 0);
|
||||
|
||||
glUniform1fv(uniform_bars_, m_data_->number_of_bars, m_data_->bars_raw);
|
||||
glUniform1fv(uniform_previous_bars_, m_data_->number_of_bars, m_data_->previous_bars_raw);
|
||||
glUniform1i(uniform_bars_count_, m_data_->number_of_bars);
|
||||
++frame_counter;
|
||||
glUniform1f(uniform_time_, (frame_counter / backend_->getFrameTimeMilsec().count()) / 1e3);
|
||||
|
||||
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_INT, nullptr);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo_);
|
||||
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_INT, nullptr);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void waybar::modules::cava::CavaGLSL::onRealize() {
|
||||
make_current();
|
||||
initShaders();
|
||||
initGLSL();
|
||||
initSurface();
|
||||
}
|
||||
|
||||
struct colors {
|
||||
uint16_t R;
|
||||
uint16_t G;
|
||||
uint16_t B;
|
||||
};
|
||||
|
||||
static void parse_color(char* color_string, struct colors* color) {
|
||||
if (color_string[0] == '#') {
|
||||
sscanf(++color_string, "%02hx%02hx%02hx", &color->R, &color->G, &color->B);
|
||||
}
|
||||
}
|
||||
|
||||
void waybar::modules::cava::CavaGLSL::initGLSL() {
|
||||
GLint gVertexPos2DLocation{glGetAttribLocation(shaderProgram_, "vertexPosition_modelspace")};
|
||||
if (gVertexPos2DLocation == -1) {
|
||||
spdlog::error("{0}. Could not find vertex position shader variable", name_);
|
||||
}
|
||||
|
||||
glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||
|
||||
GLfloat vertexData[]{-1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f};
|
||||
GLint indexData[]{0, 1, 2, 3};
|
||||
|
||||
GLuint gVBO{0};
|
||||
glGenBuffers(1, &gVBO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, gVBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, 2 * 4 * sizeof(GLfloat), vertexData, GL_STATIC_DRAW);
|
||||
|
||||
GLuint gIBO{0};
|
||||
glGenBuffers(1, &gIBO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gIBO);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 4 * sizeof(GLuint), indexData, GL_STATIC_DRAW);
|
||||
|
||||
GLuint gVAO{0};
|
||||
glGenVertexArrays(1, &gVAO);
|
||||
glBindVertexArray(gVAO);
|
||||
glEnableVertexAttribArray(gVertexPos2DLocation);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, gVBO);
|
||||
glVertexAttribPointer(gVertexPos2DLocation, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), nullptr);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gIBO);
|
||||
|
||||
glGenFramebuffers(1, &fbo_);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo_);
|
||||
|
||||
// Create a texture to attach the framebuffer
|
||||
glGenTextures(1, &texture_);
|
||||
glBindTexture(GL_TEXTURE_2D, texture_);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, prm_.sdl_width, prm_.sdl_height, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, nullptr);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_, 0);
|
||||
|
||||
// Check is framebuffer is complete
|
||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||
spdlog::error("{0}. Framebuffer not complete", name_);
|
||||
}
|
||||
|
||||
// Unbind the framebuffer
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
uniform_bars_ = glGetUniformLocation(shaderProgram_, "bars");
|
||||
uniform_previous_bars_ = glGetUniformLocation(shaderProgram_, "previous_bars");
|
||||
uniform_bars_count_ = glGetUniformLocation(shaderProgram_, "bars_count");
|
||||
uniform_time_ = glGetUniformLocation(shaderProgram_, "shader_time");
|
||||
|
||||
GLuint err{glGetError()};
|
||||
if (err != 0) {
|
||||
spdlog::error("{0}. Error on initGLSL: {1}", name_, err);
|
||||
}
|
||||
}
|
||||
|
||||
void waybar::modules::cava::CavaGLSL::initSurface() {
|
||||
colors color = {0};
|
||||
GLint uniform_bg_col{glGetUniformLocation(shaderProgram_, "bg_color")};
|
||||
parse_color(prm_.bcolor, &color);
|
||||
glUniform3f(uniform_bg_col, (float)color.R / 255.0, (float)color.G / 255.0,
|
||||
(float)color.B / 255.0);
|
||||
GLint uniform_fg_col{glGetUniformLocation(shaderProgram_, "fg_color")};
|
||||
parse_color(prm_.color, &color);
|
||||
glUniform3f(uniform_fg_col, (float)color.R / 255.0, (float)color.G / 255.0,
|
||||
(float)color.B / 255.0);
|
||||
GLint uniform_res{glGetUniformLocation(shaderProgram_, "u_resolution")};
|
||||
glUniform3f(uniform_res, (float)prm_.sdl_width, (float)prm_.sdl_height, 0.0f);
|
||||
GLint uniform_bar_width{glGetUniformLocation(shaderProgram_, "bar_width")};
|
||||
glUniform1i(uniform_bar_width, prm_.bar_width);
|
||||
GLint uniform_bar_spacing{glGetUniformLocation(shaderProgram_, "bar_spacing")};
|
||||
glUniform1i(uniform_bar_spacing, prm_.bar_spacing);
|
||||
GLint uniform_gradient_count{glGetUniformLocation(shaderProgram_, "gradient_count")};
|
||||
glUniform1i(uniform_gradient_count, prm_.gradient_count);
|
||||
GLint uniform_gradient_colors{glGetUniformLocation(shaderProgram_, "gradient_colors")};
|
||||
GLfloat gradient_colors[8][3];
|
||||
for (int i{0}; i < prm_.gradient_count; ++i) {
|
||||
parse_color(prm_.gradient_colors[i], &color);
|
||||
gradient_colors[i][0] = (float)color.R / 255.0;
|
||||
gradient_colors[i][1] = (float)color.G / 255.0;
|
||||
gradient_colors[i][2] = (float)color.B / 255.0;
|
||||
}
|
||||
glUniform3fv(uniform_gradient_colors, 8, (const GLfloat*)gradient_colors);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_INT, nullptr);
|
||||
}
|
||||
|
||||
void waybar::modules::cava::CavaGLSL::initShaders() {
|
||||
shaderProgram_ = glCreateProgram();
|
||||
|
||||
GLuint vertexShader{loadShader(prm_.vertex_shader, GL_VERTEX_SHADER)};
|
||||
GLuint fragmentShader{loadShader(prm_.fragment_shader, GL_FRAGMENT_SHADER)};
|
||||
|
||||
glAttachShader(shaderProgram_, vertexShader);
|
||||
glAttachShader(shaderProgram_, fragmentShader);
|
||||
|
||||
glLinkProgram(shaderProgram_);
|
||||
|
||||
glDeleteShader(vertexShader);
|
||||
glDeleteShader(fragmentShader);
|
||||
|
||||
// Check for linking errors
|
||||
GLint success, len;
|
||||
glGetProgramiv(shaderProgram_, GL_LINK_STATUS, &success);
|
||||
if (!success) {
|
||||
glGetProgramiv(shaderProgram_, GL_INFO_LOG_LENGTH, &len);
|
||||
GLchar* infoLog{(char*)'\0'};
|
||||
glGetProgramInfoLog(shaderProgram_, len, &len, infoLog);
|
||||
spdlog::error("{0}. Shader linking error: {1}", name_, infoLog);
|
||||
}
|
||||
|
||||
glReleaseShaderCompiler();
|
||||
glUseProgram(shaderProgram_);
|
||||
}
|
||||
|
||||
GLuint waybar::modules::cava::CavaGLSL::loadShader(const std::string& fileName, GLenum type) {
|
||||
spdlog::debug("{0}. loadShader: {1}", name_, fileName);
|
||||
|
||||
// Read shader source code from the file
|
||||
std::ifstream shaderFile{fileName};
|
||||
|
||||
if (!shaderFile.is_open()) {
|
||||
spdlog::error("{0}. Could not open shader file: {1}", name_, fileName);
|
||||
}
|
||||
|
||||
std::ostringstream buffer;
|
||||
buffer << shaderFile.rdbuf(); // read file content into stringstream
|
||||
std::string str{buffer.str()};
|
||||
const char* shaderSource = str.c_str();
|
||||
shaderFile.close();
|
||||
|
||||
GLuint shaderID{glCreateShader(type)};
|
||||
if (shaderID == 0) spdlog::error("{0}. Error creating shader type: {0}", type);
|
||||
glShaderSource(shaderID, 1, &shaderSource, nullptr);
|
||||
glCompileShader(shaderID);
|
||||
|
||||
// Check for compilation errors
|
||||
GLint success, len;
|
||||
|
||||
glGetShaderiv(shaderID, GL_COMPILE_STATUS, &success);
|
||||
|
||||
if (!success) {
|
||||
glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &len);
|
||||
|
||||
GLchar* infoLog{(char*)'\0'};
|
||||
glGetShaderInfoLog(shaderID, len, nullptr, infoLog);
|
||||
spdlog::error("{0}. Shader compilation error in {1}: {2}", name_, fileName, infoLog);
|
||||
}
|
||||
|
||||
return shaderID;
|
||||
}
|
||||
58
src/modules/cava/cavaRaw.cpp
Normal file
58
src/modules/cava/cavaRaw.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "modules/cava/cavaRaw.hpp"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
waybar::modules::cava::Cava::Cava(const std::string& id, const Json::Value& config)
|
||||
: ALabel(config, "cava", id, "{}", 60, false, false, false),
|
||||
backend_{waybar::modules::cava::CavaBackend::inst(config)} {
|
||||
if (config_["hide_on_silence"].isBool()) hide_on_silence_ = config_["hide_on_silence"].asBool();
|
||||
if (config_["format_silent"].isString()) format_silent_ = config_["format_silent"].asString();
|
||||
|
||||
ascii_range_ = backend_->getAsciiRange();
|
||||
backend_->signal_update().connect(sigc::mem_fun(*this, &Cava::onUpdate));
|
||||
backend_->signal_silence().connect(sigc::mem_fun(*this, &Cava::onSilence));
|
||||
backend_->Update();
|
||||
}
|
||||
|
||||
auto waybar::modules::cava::Cava::doAction(const std::string& name) -> void {
|
||||
if ((actionMap_[name])) {
|
||||
(this->*actionMap_[name])();
|
||||
} else
|
||||
spdlog::error("Cava. Unsupported action \"{0}\"", name);
|
||||
}
|
||||
|
||||
// Cava actions
|
||||
void waybar::modules::cava::Cava::pause_resume() { backend_->doPauseResume(); }
|
||||
auto waybar::modules::cava::Cava::onUpdate(const std::string& input) -> void {
|
||||
Glib::signal_idle().connect_once([this, input]() {
|
||||
if (silence_) {
|
||||
label_.get_style_context()->remove_class("silent");
|
||||
if (!label_.get_style_context()->has_class("updated"))
|
||||
label_.get_style_context()->add_class("updated");
|
||||
}
|
||||
label_text_.clear();
|
||||
for (auto& ch : input)
|
||||
label_text_.append(getIcon((ch > ascii_range_) ? ascii_range_ : ch, "", ascii_range_ + 1));
|
||||
|
||||
label_.set_markup(label_text_);
|
||||
label_.show();
|
||||
ALabel::update();
|
||||
});
|
||||
silence_ = false;
|
||||
}
|
||||
|
||||
auto waybar::modules::cava::Cava::onSilence() -> void {
|
||||
Glib::signal_idle().connect_once([this]() {
|
||||
if (!silence_) {
|
||||
if (label_.get_style_context()->has_class("updated"))
|
||||
label_.get_style_context()->remove_class("updated");
|
||||
|
||||
if (hide_on_silence_)
|
||||
label_.hide();
|
||||
else if (config_["format_silent"].isString())
|
||||
label_.set_markup(format_silent_);
|
||||
silence_ = true;
|
||||
label_.get_style_context()->add_class("silent");
|
||||
}
|
||||
});
|
||||
}
|
||||
273
src/modules/cava/cava_backend.cpp
Normal file
273
src/modules/cava/cava_backend.cpp
Normal file
@@ -0,0 +1,273 @@
|
||||
#include "modules/cava/cava_backend.hpp"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
std::shared_ptr<waybar::modules::cava::CavaBackend> waybar::modules::cava::CavaBackend::inst(
|
||||
const Json::Value& config) {
|
||||
static auto* backend = new CavaBackend(config);
|
||||
static std::shared_ptr<CavaBackend> backend_ptr{backend};
|
||||
return backend_ptr;
|
||||
}
|
||||
|
||||
waybar::modules::cava::CavaBackend::CavaBackend(const Json::Value& config) : config_(config) {
|
||||
// Load waybar module config
|
||||
loadConfig();
|
||||
// Read audio source trough cava API. Cava orginizes this process via infinity loop
|
||||
read_thread_ = [this] {
|
||||
try {
|
||||
input_source_(&audio_data_);
|
||||
} catch (const std::runtime_error& e) {
|
||||
spdlog::warn("Cava backend. Read source error: {0}", e.what());
|
||||
}
|
||||
read_thread_.sleep_for(fetch_input_delay_);
|
||||
loadConfig();
|
||||
};
|
||||
// Write outcoming data. Emit signals
|
||||
out_thread_ = [this] {
|
||||
doUpdate(false);
|
||||
out_thread_.sleep_for(frame_time_milsec_);
|
||||
};
|
||||
}
|
||||
|
||||
waybar::modules::cava::CavaBackend::~CavaBackend() {
|
||||
out_thread_.stop();
|
||||
read_thread_.stop();
|
||||
|
||||
freeBackend();
|
||||
}
|
||||
|
||||
static bool upThreadDelay(std::chrono::milliseconds& delay, std::chrono::seconds& delta) {
|
||||
if (delta == std::chrono::seconds{0}) {
|
||||
delta += std::chrono::seconds{1};
|
||||
delay += delta;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool downThreadDelay(std::chrono::milliseconds& delay, std::chrono::seconds& delta) {
|
||||
if (delta > std::chrono::seconds{0}) {
|
||||
delay -= delta;
|
||||
delta -= std::chrono::seconds{1};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool waybar::modules::cava::CavaBackend::isSilence() {
|
||||
for (int i{0}; i < audio_data_.input_buffer_size; ++i) {
|
||||
if (audio_data_.cava_in[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int waybar::modules::cava::CavaBackend::getAsciiRange() { return prm_.ascii_range; }
|
||||
|
||||
// Process: execute cava
|
||||
void waybar::modules::cava::CavaBackend::invoke() {
|
||||
pthread_mutex_lock(&audio_data_.lock);
|
||||
::cava::cava_execute(audio_data_.cava_in, audio_data_.samples_counter, audio_raw_.cava_out,
|
||||
plan_);
|
||||
if (audio_data_.samples_counter > 0) audio_data_.samples_counter = 0;
|
||||
pthread_mutex_unlock(&audio_data_.lock);
|
||||
}
|
||||
|
||||
// Do transformation under raw data
|
||||
void waybar::modules::cava::CavaBackend::execute() {
|
||||
invoke();
|
||||
audio_raw_fetch(&audio_raw_, &prm_, &re_paint_, plan_);
|
||||
|
||||
if (re_paint_ == 1) {
|
||||
output_.clear();
|
||||
for (int i{0}; i < audio_raw_.number_of_bars; ++i) {
|
||||
audio_raw_.previous_frame[i] = audio_raw_.bars[i];
|
||||
output_.push_back(audio_raw_.bars[i]);
|
||||
if (prm_.bar_delim != 0) output_.push_back(prm_.bar_delim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void waybar::modules::cava::CavaBackend::doPauseResume() {
|
||||
pthread_mutex_lock(&audio_data_.lock);
|
||||
if (audio_data_.suspendFlag) {
|
||||
audio_data_.suspendFlag = false;
|
||||
pthread_cond_broadcast(&audio_data_.resumeCond);
|
||||
downThreadDelay(frame_time_milsec_, suspend_silence_delay_);
|
||||
} else {
|
||||
audio_data_.suspendFlag = true;
|
||||
upThreadDelay(frame_time_milsec_, suspend_silence_delay_);
|
||||
}
|
||||
pthread_mutex_unlock(&audio_data_.lock);
|
||||
Update();
|
||||
}
|
||||
|
||||
waybar::modules::cava::CavaBackend::type_signal_update
|
||||
waybar::modules::cava::CavaBackend::signal_update() {
|
||||
return m_signal_update_;
|
||||
}
|
||||
|
||||
waybar::modules::cava::CavaBackend::type_signal_audio_raw_update
|
||||
waybar::modules::cava::CavaBackend::signal_audio_raw_update() {
|
||||
return m_signal_audio_raw_;
|
||||
}
|
||||
|
||||
waybar::modules::cava::CavaBackend::type_signal_silence
|
||||
waybar::modules::cava::CavaBackend::signal_silence() {
|
||||
return m_signal_silence_;
|
||||
}
|
||||
|
||||
void waybar::modules::cava::CavaBackend::Update() { doUpdate(true); }
|
||||
|
||||
void waybar::modules::cava::CavaBackend::doUpdate(bool force) {
|
||||
if (audio_data_.suspendFlag && !force) return;
|
||||
|
||||
silence_ = isSilence();
|
||||
if (!silence_) sleep_counter_ = 0;
|
||||
|
||||
if (silence_ && prm_.sleep_timer != 0) {
|
||||
if (sleep_counter_ <=
|
||||
(int)(std::chrono::milliseconds(prm_.sleep_timer * 1s) / frame_time_milsec_)) {
|
||||
++sleep_counter_;
|
||||
silence_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!silence_ || prm_.sleep_timer == 0) {
|
||||
if (downThreadDelay(frame_time_milsec_, suspend_silence_delay_)) Update();
|
||||
execute();
|
||||
if (re_paint_ == 1 || force || prm_.continuous_rendering) {
|
||||
m_signal_update_.emit(output_);
|
||||
m_signal_audio_raw_.emit(audio_raw_);
|
||||
}
|
||||
} else {
|
||||
if (upThreadDelay(frame_time_milsec_, suspend_silence_delay_)) Update();
|
||||
if (silence_ != silence_prev_ || force) m_signal_silence_.emit();
|
||||
}
|
||||
silence_prev_ = silence_;
|
||||
}
|
||||
|
||||
void waybar::modules::cava::CavaBackend::freeBackend() {
|
||||
if (plan_ != NULL) {
|
||||
cava_destroy(plan_);
|
||||
plan_ = NULL;
|
||||
}
|
||||
|
||||
audio_raw_clean(&audio_raw_);
|
||||
pthread_mutex_lock(&audio_data_.lock);
|
||||
audio_data_.terminate = 1;
|
||||
pthread_mutex_unlock(&audio_data_.lock);
|
||||
free_config(&prm_);
|
||||
free(audio_data_.source);
|
||||
free(audio_data_.cava_in);
|
||||
}
|
||||
|
||||
void waybar::modules::cava::CavaBackend::loadConfig() {
|
||||
freeBackend();
|
||||
// Load waybar module config
|
||||
char cfgPath[PATH_MAX];
|
||||
cfgPath[0] = '\0';
|
||||
|
||||
if (config_["cava_config"].isString()) strcpy(cfgPath, config_["cava_config"].asString().data());
|
||||
// Load cava config
|
||||
error_.length = 0;
|
||||
|
||||
if (!load_config(cfgPath, &prm_, &error_)) {
|
||||
spdlog::error("cava backend. Error loading config. {0}", error_.message);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Override cava parameters by the user config
|
||||
prm_.inAtty = 0;
|
||||
auto const output{prm_.output};
|
||||
// prm_.output = ::cava::output_method::OUTPUT_RAW;
|
||||
if (config_["data_format"].isString()) {
|
||||
if (prm_.data_format) free(prm_.data_format);
|
||||
prm_.data_format = strdup(config_["data_format"].asString().c_str());
|
||||
}
|
||||
if (config_["raw_target"].isString()) {
|
||||
if (prm_.raw_target) free(prm_.raw_target);
|
||||
prm_.raw_target = strdup(config_["raw_target"].asString().c_str());
|
||||
}
|
||||
prm_.ascii_range = config_["format-icons"].size() - 1;
|
||||
|
||||
if (config_["bar_spacing"].isInt()) prm_.bar_spacing = config_["bar_spacing"].asInt();
|
||||
if (config_["bar_width"].isInt()) prm_.bar_width = config_["bar_width"].asInt();
|
||||
if (config_["bar_height"].isInt()) prm_.bar_height = config_["bar_height"].asInt();
|
||||
prm_.orientation = ::cava::ORIENT_TOP;
|
||||
prm_.xaxis = ::cava::xaxis_scale::NONE;
|
||||
prm_.mono_opt = ::cava::AVERAGE;
|
||||
prm_.autobars = 0;
|
||||
if (config_["gravity"].isInt()) prm_.gravity = config_["gravity"].asInt();
|
||||
if (config_["integral"].isInt()) prm_.integral = config_["integral"].asInt();
|
||||
|
||||
if (config_["framerate"].isInt()) prm_.framerate = config_["framerate"].asInt();
|
||||
// Calculate delay for Update() thread
|
||||
frame_time_milsec_ = std::chrono::milliseconds((int)(1e3 / prm_.framerate));
|
||||
if (config_["autosens"].isInt()) prm_.autosens = config_["autosens"].asInt();
|
||||
if (config_["sensitivity"].isInt()) prm_.sens = config_["sensitivity"].asInt();
|
||||
if (config_["bars"].isInt()) prm_.fixedbars = config_["bars"].asInt();
|
||||
if (config_["lower_cutoff_freq"].isNumeric())
|
||||
prm_.lower_cut_off = config_["lower_cutoff_freq"].asLargestInt();
|
||||
if (config_["higher_cutoff_freq"].isNumeric())
|
||||
prm_.upper_cut_off = config_["higher_cutoff_freq"].asLargestInt();
|
||||
if (config_["sleep_timer"].isInt()) prm_.sleep_timer = config_["sleep_timer"].asInt();
|
||||
if (config_["method"].isString())
|
||||
prm_.input = ::cava::input_method_by_name(config_["method"].asString().c_str());
|
||||
if (config_["source"].isString()) {
|
||||
if (prm_.audio_source) free(prm_.audio_source);
|
||||
prm_.audio_source = config_["source"].asString().data();
|
||||
}
|
||||
if (config_["sample_rate"].isNumeric()) prm_.samplerate = config_["sample_rate"].asLargestInt();
|
||||
if (config_["sample_bits"].isInt()) prm_.samplebits = config_["sample_bits"].asInt();
|
||||
if (config_["stereo"].isBool()) prm_.stereo = config_["stereo"].asBool();
|
||||
if (config_["reverse"].isBool()) prm_.reverse = config_["reverse"].asBool();
|
||||
if (config_["bar_delimiter"].isInt()) prm_.bar_delim = config_["bar_delimiter"].asInt();
|
||||
if (config_["monstercat"].isBool()) prm_.monstercat = config_["monstercat"].asBool();
|
||||
if (config_["waves"].isBool()) prm_.waves = config_["waves"].asBool();
|
||||
if (config_["noise_reduction"].isDouble())
|
||||
prm_.noise_reduction = config_["noise_reduction"].asDouble();
|
||||
if (config_["input_delay"].isInt())
|
||||
fetch_input_delay_ = std::chrono::seconds(config_["input_delay"].asInt());
|
||||
if (config_["gradient"].isInt()) prm_.gradient = config_["gradient"].asInt();
|
||||
if (prm_.gradient == 0)
|
||||
prm_.gradient_count = 0;
|
||||
else if (config_["gradient_count"].isInt())
|
||||
prm_.gradient_count = config_["gradient_count"].asInt();
|
||||
if (config_["sdl_width"].isInt()) prm_.sdl_width = config_["sdl_width"].asInt();
|
||||
if (config_["sdl_height"].isInt()) prm_.sdl_height = config_["sdl_height"].asInt();
|
||||
|
||||
audio_raw_.height = prm_.ascii_range;
|
||||
audio_data_.format = -1;
|
||||
audio_data_.rate = 0;
|
||||
audio_data_.samples_counter = 0;
|
||||
audio_data_.channels = 2;
|
||||
audio_data_.IEEE_FLOAT = 0;
|
||||
audio_data_.input_buffer_size = BUFFER_SIZE * audio_data_.channels;
|
||||
audio_data_.cava_buffer_size = audio_data_.input_buffer_size * 8;
|
||||
audio_data_.terminate = 0;
|
||||
audio_data_.suspendFlag = false;
|
||||
input_source_ = get_input(&audio_data_, &prm_);
|
||||
|
||||
if (!input_source_) {
|
||||
spdlog::error("cava backend API didn't provide input audio source method");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
prm_.output = ::cava::output_method::OUTPUT_RAW;
|
||||
|
||||
// Make cava parameters configuration
|
||||
// Init cava plan, audio_raw structure
|
||||
audio_raw_init(&audio_data_, &audio_raw_, &prm_, &plan_);
|
||||
if (!plan_) spdlog::error("cava backend plan is not provided");
|
||||
audio_raw_.previous_frame[0] = -1; // For first Update() call need to rePaint text message
|
||||
|
||||
prm_.output = output;
|
||||
}
|
||||
|
||||
const struct ::cava::config_params* waybar::modules::cava::CavaBackend::getPrm() { return &prm_; }
|
||||
std::chrono::milliseconds waybar::modules::cava::CavaBackend::getFrameTimeMilsec() {
|
||||
return frame_time_milsec_;
|
||||
};
|
||||
@@ -30,6 +30,9 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
|
||||
cldMonShift_{year(1900) / January},
|
||||
tzInTooltip_{m_tlpFmt_.find("{" + kTZPlaceholder + "}") != std::string::npos},
|
||||
tzCurrIdx_{0},
|
||||
tzTooltipFormat_{config_["timezone-tooltip-format"].isString()
|
||||
? config_["timezone-tooltip-format"].asString()
|
||||
: ""},
|
||||
ordInTooltip_{m_tlpFmt_.find("{" + kOrdPlaceholder + "}") != std::string::npos} {
|
||||
m_tlpText_ = m_tlpFmt_;
|
||||
|
||||
@@ -63,8 +66,8 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
|
||||
if (cldInTooltip_) {
|
||||
if (config_[kCldPlaceholder]["mode"].isString()) {
|
||||
const std::string cfgMode{config_[kCldPlaceholder]["mode"].asString()};
|
||||
const std::map<std::string_view, const CldMode&> monthModes{{"month", CldMode::MONTH},
|
||||
{"year", CldMode::YEAR}};
|
||||
const std::map<std::string, CldMode> monthModes{{"month", CldMode::MONTH},
|
||||
{"year", CldMode::YEAR}};
|
||||
if (monthModes.find(cfgMode) != monthModes.end())
|
||||
cldMode_ = monthModes.at(cfgMode);
|
||||
else
|
||||
@@ -73,6 +76,11 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
|
||||
"using instead",
|
||||
cfgMode);
|
||||
}
|
||||
|
||||
if (config_[kCldPlaceholder]["iso8601"].isBool()) {
|
||||
iso8601Calendar_ = config_[kCldPlaceholder]["iso8601"].asBool();
|
||||
}
|
||||
|
||||
if (config_[kCldPlaceholder]["weeks-pos"].isString()) {
|
||||
if (config_[kCldPlaceholder]["weeks-pos"].asString() == "left") cldWPos_ = WS::LEFT;
|
||||
if (config_[kCldPlaceholder]["weeks-pos"].asString() == "right") cldWPos_ = WS::RIGHT;
|
||||
@@ -92,23 +100,25 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
|
||||
fmtMap_.insert({2, "{}"});
|
||||
if (config_[kCldPlaceholder]["format"]["today"].isString()) {
|
||||
fmtMap_.insert({3, config_[kCldPlaceholder]["format"]["today"].asString()});
|
||||
cldBaseDay_ =
|
||||
year_month_day{
|
||||
floor<days>(zoned_time{local_zone(), system_clock::now()}.get_local_time())}
|
||||
.day();
|
||||
auto local_time = zoned_time{local_zone(), system_clock::now()}.get_local_time();
|
||||
cldBaseDay_ = year_month_day{floor<days>(local_time)}.day();
|
||||
} else
|
||||
fmtMap_.insert({3, "{}"});
|
||||
if (config_[kCldPlaceholder]["format"]["weeks"].isString() && cldWPos_ != WS::HIDDEN) {
|
||||
const auto defaultFmt =
|
||||
iso8601Calendar_ ? "{:%V}" : ((first_day_of_week() == Monday) ? "{:%W}" : "{:%U}");
|
||||
fmtMap_.insert({4, std::regex_replace(config_[kCldPlaceholder]["format"]["weeks"].asString(),
|
||||
std::regex("\\{\\}"),
|
||||
(first_day_of_week() == Monday) ? "{:%W}" : "{:%U}")});
|
||||
std::regex("\\{\\}"), defaultFmt)});
|
||||
Glib::ustring tmp{std::regex_replace(fmtMap_[4], std::regex("</?[^>]+>|\\{.*\\}"), "")};
|
||||
cldWnLen_ += tmp.size();
|
||||
} else {
|
||||
if (cldWPos_ != WS::HIDDEN)
|
||||
fmtMap_.insert({4, (first_day_of_week() == Monday) ? "{:%W}" : "{:%U}"});
|
||||
else
|
||||
if (cldWPos_ != WS::HIDDEN) {
|
||||
const auto defaultFmt =
|
||||
iso8601Calendar_ ? "{:%V}" : ((first_day_of_week() == Monday) ? "{:%W}" : "{:%U}");
|
||||
fmtMap_.insert({4, defaultFmt});
|
||||
} else {
|
||||
cldWnLen_ = 0;
|
||||
}
|
||||
}
|
||||
if (config_[kCldPlaceholder]["mode-mon-col"].isInt()) {
|
||||
cldMonCols_ = config_[kCldPlaceholder]["mode-mon-col"].asInt();
|
||||
@@ -188,11 +198,26 @@ auto waybar::modules::Clock::getTZtext(sys_seconds now) -> std::string {
|
||||
if (tzList_.size() == 1) return "";
|
||||
|
||||
std::stringstream os;
|
||||
bool first = true;
|
||||
for (size_t tz_idx{0}; tz_idx < tzList_.size(); ++tz_idx) {
|
||||
if (static_cast<int>(tz_idx) == tzCurrIdx_) continue;
|
||||
const auto* tz = tzList_[tz_idx] != nullptr ? tzList_[tz_idx] : local_zone();
|
||||
// Skip local timezone (nullptr) - never show it in tooltip
|
||||
if (tzList_[tz_idx] == nullptr) continue;
|
||||
|
||||
// Skip current timezone unless timezone-tooltip-format is specified
|
||||
if (static_cast<int>(tz_idx) == tzCurrIdx_ && tzTooltipFormat_.empty()) continue;
|
||||
|
||||
const auto* tz = tzList_[tz_idx];
|
||||
auto zt{zoned_time{tz, now}};
|
||||
os << fmt_lib::vformat(m_locale_, format_, fmt_lib::make_format_args(zt)) << '\n';
|
||||
|
||||
// Add newline before each entry except the first
|
||||
if (!first) {
|
||||
os << '\n';
|
||||
}
|
||||
first = false;
|
||||
|
||||
// Use timezone-tooltip-format if specified, otherwise use format_
|
||||
const std::string& fmt = tzTooltipFormat_.empty() ? format_ : tzTooltipFormat_;
|
||||
os << fmt_lib::vformat(m_locale_, fmt, fmt_lib::make_format_args(zt));
|
||||
}
|
||||
|
||||
return os.str();
|
||||
@@ -204,9 +229,11 @@ const unsigned cldRowsInMonth(const year_month& ym, const weekday& firstdow) {
|
||||
|
||||
auto cldGetWeekForLine(const year_month& ym, const weekday& firstdow, const unsigned line)
|
||||
-> const year_month_weekday {
|
||||
unsigned index{line - 2};
|
||||
if (weekday{ym / 1} == firstdow) ++index;
|
||||
return ym / firstdow[index];
|
||||
const unsigned idx = line - 2;
|
||||
const auto indexed_first_day_of_week =
|
||||
weekday{ym / 1} == firstdow ? firstdow[idx + 1] : firstdow[idx];
|
||||
|
||||
return ym / indexed_first_day_of_week;
|
||||
}
|
||||
|
||||
auto getCalendarLine(const year_month_day& currDate, const year_month ym, const unsigned line,
|
||||
@@ -265,7 +292,7 @@ auto getCalendarLine(const year_month_day& currDate, const year_month ym, const
|
||||
}
|
||||
// Print non-first week
|
||||
default: {
|
||||
auto ymdTmp{cldGetWeekForLine(ym, firstdow, line)};
|
||||
const auto ymdTmp{cldGetWeekForLine(ym, firstdow, line)};
|
||||
if (ymdTmp.ok()) {
|
||||
auto d{year_month_day{ymdTmp}.day()};
|
||||
const auto dlast{(ym / last).day()};
|
||||
@@ -356,8 +383,9 @@ auto waybar::modules::Clock::get_calendar(const year_month_day& today, const yea
|
||||
: static_cast<const zoned_seconds&&>(zoned_seconds{
|
||||
tz, local_days{cldGetWeekForLine(ymTmp, firstdow, line)}})))
|
||||
<< ' ';
|
||||
} else
|
||||
} else {
|
||||
os << pads;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,6 +509,9 @@ using deleting_unique_ptr = std::unique_ptr<T, deleter_from_fn<fn>>;
|
||||
|
||||
// Computations done similarly to Linux cal utility.
|
||||
auto waybar::modules::Clock::first_day_of_week() -> weekday {
|
||||
if (iso8601Calendar_) {
|
||||
return Monday;
|
||||
}
|
||||
#ifdef HAVE_LANGINFO_1STDAY
|
||||
deleting_unique_ptr<std::remove_pointer<locale_t>::type, freelocale> posix_locale{
|
||||
newlocale(LC_ALL, m_locale_.name().c_str(), nullptr)};
|
||||
|
||||
@@ -89,9 +89,11 @@ void waybar::modules::Custom::continuousWorker() {
|
||||
dp.emit();
|
||||
spdlog::error("{} stopped unexpectedly, is it endless?", name_);
|
||||
}
|
||||
if (config_["restart-interval"].isUInt()) {
|
||||
if (config_["restart-interval"].isNumeric()) {
|
||||
pid_ = -1;
|
||||
thread_.sleep_for(std::chrono::seconds(config_["restart-interval"].asUInt()));
|
||||
thread_.sleep_for(std::chrono::milliseconds(
|
||||
std::max(1L, // Minimum 1ms due to millisecond precision
|
||||
static_cast<long>(config_["restart-interval"].asDouble() * 1000))));
|
||||
fp_ = util::command::open(cmd, pid_, output_name_);
|
||||
if (!fp_) {
|
||||
throw std::runtime_error("Unable to open " + cmd);
|
||||
|
||||
@@ -187,6 +187,12 @@ void Tags::handle_view_tags(uint32_t tag, uint32_t state, uint32_t clients, uint
|
||||
button.get_style_context()->remove_class("occupied");
|
||||
}
|
||||
|
||||
if (clients & TAG_INACTIVE) {
|
||||
button.get_style_context()->remove_class("empty");
|
||||
} else {
|
||||
button.get_style_context()->add_class("empty");
|
||||
}
|
||||
|
||||
if (state & TAG_ACTIVE) {
|
||||
button.get_style_context()->add_class("focused");
|
||||
} else {
|
||||
|
||||
@@ -349,11 +349,11 @@ Workspace::Workspace(const Json::Value &config, WorkspaceManager &manager,
|
||||
}
|
||||
const bool config_on_click_middle = config["on-click-middle"].isString();
|
||||
if (config_on_click_middle) {
|
||||
on_click_middle_action_ = config["on-click"].asString();
|
||||
on_click_middle_action_ = config["on-click-middle"].asString();
|
||||
}
|
||||
const bool config_on_click_right = config["on-click-right"].isString();
|
||||
if (config_on_click_right) {
|
||||
on_click_right_action_ = config["on-click"].asString();
|
||||
on_click_right_action_ = config["on-click-right"].asString();
|
||||
}
|
||||
|
||||
// setup UI
|
||||
@@ -377,16 +377,19 @@ Workspace::~Workspace() {
|
||||
}
|
||||
|
||||
void Workspace::update() {
|
||||
if (!needs_updating_) {
|
||||
return;
|
||||
}
|
||||
const auto style_context = button_.get_style_context();
|
||||
|
||||
// update style and visibility
|
||||
|
||||
const auto style_context = button_.get_style_context();
|
||||
style_context->remove_class("active");
|
||||
style_context->remove_class("urgent");
|
||||
style_context->remove_class("hidden");
|
||||
if (!has_state(EXT_WORKSPACE_HANDLE_V1_STATE_ACTIVE)) {
|
||||
style_context->remove_class("active");
|
||||
}
|
||||
if (!has_state(EXT_WORKSPACE_HANDLE_V1_STATE_URGENT)) {
|
||||
style_context->remove_class("urgent");
|
||||
}
|
||||
if (!has_state(EXT_WORKSPACE_HANDLE_V1_STATE_HIDDEN)) {
|
||||
style_context->remove_class("hidden");
|
||||
}
|
||||
|
||||
if (has_state(EXT_WORKSPACE_HANDLE_V1_STATE_ACTIVE)) {
|
||||
button_.set_visible(true);
|
||||
@@ -408,34 +411,26 @@ void Workspace::update() {
|
||||
label_.set_markup(fmt::format(fmt::runtime(format_), fmt::arg("name", name_),
|
||||
fmt::arg("id", workspace_id_),
|
||||
fmt::arg("icon", with_icon_ ? icon() : "")));
|
||||
|
||||
needs_updating_ = false;
|
||||
}
|
||||
|
||||
void Workspace::handle_id(const std::string &id) {
|
||||
spdlog::debug("[ext/workspaces]: ID for workspace {}: {}", id_, id);
|
||||
workspace_id_ = id;
|
||||
needs_updating_ = true;
|
||||
workspace_manager_.set_needs_sorting();
|
||||
}
|
||||
|
||||
void Workspace::handle_name(const std::string &name) {
|
||||
spdlog::debug("[ext/workspaces]: Name for workspace {}: {}", id_, name);
|
||||
name_ = name;
|
||||
needs_updating_ = true;
|
||||
workspace_manager_.set_needs_sorting();
|
||||
}
|
||||
|
||||
void Workspace::handle_coordinates(const std::vector<uint32_t> &coordinates) {
|
||||
coordinates_ = coordinates;
|
||||
needs_updating_ = true;
|
||||
workspace_manager_.set_needs_sorting();
|
||||
}
|
||||
|
||||
void Workspace::handle_state(uint32_t state) {
|
||||
state_ = state;
|
||||
needs_updating_ = true;
|
||||
}
|
||||
void Workspace::handle_state(uint32_t state) { state_ = state; }
|
||||
|
||||
void Workspace::handle_capabilities(uint32_t capabilities) {
|
||||
spdlog::debug("[ext/workspaces]: Capabilities for workspace {}:", id_);
|
||||
@@ -451,7 +446,6 @@ void Workspace::handle_capabilities(uint32_t capabilities) {
|
||||
if ((capabilities & EXT_WORKSPACE_HANDLE_V1_WORKSPACE_CAPABILITIES_ASSIGN) == capabilities) {
|
||||
spdlog::debug("[ext/workspaces]: - assign");
|
||||
}
|
||||
needs_updating_ = true;
|
||||
}
|
||||
|
||||
void Workspace::handle_removed() {
|
||||
@@ -475,6 +469,8 @@ bool Workspace::handle_clicked(const GdkEventButton *button) const {
|
||||
|
||||
if (action == "activate") {
|
||||
ext_workspace_handle_v1_activate(ext_handle_);
|
||||
} else if (action == "deactivate") {
|
||||
ext_workspace_handle_v1_deactivate(ext_handle_);
|
||||
} else if (action == "close") {
|
||||
ext_workspace_handle_v1_remove(ext_handle_);
|
||||
} else {
|
||||
|
||||
@@ -53,7 +53,6 @@ Gamemode::Gamemode(const std::string& id, const Json::Value& config)
|
||||
if (config_["icon-spacing"].isUInt()) {
|
||||
iconSpacing = config_["icon-spacing"].asUInt();
|
||||
}
|
||||
box_.set_spacing(iconSpacing);
|
||||
|
||||
// Whether to use icon or not
|
||||
if (config_["use-icon"].isBool()) {
|
||||
@@ -64,7 +63,6 @@ Gamemode::Gamemode(const std::string& id, const Json::Value& config)
|
||||
if (config_["icon-size"].isUInt()) {
|
||||
iconSize = config_["icon-size"].asUInt();
|
||||
}
|
||||
icon_.set_pixel_size(iconSize);
|
||||
|
||||
// Format
|
||||
if (config_["format"].isString()) {
|
||||
@@ -228,6 +226,11 @@ auto Gamemode::update() -> void {
|
||||
iconName = DEFAULT_ICON_NAME;
|
||||
}
|
||||
icon_.set_from_icon_name(iconName, Gtk::ICON_SIZE_INVALID);
|
||||
box_.set_spacing(iconSpacing);
|
||||
icon_.set_pixel_size(iconSize);
|
||||
} else {
|
||||
box_.set_spacing(0);
|
||||
icon_.set_pixel_size(0);
|
||||
}
|
||||
|
||||
// Call parent update
|
||||
|
||||
@@ -46,9 +46,14 @@ std::filesystem::path IPC::getSocketFolder(const char* instanceSig) {
|
||||
IPC::IPC() {
|
||||
// will start IPC and relay events to parseIPC
|
||||
ipcThread_ = std::thread([this]() { socketListener(); });
|
||||
socketOwnerPid_ = getpid();
|
||||
}
|
||||
|
||||
IPC::~IPC() {
|
||||
// Do no stop Hyprland IPC if a child process (with successful fork() but
|
||||
// failed exec()) exits.
|
||||
if (getpid() != socketOwnerPid_) return;
|
||||
|
||||
running_ = false;
|
||||
spdlog::info("Hyprland IPC stopping...");
|
||||
if (socketfd_ != -1) {
|
||||
@@ -78,8 +83,6 @@ void IPC::socketListener() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!modulesReady) return;
|
||||
|
||||
spdlog::info("Hyprland IPC starting");
|
||||
|
||||
struct sockaddr_un addr;
|
||||
|
||||
@@ -11,8 +11,6 @@ namespace waybar::modules::hyprland {
|
||||
|
||||
Language::Language(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
: ALabel(config, "language", id, "{}", 0, true), bar_(bar), m_ipc(IPC::inst()) {
|
||||
modulesReady = true;
|
||||
|
||||
// get the active layout when open
|
||||
initLanguage();
|
||||
|
||||
|
||||
@@ -2,14 +2,10 @@
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include "util/sanitize_str.hpp"
|
||||
|
||||
namespace waybar::modules::hyprland {
|
||||
|
||||
Submap::Submap(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
: ALabel(config, "submap", id, "{}", 0, true), bar_(bar), m_ipc(IPC::inst()) {
|
||||
modulesReady = true;
|
||||
|
||||
parseConfig(config);
|
||||
|
||||
label_.hide();
|
||||
|
||||
@@ -21,7 +21,6 @@ Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
: AAppIconLabel(config, "window", id, "{title}", 0, true), bar_(bar), m_ipc(IPC::inst()) {
|
||||
std::unique_lock<std::shared_mutex> windowIpcUniqueLock(windowIpcSmtx);
|
||||
|
||||
modulesReady = true;
|
||||
separateOutputs_ = config["separate-outputs"].asBool();
|
||||
|
||||
// register for hyprland ipc
|
||||
|
||||
@@ -9,35 +9,29 @@
|
||||
#include <vector>
|
||||
|
||||
#include "modules/hyprland/backend.hpp"
|
||||
#include "util/sanitize_str.hpp"
|
||||
|
||||
namespace waybar::modules::hyprland {
|
||||
|
||||
WindowCount::WindowCount(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
: AAppIconLabel(config, "windowcount", id, "{count}", 0, true), bar_(bar) {
|
||||
modulesReady = true;
|
||||
: AAppIconLabel(config, "windowcount", id, "{count}", 0, true), bar_(bar), m_ipc(IPC::inst()) {
|
||||
separateOutputs_ =
|
||||
config.isMember("separate-outputs") ? config["separate-outputs"].asBool() : true;
|
||||
|
||||
if (!gIPC) {
|
||||
gIPC = std::make_unique<IPC>();
|
||||
}
|
||||
|
||||
queryActiveWorkspace();
|
||||
update();
|
||||
dp.emit();
|
||||
|
||||
// register for hyprland ipc
|
||||
gIPC->registerForIPC("fullscreen", this);
|
||||
gIPC->registerForIPC("workspace", this);
|
||||
gIPC->registerForIPC("focusedmon", this);
|
||||
gIPC->registerForIPC("openwindow", this);
|
||||
gIPC->registerForIPC("closewindow", this);
|
||||
gIPC->registerForIPC("movewindow", this);
|
||||
m_ipc.registerForIPC("fullscreen", this);
|
||||
m_ipc.registerForIPC("workspace", this);
|
||||
m_ipc.registerForIPC("focusedmon", this);
|
||||
m_ipc.registerForIPC("openwindow", this);
|
||||
m_ipc.registerForIPC("closewindow", this);
|
||||
m_ipc.registerForIPC("movewindow", this);
|
||||
}
|
||||
|
||||
WindowCount::~WindowCount() {
|
||||
gIPC->unregisterForIPC(this);
|
||||
m_ipc.unregisterForIPC(this);
|
||||
// wait for possible event handler to finish
|
||||
std::lock_guard<std::mutex> lg(mutex_);
|
||||
}
|
||||
@@ -70,7 +64,7 @@ auto WindowCount::update() -> void {
|
||||
}
|
||||
|
||||
auto WindowCount::getActiveWorkspace() -> Workspace {
|
||||
const auto workspace = gIPC->getSocket1JsonReply("activeworkspace");
|
||||
const auto workspace = m_ipc.getSocket1JsonReply("activeworkspace");
|
||||
|
||||
if (workspace.isObject()) {
|
||||
return Workspace::parse(workspace);
|
||||
@@ -80,24 +74,31 @@ auto WindowCount::getActiveWorkspace() -> Workspace {
|
||||
}
|
||||
|
||||
auto WindowCount::getActiveWorkspace(const std::string& monitorName) -> Workspace {
|
||||
const auto monitors = gIPC->getSocket1JsonReply("monitors");
|
||||
const auto monitors = m_ipc.getSocket1JsonReply("monitors");
|
||||
if (monitors.isArray()) {
|
||||
auto monitor = std::find_if(monitors.begin(), monitors.end(), [&](Json::Value monitor) {
|
||||
return monitor["name"] == monitorName;
|
||||
});
|
||||
auto monitor = std::ranges::find_if(
|
||||
monitors, [&](Json::Value monitor) { return monitor["name"] == monitorName; });
|
||||
if (monitor == std::end(monitors)) {
|
||||
spdlog::warn("Monitor not found: {}", monitorName);
|
||||
return Workspace{-1, 0, false};
|
||||
return Workspace{
|
||||
.id = -1,
|
||||
.windows = 0,
|
||||
.hasfullscreen = false,
|
||||
};
|
||||
}
|
||||
const int id = (*monitor)["activeWorkspace"]["id"].asInt();
|
||||
|
||||
const auto workspaces = gIPC->getSocket1JsonReply("workspaces");
|
||||
const auto workspaces = m_ipc.getSocket1JsonReply("workspaces");
|
||||
if (workspaces.isArray()) {
|
||||
auto workspace = std::find_if(workspaces.begin(), workspaces.end(),
|
||||
[&](Json::Value workspace) { return workspace["id"] == id; });
|
||||
auto workspace = std::ranges::find_if(
|
||||
workspaces, [&](Json::Value workspace) { return workspace["id"] == id; });
|
||||
if (workspace == std::end(workspaces)) {
|
||||
spdlog::warn("No workspace with id {}", id);
|
||||
return Workspace{-1, 0, false};
|
||||
return Workspace{
|
||||
.id = -1,
|
||||
.windows = 0,
|
||||
.hasfullscreen = false,
|
||||
};
|
||||
}
|
||||
return Workspace::parse(*workspace);
|
||||
};
|
||||
@@ -108,9 +109,9 @@ auto WindowCount::getActiveWorkspace(const std::string& monitorName) -> Workspac
|
||||
|
||||
auto WindowCount::Workspace::parse(const Json::Value& value) -> WindowCount::Workspace {
|
||||
return Workspace{
|
||||
value["id"].asInt(),
|
||||
value["windows"].asInt(),
|
||||
value["hasfullscreen"].asBool(),
|
||||
.id = value["id"].asInt(),
|
||||
.windows = value["windows"].asInt(),
|
||||
.hasfullscreen = value["hasfullscreen"].asBool(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -104,8 +104,25 @@ void Workspace::initializeWindowMap(const Json::Value &clients_data) {
|
||||
}
|
||||
|
||||
void Workspace::setActiveWindow(WindowAddress const &addr) {
|
||||
for (auto &window : m_windowMap) {
|
||||
window.setActive(window.address == addr);
|
||||
std::optional<long> activeIdx;
|
||||
for (size_t i = 0; i < m_windowMap.size(); ++i) {
|
||||
auto &window = m_windowMap[i];
|
||||
bool isActive = (window.address == addr);
|
||||
window.setActive(isActive);
|
||||
if (isActive) {
|
||||
activeIdx = i;
|
||||
}
|
||||
}
|
||||
|
||||
auto activeWindowPos = m_workspaceManager.activeWindowPosition();
|
||||
if (activeIdx.has_value() && activeWindowPos != Workspaces::ActiveWindowPosition::NONE) {
|
||||
auto window = std::move(m_windowMap[*activeIdx]);
|
||||
m_windowMap.erase(m_windowMap.begin() + *activeIdx);
|
||||
if (activeWindowPos == Workspaces::ActiveWindowPosition::FIRST) {
|
||||
m_windowMap.insert(m_windowMap.begin(), std::move(window));
|
||||
} else if (activeWindowPos == Workspaces::ActiveWindowPosition::LAST) {
|
||||
m_windowMap.emplace_back(std::move(window));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,6 +268,17 @@ void Workspace::update(const std::string &workspace_icon) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Workspace::isEmpty() const {
|
||||
auto ignore_list = m_workspaceManager.getIgnoredWindows();
|
||||
if (ignore_list.empty()) {
|
||||
return m_windows == 0;
|
||||
}
|
||||
// If there are windows but they are all ignored, consider the workspace empty
|
||||
return std::all_of(
|
||||
m_windowMap.begin(), m_windowMap.end(),
|
||||
[this, &ignore_list](const auto &window_repr) { return shouldSkipWindow(window_repr); });
|
||||
}
|
||||
|
||||
void Workspace::updateTaskbar(const std::string &workspace_icon) {
|
||||
for (auto child : m_content.get_children()) {
|
||||
if (child != &m_labelBefore) {
|
||||
@@ -259,9 +287,9 @@ void Workspace::updateTaskbar(const std::string &workspace_icon) {
|
||||
}
|
||||
|
||||
bool isFirst = true;
|
||||
for (const auto &window_repr : m_windowMap) {
|
||||
auto processWindow = [&](const WindowRepr &window_repr) {
|
||||
if (shouldSkipWindow(window_repr)) {
|
||||
continue;
|
||||
return; // skip
|
||||
}
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
@@ -270,6 +298,7 @@ void Workspace::updateTaskbar(const std::string &workspace_icon) {
|
||||
m_content.pack_start(*windowSeparator, false, false);
|
||||
windowSeparator->show();
|
||||
}
|
||||
|
||||
auto window_box = Gtk::make_managed<Gtk::Box>(Gtk::ORIENTATION_HORIZONTAL);
|
||||
window_box->set_tooltip_text(window_repr.window_title);
|
||||
window_box->get_style_context()->add_class("taskbar-window");
|
||||
@@ -307,6 +336,16 @@ void Workspace::updateTaskbar(const std::string &workspace_icon) {
|
||||
|
||||
m_content.pack_start(*event_box, true, false);
|
||||
event_box->show_all();
|
||||
};
|
||||
|
||||
if (m_workspaceManager.taskbarReverseDirection()) {
|
||||
for (auto it = m_windowMap.rbegin(); it != m_windowMap.rend(); ++it) {
|
||||
processWindow(*it);
|
||||
}
|
||||
} else {
|
||||
for (const auto &window_repr : m_windowMap) {
|
||||
processWindow(window_repr);
|
||||
}
|
||||
}
|
||||
|
||||
auto formatAfter = m_workspaceManager.formatAfter();
|
||||
|
||||
@@ -19,7 +19,6 @@ Workspaces::Workspaces(const std::string &id, const Bar &bar, const Json::Value
|
||||
m_bar(bar),
|
||||
m_box(bar.orientation, 0),
|
||||
m_ipc(IPC::inst()) {
|
||||
modulesReady = true;
|
||||
parseConfig(config);
|
||||
|
||||
m_box.set_name("workspaces");
|
||||
@@ -297,6 +296,11 @@ void Workspaces::loadPersistentWorkspacesFromWorkspaceRules(const Json::Value &c
|
||||
auto workspace = rule.isMember("defaultName") ? rule["defaultName"].asString()
|
||||
: rule["workspaceString"].asString();
|
||||
|
||||
// There could be persistent special workspaces, only show those when show-special is enabled.
|
||||
if (workspace.starts_with("special:") && !showSpecial()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The prefix "name:" cause mismatches with workspace names taken anywhere else.
|
||||
if (workspace.starts_with("name:")) {
|
||||
workspace = workspace.substr(5);
|
||||
@@ -728,6 +732,7 @@ auto Workspaces::populateWorkspaceTaskbarConfig(const Json::Value &config) -> vo
|
||||
|
||||
populateBoolConfig(workspaceTaskbar, "enable", m_enableTaskbar);
|
||||
populateBoolConfig(workspaceTaskbar, "update-active-window", m_updateActiveWindow);
|
||||
populateBoolConfig(workspaceTaskbar, "reverse-direction", m_taskbarReverseDirection);
|
||||
|
||||
if (workspaceTaskbar["format"].isString()) {
|
||||
/* The user defined a format string, use it */
|
||||
@@ -775,6 +780,18 @@ auto Workspaces::populateWorkspaceTaskbarConfig(const Json::Value &config) -> vo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (workspaceTaskbar["active-window-position"].isString()) {
|
||||
auto posStr = workspaceTaskbar["active-window-position"].asString();
|
||||
try {
|
||||
m_activeWindowPosition =
|
||||
m_activeWindowEnumParser.parseStringToEnum(posStr, m_activeWindowPositionMap);
|
||||
} catch (const std::invalid_argument &e) {
|
||||
spdlog::warn(
|
||||
"Invalid string representation for active-window-position. Falling back to 'none'.");
|
||||
m_activeWindowPosition = ActiveWindowPosition::NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Workspaces::registerOrphanWindow(WindowCreationPayload create_window_payload) {
|
||||
@@ -1129,9 +1146,9 @@ std::optional<int> Workspaces::parseWorkspaceId(std::string const &workspaceIdSt
|
||||
try {
|
||||
return workspaceIdStr == "special" ? -99 : std::stoi(workspaceIdStr);
|
||||
} catch (std::exception const &e) {
|
||||
spdlog::error("Failed to parse workspace ID: {}", e.what());
|
||||
spdlog::debug("Workspace \"{}\" is not bound to an id: {}", workspaceIdStr, e.what());
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
||||
@@ -14,14 +14,20 @@ waybar::modules::Image::Image(const std::string& id, const Json::Value& config)
|
||||
|
||||
size_ = config["size"].asInt();
|
||||
|
||||
interval_ = config_["interval"].asInt();
|
||||
interval_ = config_["interval"] == "once"
|
||||
? std::chrono::milliseconds::max()
|
||||
: std::chrono::milliseconds(std::max(
|
||||
1L, // Minimum 1ms due to millisecond precision
|
||||
static_cast<long>(
|
||||
(config_["interval"].isNumeric() ? config_["interval"].asDouble() : 0) *
|
||||
1000)));
|
||||
|
||||
if (size_ == 0) {
|
||||
size_ = 16;
|
||||
}
|
||||
|
||||
if (interval_ == 0) {
|
||||
interval_ = INT_MAX;
|
||||
if (interval_.count() == 0) {
|
||||
interval_ = std::chrono::milliseconds::max();
|
||||
}
|
||||
|
||||
delayWorker();
|
||||
@@ -30,8 +36,7 @@ waybar::modules::Image::Image(const std::string& id, const Json::Value& config)
|
||||
void waybar::modules::Image::delayWorker() {
|
||||
thread_ = [this] {
|
||||
dp.emit();
|
||||
auto interval = std::chrono::seconds(interval_);
|
||||
thread_.sleep_for(interval);
|
||||
thread_.sleep_for(interval_);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ auto waybar::modules::Memory::update() -> void {
|
||||
float total_swap_gigabytes = 0.01 * round(swaptotal / 10485.76);
|
||||
int used_ram_percentage = 100 * (memtotal - memfree) / memtotal;
|
||||
int used_swap_percentage = 0;
|
||||
if (swaptotal && swapfree) {
|
||||
if (swaptotal) {
|
||||
used_swap_percentage = 100 * (swaptotal - swapfree) / swaptotal;
|
||||
}
|
||||
float used_ram_gigabytes = 0.01 * round((memtotal - memfree) / 10485.76);
|
||||
|
||||
@@ -333,18 +333,23 @@ auto waybar::modules::Network::update() -> void {
|
||||
fmt::arg("ipaddr", final_ipaddr_), fmt::arg("gwaddr", gwaddr_), fmt::arg("cidr", cidr_),
|
||||
fmt::arg("cidr6", cidr6_), fmt::arg("frequency", fmt::format("{:.1f}", frequency_)),
|
||||
fmt::arg("icon", getIcon(signal_strength_, state_)),
|
||||
fmt::arg("bandwidthDownBits", pow_format(bandwidth_down * 8ull / interval_.count(), "b/s")),
|
||||
fmt::arg("bandwidthUpBits", pow_format(bandwidth_up * 8ull / interval_.count(), "b/s")),
|
||||
fmt::arg("bandwidthTotalBits",
|
||||
pow_format((bandwidth_up + bandwidth_down) * 8ull / interval_.count(), "b/s")),
|
||||
fmt::arg("bandwidthDownOctets", pow_format(bandwidth_down / interval_.count(), "o/s")),
|
||||
fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up / interval_.count(), "o/s")),
|
||||
fmt::arg("bandwidthDownBits",
|
||||
pow_format(bandwidth_down * 8ull / (interval_.count() / 1000.0), "b/s")),
|
||||
fmt::arg("bandwidthUpBits",
|
||||
pow_format(bandwidth_up * 8ull / (interval_.count() / 1000.0), "b/s")),
|
||||
fmt::arg(
|
||||
"bandwidthTotalBits",
|
||||
pow_format((bandwidth_up + bandwidth_down) * 8ull / (interval_.count() / 1000.0), "b/s")),
|
||||
fmt::arg("bandwidthDownOctets",
|
||||
pow_format(bandwidth_down / (interval_.count() / 1000.0), "o/s")),
|
||||
fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up / (interval_.count() / 1000.0), "o/s")),
|
||||
fmt::arg("bandwidthTotalOctets",
|
||||
pow_format((bandwidth_up + bandwidth_down) / interval_.count(), "o/s")),
|
||||
fmt::arg("bandwidthDownBytes", pow_format(bandwidth_down / interval_.count(), "B/s")),
|
||||
fmt::arg("bandwidthUpBytes", pow_format(bandwidth_up / interval_.count(), "B/s")),
|
||||
pow_format((bandwidth_up + bandwidth_down) / (interval_.count() / 1000.0), "o/s")),
|
||||
fmt::arg("bandwidthDownBytes",
|
||||
pow_format(bandwidth_down / (interval_.count() / 1000.0), "B/s")),
|
||||
fmt::arg("bandwidthUpBytes", pow_format(bandwidth_up / (interval_.count() / 1000.0), "B/s")),
|
||||
fmt::arg("bandwidthTotalBytes",
|
||||
pow_format((bandwidth_up + bandwidth_down) / interval_.count(), "B/s")));
|
||||
pow_format((bandwidth_up + bandwidth_down) / (interval_.count() / 1000.0), "B/s")));
|
||||
if (text.compare(label_.get_label()) != 0) {
|
||||
label_.set_markup(text);
|
||||
if (text.empty()) {
|
||||
|
||||
@@ -58,6 +58,16 @@ void Language::doUpdate() {
|
||||
spdlog::debug("niri language update with short description {}", layout.short_description);
|
||||
spdlog::debug("niri language update with variant {}", layout.variant);
|
||||
|
||||
if (!last_short_name_.empty()) {
|
||||
label_.get_style_context()->remove_class(last_short_name_);
|
||||
}
|
||||
if (!layout.short_name.empty()) {
|
||||
label_.get_style_context()->add_class(layout.short_name);
|
||||
last_short_name_ = layout.short_name;
|
||||
} else {
|
||||
last_short_name_.clear();
|
||||
}
|
||||
|
||||
std::string layoutName = std::string{};
|
||||
if (config_.isMember("format-" + layout.short_description + "-" + layout.variant)) {
|
||||
const auto propName = "format-" + layout.short_description + "-" + layout.variant;
|
||||
|
||||
@@ -150,11 +150,7 @@ Tags::Tags(const std::string &id, const waybar::Bar &bar, const Json::Value &con
|
||||
button.show();
|
||||
}
|
||||
|
||||
struct wl_output *output = gdk_wayland_monitor_get_wl_output(bar_.output->monitor->gobj());
|
||||
output_status_ = zriver_status_manager_v1_get_river_output_status(status_manager_, output);
|
||||
zriver_output_status_v1_add_listener(output_status_, &output_status_listener_impl, this);
|
||||
|
||||
zriver_status_manager_v1_destroy(status_manager_);
|
||||
box_.signal_show().connect(sigc::mem_fun(*this, &Tags::handle_show));
|
||||
}
|
||||
|
||||
Tags::~Tags() {
|
||||
@@ -165,6 +161,19 @@ Tags::~Tags() {
|
||||
if (control_) {
|
||||
zriver_control_v1_destroy(control_);
|
||||
}
|
||||
|
||||
if (status_manager_) {
|
||||
zriver_status_manager_v1_destroy(status_manager_);
|
||||
}
|
||||
}
|
||||
|
||||
void Tags::handle_show() {
|
||||
struct wl_output *output = gdk_wayland_monitor_get_wl_output(bar_.output->monitor->gobj());
|
||||
output_status_ = zriver_status_manager_v1_get_river_output_status(status_manager_, output);
|
||||
zriver_output_status_v1_add_listener(output_status_, &output_status_listener_impl, this);
|
||||
|
||||
zriver_status_manager_v1_destroy(status_manager_);
|
||||
status_manager_ = nullptr;
|
||||
}
|
||||
|
||||
void Tags::handle_primary_clicked(uint32_t tag) {
|
||||
|
||||
@@ -74,6 +74,13 @@ Item::Item(const std::string& bn, const std::string& op, const Json::Value& conf
|
||||
cancellable_, interface);
|
||||
}
|
||||
|
||||
Item::~Item() {
|
||||
if (this->gtk_menu != nullptr) {
|
||||
this->gtk_menu->popdown();
|
||||
this->gtk_menu->detach();
|
||||
}
|
||||
}
|
||||
|
||||
bool Item::handleMouseEnter(GdkEventCrossing* const& e) {
|
||||
event_box.set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
|
||||
return false;
|
||||
@@ -443,6 +450,9 @@ void Item::makeMenu() {
|
||||
gtk_menu->attach_to_widget(event_box);
|
||||
}
|
||||
}
|
||||
// Manually reset prelight to make sure the tray item doesn't stay in a hover state even though
|
||||
// the menu is focused
|
||||
event_box.unset_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
|
||||
}
|
||||
|
||||
bool Item::handleClick(GdkEventButton* const& ev) {
|
||||
|
||||
@@ -331,7 +331,7 @@ auto Workspaces::update() -> void {
|
||||
}
|
||||
std::string output = (*it)["name"].asString();
|
||||
std::string windows = "";
|
||||
if (config_["window-format"].isString()) {
|
||||
if (config_["window-rewrite"].isObject()) {
|
||||
updateWindows((*it), windows);
|
||||
}
|
||||
if (config_["format"].isString()) {
|
||||
|
||||
@@ -74,12 +74,14 @@ auto waybar::modules::Temperature::update() -> void {
|
||||
if (critical) {
|
||||
format = config_["format-critical"].isString() ? config_["format-critical"].asString() : format;
|
||||
label_.get_style_context()->add_class("critical");
|
||||
} else if (warning) {
|
||||
format = config_["format-warning"].isString() ? config_["format-warning"].asString() : format;
|
||||
label_.get_style_context()->add_class("warning");
|
||||
} else {
|
||||
label_.get_style_context()->remove_class("critical");
|
||||
label_.get_style_context()->remove_class("warning");
|
||||
if (warning) {
|
||||
format = config_["format-warning"].isString() ? config_["format-warning"].asString() : format;
|
||||
label_.get_style_context()->add_class("warning");
|
||||
} else {
|
||||
label_.get_style_context()->remove_class("warning");
|
||||
}
|
||||
}
|
||||
|
||||
if (format.empty()) {
|
||||
|
||||
@@ -14,16 +14,18 @@ waybar::modules::Wireplumber::Wireplumber(const std::string& id, const Json::Val
|
||||
mixer_api_(nullptr),
|
||||
def_nodes_api_(nullptr),
|
||||
default_node_name_(nullptr),
|
||||
default_source_name_(nullptr),
|
||||
pending_plugins_(0),
|
||||
muted_(false),
|
||||
source_muted_(false),
|
||||
volume_(0.0),
|
||||
source_volume_(0.0),
|
||||
min_step_(0.0),
|
||||
node_id_(0),
|
||||
node_name_(""),
|
||||
source_name_(""),
|
||||
type_(nullptr),
|
||||
source_node_id_(0),
|
||||
type_(nullptr) {
|
||||
source_muted_(false),
|
||||
source_volume_(0.0),
|
||||
default_source_name_(nullptr) {
|
||||
waybar::modules::Wireplumber::modules.push_back(this);
|
||||
|
||||
wp_init(WP_INIT_PIPEWIRE);
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
#include "util/udev_deleter.hpp"
|
||||
|
||||
namespace {
|
||||
class FileDescriptor {
|
||||
public:
|
||||
@@ -29,22 +31,6 @@ class FileDescriptor {
|
||||
int fd_;
|
||||
};
|
||||
|
||||
struct UdevDeleter {
|
||||
void operator()(udev *ptr) { udev_unref(ptr); }
|
||||
};
|
||||
|
||||
struct UdevDeviceDeleter {
|
||||
void operator()(udev_device *ptr) { udev_device_unref(ptr); }
|
||||
};
|
||||
|
||||
struct UdevEnumerateDeleter {
|
||||
void operator()(udev_enumerate *ptr) { udev_enumerate_unref(ptr); }
|
||||
};
|
||||
|
||||
struct UdevMonitorDeleter {
|
||||
void operator()(udev_monitor *ptr) { udev_monitor_unref(ptr); }
|
||||
};
|
||||
|
||||
void check_eq(int rc, int expected, const char *message = "eq, rc was: ") {
|
||||
if (rc != expected) {
|
||||
throw std::runtime_error(fmt::format(fmt::runtime(message), rc));
|
||||
@@ -201,7 +187,9 @@ BacklightBackend::BacklightBackend(std::chrono::milliseconds interval,
|
||||
const auto &event = events[i];
|
||||
check_eq(event.data.fd, udev_fd, "unexpected udev fd");
|
||||
std::unique_ptr<udev_device, UdevDeviceDeleter> dev{udev_monitor_receive_device(mon.get())};
|
||||
check_nn(dev.get(), "epoll dev was null");
|
||||
if (!dev) {
|
||||
continue;
|
||||
}
|
||||
upsert_device(devices, dev.get());
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ EnumType EnumParser<EnumType>::parseStringToEnum(const std::string& str,
|
||||
// Explicit instantiations for specific EnumType types you intend to use
|
||||
// Add explicit instantiations for all relevant EnumType types
|
||||
template struct EnumParser<modules::hyprland::Workspaces::SortMethod>;
|
||||
template struct EnumParser<modules::hyprland::Workspaces::ActiveWindowPosition>;
|
||||
template struct EnumParser<util::KillSignalAction>;
|
||||
|
||||
} // namespace waybar::util
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
[wrap-file]
|
||||
directory = cava-0.10.4
|
||||
source_url = https://github.com/LukashonakV/cava/archive/0.10.4.tar.gz
|
||||
source_filename = cava-0.10.4.tar.gz
|
||||
source_hash =7bc1c1f9535f2bcc5cd2ae8a2434a2e3a05f5670b1c96316df304137ffc65756
|
||||
[provide]
|
||||
cava = cava_dep
|
||||
@@ -1,13 +1,13 @@
|
||||
[wrap-file]
|
||||
directory = fmt-11.0.2
|
||||
source_url = https://github.com/fmtlib/fmt/archive/11.0.2.tar.gz
|
||||
source_filename = fmt-11.0.2.tar.gz
|
||||
source_hash = 6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f
|
||||
patch_filename = fmt_11.0.2-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/fmt_11.0.2-1/get_patch
|
||||
patch_hash = 90c9e3b8e8f29713d40ca949f6f93ad115d78d7fb921064112bc6179e6427c5e
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/fmt_11.0.2-1/fmt-11.0.2.tar.gz
|
||||
wrapdb_version = 11.0.2-1
|
||||
directory = fmt-12.0.0
|
||||
source_url = https://github.com/fmtlib/fmt/archive/12.0.0.tar.gz
|
||||
source_filename = fmt-12.0.0.tar.gz
|
||||
source_hash = aa3e8fbb6a0066c03454434add1f1fc23299e85758ceec0d7d2d974431481e40
|
||||
patch_filename = fmt_12.0.0-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/fmt_12.0.0-1/get_patch
|
||||
patch_hash = 307f288ebf3850abf2f0c50ac1fb07de97df9538d39146d802f3c0d6cada8998
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/fmt_12.0.0-1/fmt-12.0.0.tar.gz
|
||||
wrapdb_version = 12.0.0-1
|
||||
|
||||
[provide]
|
||||
fmt = fmt_dep
|
||||
|
||||
12
subprojects/libcava.wrap
Normal file
12
subprojects/libcava.wrap
Normal file
@@ -0,0 +1,12 @@
|
||||
#[wrap-git]
|
||||
#url = https://github.com/LukashonakV/cava.git
|
||||
#revision = 866cfec40b7b9d38e97148d004d3134c1385b52f
|
||||
#depth = 1
|
||||
|
||||
[wrap-file]
|
||||
directory = cava-0.10.7-beta
|
||||
source_url = https://github.com/LukashonakV/cava/archive/v0.10.7-beta.tar.gz
|
||||
source_filename = cava-0.10.7.tar.gz
|
||||
source_hash = 8915d7214f2046554c158fe6f2ae518881dfb573e421ea848727be11a5dfa8c4
|
||||
[provide]
|
||||
libcava = cava_dep
|
||||
@@ -1,13 +1,13 @@
|
||||
[wrap-file]
|
||||
directory = spdlog-1.14.1
|
||||
source_url = https://github.com/gabime/spdlog/archive/refs/tags/v1.14.1.tar.gz
|
||||
source_filename = spdlog-1.14.1.tar.gz
|
||||
source_hash = 1586508029a7d0670dfcb2d97575dcdc242d3868a259742b69f100801ab4e16b
|
||||
patch_filename = spdlog_1.14.1-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/spdlog_1.14.1-1/get_patch
|
||||
patch_hash = ae878e732330ea1048f90d7e117c40c0cd2a6fb8ae5492c7955818ce3aaade6c
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/spdlog_1.14.1-1/spdlog-1.14.1.tar.gz
|
||||
wrapdb_version = 1.14.1-1
|
||||
directory = spdlog-1.15.2
|
||||
source_url = https://github.com/gabime/spdlog/archive/refs/tags/v1.15.2.tar.gz
|
||||
source_filename = spdlog-1.15.2.tar.gz
|
||||
source_hash = 7a80896357f3e8e920e85e92633b14ba0f229c506e6f978578bdc35ba09e9a5d
|
||||
patch_filename = spdlog_1.15.2-3_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/spdlog_1.15.2-3/get_patch
|
||||
patch_hash = d5ab078661f571ef5113a8e4bc5c4121e16c044e7772a24b44b1ca8f3ee7c6cb
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/spdlog_1.15.2-3/spdlog-1.15.2.tar.gz
|
||||
wrapdb_version = 1.15.2-3
|
||||
|
||||
[provide]
|
||||
spdlog = spdlog_dep
|
||||
|
||||
@@ -84,6 +84,33 @@ TEST_CASE("Load simple config with include", "[config]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Load simple config with wildcard include", "[config]") {
|
||||
waybar::Config conf;
|
||||
conf.load("test/config/include-wildcard.json");
|
||||
|
||||
auto& data = conf.getConfig();
|
||||
SECTION("validate cpu include file") { REQUIRE(data["cpu"]["format"].asString() == "goo"); }
|
||||
SECTION("validate memory include file") { REQUIRE(data["memory"]["format"].asString() == "foo"); }
|
||||
}
|
||||
|
||||
TEST_CASE("Load config using relative paths and wildcards", "[config]") {
|
||||
waybar::Config conf;
|
||||
|
||||
const char* old_config_path = std::getenv(waybar::Config::CONFIG_PATH_ENV);
|
||||
setenv(waybar::Config::CONFIG_PATH_ENV, "test/config", 1);
|
||||
|
||||
conf.load("test/config/include-relative-path.json");
|
||||
|
||||
auto& data = conf.getConfig();
|
||||
SECTION("validate cpu include file") { REQUIRE(data["cpu"]["format"].asString() == "goo"); }
|
||||
SECTION("validate memory include file") { REQUIRE(data["memory"]["format"].asString() == "foo"); }
|
||||
|
||||
if (old_config_path)
|
||||
setenv(waybar::Config::CONFIG_PATH_ENV, old_config_path, 1);
|
||||
else
|
||||
unsetenv(waybar::Config::CONFIG_PATH_ENV);
|
||||
}
|
||||
|
||||
TEST_CASE("Load multiple bar config with include", "[config]") {
|
||||
waybar::Config conf;
|
||||
conf.load("test/config/include-multi.json");
|
||||
|
||||
5
test/config/include-relative-path.json
Normal file
5
test/config/include-relative-path.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"include": ["modules/*.jsonc"],
|
||||
"position": "top",
|
||||
"nullOption": null
|
||||
}
|
||||
5
test/config/include-wildcard.json
Normal file
5
test/config/include-wildcard.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"include": ["test/config/modules/*.jsonc"],
|
||||
"position": "top",
|
||||
"nullOption": null
|
||||
}
|
||||
6
test/config/modules/cpu.jsonc
Normal file
6
test/config/modules/cpu.jsonc
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"cpu": {
|
||||
"interval": 2,
|
||||
"format": "goo"
|
||||
}
|
||||
}
|
||||
6
test/config/modules/memory.jsonc
Normal file
6
test/config/modules/memory.jsonc
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"memory": {
|
||||
"interval": 2,
|
||||
"format": "foo",
|
||||
}
|
||||
}
|
||||
7
tsan.supp
Normal file
7
tsan.supp
Normal file
@@ -0,0 +1,7 @@
|
||||
# Suppress common thread issues in dependencies, these are often non-fixable or not an issue.
|
||||
# Use it like this (when in repo root): TSAN_OPTIONS="suppressions=./tsan.supp" ./build/waybar
|
||||
race:libfontconfig.so
|
||||
race:libglib-2.0.so
|
||||
race:libpango-1.0.so
|
||||
race:libc.so.6
|
||||
race:libgio-2.0.so
|
||||
Reference in New Issue
Block a user