Merge tag '0.15.0' of https://github.com/Alexays/Waybar
Some checks failed
clang-format / lint (push) Has been cancelled
freebsd / build (push) Has been cancelled
linux / build (c++20, alpine) (push) Has been cancelled
linux / build (c++20, archlinux) (push) Has been cancelled
linux / build (c++20, debian) (push) Has been cancelled
linux / build (c++20, fedora) (push) Has been cancelled
linux / build (c++20, gentoo) (push) Has been cancelled
linux / build (c++20, opensuse) (push) Has been cancelled
Nix-Tests / nix-flake-check (push) Has been cancelled

This commit is contained in:
2026-02-19 20:54:36 -08:00
116 changed files with 2513 additions and 1511 deletions

View File

@ -17,11 +17,11 @@ namespace waybar::modules {
class Backlight : public ALabel {
public:
Backlight(const std::string &, const Json::Value &);
Backlight(const std::string&, const Json::Value&);
virtual ~Backlight() = default;
auto update() -> void override;
bool handleScroll(GdkEventScroll *e) override;
bool handleScroll(GdkEventScroll* e) override;
const std::string preferred_device_;

View 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_;

View 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

View File

@ -9,20 +9,20 @@ class Cava final : public ALabel, public sigc::trackable {
public:
Cava(const std::string&, const Json::Value&);
~Cava() = default;
auto onUpdate(const std::string& input) -> void;
auto onSilence() -> void;
auto doAction(const std::string& name) -> void override;
private:
std::shared_ptr<CavaBackend> backend_;
// Text to display
std::string label_text_{""};
Glib::ustring label_text_{""};
bool silence_{false};
bool hide_on_silence_{false};
std::string format_silent_{""};
int ascii_range_{0};
bool silence_{false};
// 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}};

View File

@ -32,29 +32,36 @@ class CavaBackend final {
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 thread_;
util::SleeperThread read_thread_;
util::SleeperThread out_thread_;
// Cava API to read audio source
::cava::ptr input_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_; //{new cava_plan{}};
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};
@ -66,9 +73,12 @@ class CavaBackend final {
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

View 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

View File

@ -12,23 +12,23 @@ namespace waybar::modules::dwl {
class Tags : public waybar::AModule {
public:
Tags(const std::string &, const waybar::Bar &, const Json::Value &);
Tags(const std::string&, const waybar::Bar&, const Json::Value&);
virtual ~Tags();
// Handlers for wayland events
void handle_view_tags(uint32_t tag, uint32_t state, uint32_t clients, uint32_t focused);
void handle_primary_clicked(uint32_t tag);
bool handle_button_press(GdkEventButton *event_button, uint32_t tag);
bool handle_button_press(GdkEventButton* event_button, uint32_t tag);
struct zdwl_ipc_manager_v2 *status_manager_;
struct wl_seat *seat_;
struct zdwl_ipc_manager_v2* status_manager_;
struct wl_seat* seat_;
private:
const waybar::Bar &bar_;
const waybar::Bar& bar_;
Gtk::Box box_;
std::vector<Gtk::Button> buttons_;
struct zdwl_ipc_output_v2 *output_status_;
struct zdwl_ipc_output_v2* output_status_;
};
} /* namespace waybar::modules::dwl */

View File

@ -13,26 +13,26 @@ namespace waybar::modules::dwl {
class Window : public AAppIconLabel, public sigc::trackable {
public:
Window(const std::string &, const waybar::Bar &, const Json::Value &);
Window(const std::string&, const waybar::Bar&, const Json::Value&);
~Window();
void handle_layout(const uint32_t layout);
void handle_title(const char *title);
void handle_appid(const char *ppid);
void handle_layout_symbol(const char *layout_symbol);
void handle_title(const char* title);
void handle_appid(const char* ppid);
void handle_layout_symbol(const char* layout_symbol);
void handle_frame();
struct zdwl_ipc_manager_v2 *status_manager_;
struct zdwl_ipc_manager_v2* status_manager_;
private:
const Bar &bar_;
const Bar& bar_;
std::string title_;
std::string appid_;
std::string layout_symbol_;
uint32_t layout_;
struct zdwl_ipc_output_v2 *output_status_;
struct zdwl_ipc_output_v2* output_status_;
};
} // namespace waybar::modules::dwl

View File

@ -20,16 +20,16 @@ class Workspace;
class WorkspaceManager final : public AModule {
public:
WorkspaceManager(const std::string &id, const waybar::Bar &bar, const Json::Value &config);
WorkspaceManager(const std::string& id, const waybar::Bar& bar, const Json::Value& config);
~WorkspaceManager() override;
void register_manager(wl_registry *registry, uint32_t name, uint32_t version);
void register_manager(wl_registry* registry, uint32_t name, uint32_t version);
void remove_workspace_group(uint32_t id);
void remove_workspace(uint32_t id);
void set_needs_sorting() { needs_sorting_ = true; }
// wl events
void handle_workspace_group(ext_workspace_group_handle_v1 *handle);
void handle_workspace(ext_workspace_handle_v1 *handle);
void handle_workspace_group(ext_workspace_group_handle_v1* handle);
void handle_workspace(ext_workspace_handle_v1* handle);
void handle_done();
void handle_finished();
@ -38,7 +38,7 @@ class WorkspaceManager final : public AModule {
private:
void update() override;
bool has_button(const Gtk::Button *button);
bool has_button(const Gtk::Button* button);
void sort_workspaces();
void clear_buttons();
void update_buttons();
@ -52,10 +52,10 @@ class WorkspaceManager final : public AModule {
bool sort_by_coordinates_ = false;
bool all_outputs_ = false;
const waybar::Bar &bar_;
const waybar::Bar& bar_;
Gtk::Box box_;
ext_workspace_manager_v1 *ext_manager_ = nullptr;
ext_workspace_manager_v1* ext_manager_ = nullptr;
std::vector<std::unique_ptr<WorkspaceGroup>> groups_;
std::vector<std::unique_ptr<Workspace>> workspaces_;
@ -64,60 +64,60 @@ class WorkspaceManager final : public AModule {
class WorkspaceGroup {
public:
WorkspaceGroup(WorkspaceManager &manager, ext_workspace_group_handle_v1 *handle, uint32_t id);
WorkspaceGroup(WorkspaceManager& manager, ext_workspace_group_handle_v1* handle, uint32_t id);
~WorkspaceGroup();
u_int32_t id() const { return id_; }
bool has_output(const wl_output *output);
bool has_workspace(const ext_workspace_handle_v1 *workspace);
bool has_output(const wl_output* output);
bool has_workspace(const ext_workspace_handle_v1* workspace);
// wl events
void handle_capabilities(uint32_t capabilities);
void handle_output_enter(wl_output *output);
void handle_output_leave(wl_output *output);
void handle_workspace_enter(ext_workspace_handle_v1 *handle);
void handle_workspace_leave(ext_workspace_handle_v1 *handle);
void handle_output_enter(wl_output* output);
void handle_output_leave(wl_output* output);
void handle_workspace_enter(ext_workspace_handle_v1* handle);
void handle_workspace_leave(ext_workspace_handle_v1* handle);
void handle_removed();
private:
WorkspaceManager &workspaces_manager_;
ext_workspace_group_handle_v1 *ext_handle_;
WorkspaceManager& workspaces_manager_;
ext_workspace_group_handle_v1* ext_handle_;
uint32_t id_;
std::vector<wl_output *> outputs_;
std::vector<ext_workspace_handle_v1 *> workspaces_;
std::vector<wl_output*> outputs_;
std::vector<ext_workspace_handle_v1*> workspaces_;
};
class Workspace {
public:
Workspace(const Json::Value &config, WorkspaceManager &manager, ext_workspace_handle_v1 *handle,
uint32_t id, const std::string &name);
Workspace(const Json::Value& config, WorkspaceManager& manager, ext_workspace_handle_v1* handle,
uint32_t id, const std::string& name);
~Workspace();
ext_workspace_handle_v1 *handle() const { return ext_handle_; }
ext_workspace_handle_v1* handle() const { return ext_handle_; }
u_int32_t id() const { return id_; }
std::string &workspace_id() { return workspace_id_; }
std::string &name() { return name_; }
std::vector<u_int32_t> &coordinates() { return coordinates_; }
Gtk::Button &button() { return button_; }
std::string& workspace_id() { return workspace_id_; }
std::string& name() { return name_; }
std::vector<u_int32_t>& coordinates() { return coordinates_; }
Gtk::Button& button() { return button_; }
void update();
// wl events
void handle_id(const std::string &id);
void handle_name(const std::string &name);
void handle_coordinates(const std::vector<uint32_t> &coordinates);
void handle_id(const std::string& id);
void handle_name(const std::string& name);
void handle_coordinates(const std::vector<uint32_t>& coordinates);
void handle_state(uint32_t state);
void handle_capabilities(uint32_t capabilities);
void handle_removed();
// gdk events
bool handle_clicked(const GdkEventButton *button) const;
bool handle_clicked(const GdkEventButton* button) const;
private:
bool has_state(uint32_t state) const { return (state_ & state) == state; }
std::string icon();
WorkspaceManager &workspace_manager_;
ext_workspace_handle_v1 *ext_handle_ = nullptr;
WorkspaceManager& workspace_manager_;
ext_workspace_handle_v1* ext_handle_ = nullptr;
uint32_t id_;
uint32_t state_ = 0;
std::string workspace_id_;

View File

@ -1,10 +1,10 @@
#include "ext-workspace-v1-client-protocol.h"
namespace waybar::modules::ext {
void add_registry_listener(void *data);
void add_workspace_listener(ext_workspace_handle_v1 *workspace_handle, void *data);
void add_workspace_group_listener(ext_workspace_group_handle_v1 *workspace_group_handle,
void *data);
ext_workspace_manager_v1 *workspace_manager_bind(wl_registry *registry, uint32_t name,
uint32_t version, void *data);
void add_registry_listener(void* data);
void add_workspace_listener(ext_workspace_handle_v1* workspace_handle, void* data);
void add_workspace_group_listener(ext_workspace_group_handle_v1* workspace_group_handle,
void* data);
ext_workspace_manager_v1* workspace_manager_bind(wl_registry* registry, uint32_t name,
uint32_t version, void* data);
} // namespace waybar::modules::ext

View File

@ -17,7 +17,7 @@ namespace waybar::modules {
class Gamemode : public AModule {
public:
Gamemode(const std::string &, const Json::Value &);
Gamemode(const std::string&, const Json::Value&);
virtual ~Gamemode();
auto update() -> void override;
@ -28,18 +28,18 @@ class Gamemode : public AModule {
const std::string DEFAULT_TOOLTIP_FORMAT = "Games running: {count}";
const std::string DEFAULT_GLYPH = "";
void appear(const Glib::RefPtr<Gio::DBus::Connection> &connection, const Glib::ustring &name,
const Glib::ustring &name_owner);
void disappear(const Glib::RefPtr<Gio::DBus::Connection> &connection, const Glib::ustring &name);
void prepareForSleep_cb(const Glib::RefPtr<Gio::DBus::Connection> &connection,
const Glib::ustring &sender_name, const Glib::ustring &object_path,
const Glib::ustring &interface_name, const Glib::ustring &signal_name,
const Glib::VariantContainerBase &parameters);
void notify_cb(const Glib::ustring &sender_name, const Glib::ustring &signal_name,
const Glib::VariantContainerBase &arguments);
void appear(const Glib::RefPtr<Gio::DBus::Connection>& connection, const Glib::ustring& name,
const Glib::ustring& name_owner);
void disappear(const Glib::RefPtr<Gio::DBus::Connection>& connection, const Glib::ustring& name);
void prepareForSleep_cb(const Glib::RefPtr<Gio::DBus::Connection>& connection,
const Glib::ustring& sender_name, const Glib::ustring& object_path,
const Glib::ustring& interface_name, const Glib::ustring& signal_name,
const Glib::VariantContainerBase& parameters);
void notify_cb(const Glib::ustring& sender_name, const Glib::ustring& signal_name,
const Glib::VariantContainerBase& arguments);
void getData();
bool handleToggle(GdkEventButton *const &) override;
bool handleToggle(GdkEventButton* const&) override;
// Config
std::string format = DEFAULT_FORMAT;

View File

@ -26,6 +26,7 @@ class Submap : public waybar::ALabel, public EventHandler {
const Bar& bar_;
util::JsonParser parser_;
std::string submap_;
std::string prev_submap_;
bool always_on_ = false;
std::string default_submap_ = "Default";

View File

@ -13,7 +13,7 @@ namespace waybar::modules {
class JACK : public ALabel {
public:
JACK(const std::string &, const Json::Value &);
JACK(const std::string&, const Json::Value&);
virtual ~JACK() = default;
auto update() -> void override;
@ -25,7 +25,7 @@ class JACK : public ALabel {
private:
std::string JACKState();
jack_client_t *client_;
jack_client_t* client_;
jack_nframes_t bufsize_;
jack_nframes_t samplerate_;
unsigned int xruns_;
@ -38,7 +38,7 @@ class JACK : public ALabel {
} // namespace waybar::modules
int bufSizeCallback(jack_nframes_t size, void *obj);
int sampleRateCallback(jack_nframes_t rate, void *obj);
int xrunCallback(void *obj);
void shutdownCallback(void *obj);
int bufSizeCallback(jack_nframes_t size, void* obj);
int sampleRateCallback(jack_nframes_t rate, void* obj);
int xrunCallback(void* obj);
void shutdownCallback(void* obj);

View File

@ -10,13 +10,13 @@ namespace waybar::modules::niri {
class Language : public ALabel, public EventHandler {
public:
Language(const std::string &, const Bar &, const Json::Value &);
Language(const std::string&, const Bar&, const Json::Value&);
~Language() override;
void update() override;
private:
void updateFromIPC();
void onEvent(const Json::Value &ev) override;
void onEvent(const Json::Value& ev) override;
void doUpdate();
struct Layout {
@ -26,10 +26,10 @@ class Language : public ALabel, public EventHandler {
std::string short_description;
};
static Layout getLayout(const std::string &fullName);
static Layout getLayout(const std::string& fullName);
std::mutex mutex_;
const Bar &bar_;
const Bar& bar_;
std::vector<Layout> layouts_;
unsigned current_idx_;

View File

@ -11,16 +11,16 @@ namespace waybar::modules::niri {
class Window : public AAppIconLabel, public EventHandler {
public:
Window(const std::string &, const Bar &, const Json::Value &);
Window(const std::string&, const Bar&, const Json::Value&);
~Window() override;
void update() override;
private:
void onEvent(const Json::Value &ev) override;
void onEvent(const Json::Value& ev) override;
void doUpdate();
void setClass(const std::string &className, bool enable);
void setClass(const std::string& className, bool enable);
const Bar &bar_;
const Bar& bar_;
std::string oldAppId_;
};

View File

@ -11,17 +11,17 @@ namespace waybar::modules::niri {
class Workspaces : public AModule, public EventHandler {
public:
Workspaces(const std::string &, const Bar &, const Json::Value &);
Workspaces(const std::string&, const Bar&, const Json::Value&);
~Workspaces() override;
void update() override;
private:
void onEvent(const Json::Value &ev) override;
void onEvent(const Json::Value& ev) override;
void doUpdate();
Gtk::Button &addButton(const Json::Value &ws);
std::string getIcon(const std::string &value, const Json::Value &ws);
Gtk::Button& addButton(const Json::Value& ws);
std::string getIcon(const std::string& value, const Json::Value& ws);
const Bar &bar_;
const Bar& bar_;
Gtk::Box box_;
// Map from niri workspace id to button.
std::unordered_map<uint64_t, Gtk::Button> buttons_;

View File

@ -16,15 +16,15 @@ struct Profile {
class PowerProfilesDaemon : public ALabel {
public:
PowerProfilesDaemon(const std::string &, const Json::Value &);
PowerProfilesDaemon(const std::string&, const Json::Value&);
auto update() -> void override;
void profileChangedCb(const Gio::DBus::Proxy::MapChangedProperties &,
const std::vector<Glib::ustring> &);
void busConnectedCb(Glib::RefPtr<Gio::AsyncResult> &r);
void getAllPropsCb(Glib::RefPtr<Gio::AsyncResult> &r);
void setPropCb(Glib::RefPtr<Gio::AsyncResult> &r);
void profileChangedCb(const Gio::DBus::Proxy::MapChangedProperties&,
const std::vector<Glib::ustring>&);
void busConnectedCb(Glib::RefPtr<Gio::AsyncResult>& r);
void getAllPropsCb(Glib::RefPtr<Gio::AsyncResult>& r);
void setPropCb(Glib::RefPtr<Gio::AsyncResult>& r);
void populateInitState();
bool handleToggle(GdkEventButton *const &e) override;
bool handleToggle(GdkEventButton* const& e) override;
private:
// True if we're connected to the dbug interface. False if we're
@ -32,7 +32,7 @@ class PowerProfilesDaemon : public ALabel {
bool connected_;
// Look for a profile name in the list of available profiles and
// switch activeProfile_ to it.
void switchToProfile(std::string const &);
void switchToProfile(std::string const&);
// Used to toggle/display the profiles
std::vector<Profile> availableProfiles_;
// Points to the active profile in the profiles list

View File

@ -13,15 +13,15 @@ namespace waybar::modules::privacy {
class Privacy : public AModule {
public:
Privacy(const std::string &, const Json::Value &, Gtk::Orientation, const std::string &pos);
Privacy(const std::string&, const Json::Value&, Gtk::Orientation, const std::string& pos);
auto update() -> void override;
void onPrivacyNodesChanged();
private:
std::list<PrivacyNodeInfo *> nodes_screenshare; // Screen is being shared
std::list<PrivacyNodeInfo *> nodes_audio_in; // Application is using the microphone
std::list<PrivacyNodeInfo *> nodes_audio_out; // Application is outputting audio
std::list<PrivacyNodeInfo*> nodes_screenshare; // Screen is being shared
std::list<PrivacyNodeInfo*> nodes_audio_in; // Application is using the microphone
std::list<PrivacyNodeInfo*> nodes_audio_out; // Application is outputting audio
std::mutex mutex_;
sigc::connection visibility_conn;

View File

@ -16,16 +16,16 @@ namespace waybar::modules::privacy {
class PrivacyItem : public Gtk::Revealer {
public:
PrivacyItem(const Json::Value &config_, enum PrivacyNodeType privacy_type_,
std::list<PrivacyNodeInfo *> *nodes, Gtk::Orientation orientation,
const std::string &pos, const uint icon_size, const uint transition_duration);
PrivacyItem(const Json::Value& config_, enum PrivacyNodeType privacy_type_,
std::list<PrivacyNodeInfo*>* nodes, Gtk::Orientation orientation,
const std::string& pos, const uint icon_size, const uint transition_duration);
enum PrivacyNodeType privacy_type;
void set_in_use(bool in_use);
private:
std::list<PrivacyNodeInfo *> *nodes;
std::list<PrivacyNodeInfo*>* nodes;
sigc::connection signal_conn;

View File

@ -10,25 +10,25 @@ namespace waybar::modules::river {
class Layout : public waybar::ALabel {
public:
Layout(const std::string &, const waybar::Bar &, const Json::Value &);
Layout(const std::string&, const waybar::Bar&, const Json::Value&);
virtual ~Layout();
// Handlers for wayland events
void handle_name(const char *name);
void handle_name(const char* name);
void handle_clear();
void handle_focused_output(struct wl_output *output);
void handle_unfocused_output(struct wl_output *output);
void handle_focused_output(struct wl_output* output);
void handle_unfocused_output(struct wl_output* output);
struct zriver_status_manager_v1 *status_manager_;
struct wl_seat *seat_;
struct zriver_status_manager_v1* status_manager_;
struct wl_seat* seat_;
private:
const waybar::Bar &bar_;
const waybar::Bar& bar_;
std::string name_;
struct wl_output *output_; // stores the output this module belongs to
struct wl_output *focused_output_; // stores the currently focused output
struct zriver_output_status_v1 *output_status_;
struct zriver_seat_status_v1 *seat_status_;
struct wl_output* output_; // stores the output this module belongs to
struct wl_output* focused_output_; // stores the currently focused output
struct zriver_output_status_v1* output_status_;
struct zriver_seat_status_v1* seat_status_;
};
} /* namespace waybar::modules::river */

View File

@ -10,20 +10,20 @@ namespace waybar::modules::river {
class Mode : public waybar::ALabel {
public:
Mode(const std::string &, const waybar::Bar &, const Json::Value &);
Mode(const std::string&, const waybar::Bar&, const Json::Value&);
virtual ~Mode();
// Handlers for wayland events
void handle_mode(const char *mode);
void handle_mode(const char* mode);
struct zriver_status_manager_v1 *status_manager_;
struct wl_seat *seat_;
struct zriver_status_manager_v1* status_manager_;
struct wl_seat* seat_;
private:
const waybar::Bar &bar_;
const waybar::Bar& bar_;
std::set<std::string> hidden_modes_;
std::string mode_;
struct zriver_seat_status_v1 *seat_status_;
struct zriver_seat_status_v1* seat_status_;
};
} /* namespace waybar::modules::river */

View File

@ -13,32 +13,32 @@ namespace waybar::modules::river {
class Tags : public waybar::AModule {
public:
Tags(const std::string &, const waybar::Bar &, const Json::Value &);
Tags(const std::string&, const waybar::Bar&, const Json::Value&);
virtual ~Tags();
// Handlers for wayland events
void handle_focused_tags(uint32_t tags);
void handle_view_tags(struct wl_array *tags);
void handle_view_tags(struct wl_array* tags);
void handle_urgent_tags(uint32_t tags);
void handle_focused_view(const char *title, uint32_t tags);
void handle_show();
void handle_primary_clicked(uint32_t tag);
bool handle_button_press(GdkEventButton *event_button, uint32_t tag);
bool handle_button_press(GdkEventButton* event_button, uint32_t tag);
struct zriver_status_manager_v1 *status_manager_;
struct zriver_control_v1 *control_;
struct zriver_status_manager_v1* status_manager_;
struct zriver_control_v1* control_;
struct zriver_seat_status_v1 *seat_status_;
struct wl_seat *seat_;
struct wl_seat* seat_;
// used to make sure the focused view tags are on the correct output
const wl_output *output_;
const wl_output *focused_output_;
const wl_output* output_;
const wl_output* focused_output_;
private:
const waybar::Bar &bar_;
const waybar::Bar& bar_;
Gtk::Box box_;
std::vector<Gtk::Button> buttons_;
struct zriver_output_status_v1 *output_status_;
struct zriver_output_status_v1* output_status_;
};
} /* namespace waybar::modules::river */

View File

@ -14,23 +14,23 @@ namespace waybar::modules::river {
class Window : public waybar::ALabel {
public:
Window(const std::string &, const waybar::Bar &, const Json::Value &);
Window(const std::string&, const waybar::Bar&, const Json::Value&);
virtual ~Window();
// Handlers for wayland events
void handle_focused_view(const char *title, uint32_t);
void handle_focused_output(struct wl_output *output);
void handle_unfocused_output(struct wl_output *output);
void handle_focused_view(const char* title, uint32_t tags);
void handle_focused_output(struct wl_output* output);
void handle_unfocused_output(struct wl_output* output);
struct zriver_status_manager_v1 *status_manager_;
struct wl_seat *seat_;
struct zriver_status_manager_v1* status_manager_;
struct wl_seat* seat_;
private:
const waybar::Bar &bar_;
const waybar::Bar& bar_;
std::optional<std::string> default_format_; // format when there is no window
struct wl_output *output_; // stores the output this module belongs to
struct wl_output *focused_output_; // stores the currently focused output
struct zriver_seat_status_v1 *seat_status_;
struct wl_output* output_; // stores the output this module belongs to
struct wl_output* focused_output_; // stores the currently focused output
struct zriver_seat_status_v1* seat_status_;
};
} /* namespace waybar::modules::river */

View File

@ -11,18 +11,18 @@ namespace waybar::modules {
class Sndio : public ALabel {
public:
Sndio(const std::string &, const Json::Value &);
Sndio(const std::string&, const Json::Value&);
virtual ~Sndio();
auto update() -> void override;
auto set_desc(struct sioctl_desc *, unsigned int) -> void;
auto set_desc(struct sioctl_desc*, unsigned int) -> void;
auto put_val(unsigned int, unsigned int) -> void;
bool handleScroll(GdkEventScroll *) override;
bool handleToggle(GdkEventButton *const &) override;
bool handleScroll(GdkEventScroll*) override;
bool handleToggle(GdkEventButton* const&) override;
private:
auto connect_to_sndio() -> void;
util::SleeperThread thread_;
struct sioctl_hdl *hdl_;
struct sioctl_hdl* hdl_;
std::vector<struct pollfd> pfds_;
unsigned int addr_;
unsigned int volume_, old_volume_, maxval_;

View File

@ -30,27 +30,27 @@ class Watcher {
typedef struct {
GfWatchType type;
Watcher *watcher;
gchar *service;
gchar *bus_name;
gchar *object_path;
Watcher* watcher;
gchar* service;
gchar* bus_name;
gchar* object_path;
guint watch_id;
} GfWatch;
void busAcquired(const Glib::RefPtr<Gio::DBus::Connection> &, Glib::ustring);
static gboolean handleRegisterHost(Watcher *, GDBusMethodInvocation *, const gchar *);
static gboolean handleRegisterItem(Watcher *, GDBusMethodInvocation *, const gchar *);
static GfWatch *gfWatchFind(GSList *list, const gchar *bus_name, const gchar *object_path);
static GfWatch *gfWatchNew(GfWatchType, const gchar *, const gchar *, const gchar *, Watcher *);
static void nameVanished(GDBusConnection *connection, const char *name, gpointer data);
void busAcquired(const Glib::RefPtr<Gio::DBus::Connection>&, Glib::ustring);
static gboolean handleRegisterHost(Watcher*, GDBusMethodInvocation*, const gchar*);
static gboolean handleRegisterItem(Watcher*, GDBusMethodInvocation*, const gchar*);
static GfWatch* gfWatchFind(GSList* list, const gchar* bus_name, const gchar* object_path);
static GfWatch* gfWatchNew(GfWatchType, const gchar*, const gchar*, const gchar*, Watcher*);
static void nameVanished(GDBusConnection* connection, const char* name, gpointer data);
static void gfWatchFree(gpointer data);
void updateRegisteredItems(SnWatcher *obj);
void updateRegisteredItems(SnWatcher* obj);
uint32_t bus_name_id_;
GSList *hosts_ = nullptr;
GSList *items_ = nullptr;
SnWatcher *watcher_ = nullptr;
GSList* hosts_ = nullptr;
GSList* items_ = nullptr;
SnWatcher* watcher_ = nullptr;
};
} // namespace waybar::modules::SNI

View File

@ -27,21 +27,21 @@ class Ipc {
std::string payload;
};
sigc::signal<void, const struct ipc_response &> signal_event;
sigc::signal<void, const struct ipc_response &> signal_cmd;
sigc::signal<void, const struct ipc_response&> signal_event;
sigc::signal<void, const struct ipc_response&> signal_cmd;
void sendCmd(uint32_t type, const std::string &payload = "");
void subscribe(const std::string &payload);
void sendCmd(uint32_t type, const std::string& payload = "");
void subscribe(const std::string& payload);
void handleEvent();
void setWorker(std::function<void()> &&func);
void setWorker(std::function<void()>&& func);
protected:
static inline const std::string ipc_magic_ = "i3-ipc";
static inline const size_t ipc_header_size_ = ipc_magic_.size() + 8;
const std::string getSocketPath() const;
int open(const std::string &) const;
struct ipc_response send(int fd, uint32_t type, const std::string &payload = "");
int open(const std::string&) const;
struct ipc_response send(int fd, uint32_t type, const std::string& payload = "");
struct ipc_response recv(int fd);
int fd_;

View File

@ -10,7 +10,7 @@ namespace waybar::modules {
class SystemdFailedUnits : public ALabel {
public:
SystemdFailedUnits(const std::string &, const Json::Value &);
SystemdFailedUnits(const std::string&, const Json::Value&);
virtual ~SystemdFailedUnits();
auto update() -> void override;
@ -24,8 +24,8 @@ class SystemdFailedUnits : public ALabel {
std::string last_status;
Glib::RefPtr<Gio::DBus::Proxy> system_proxy, user_proxy;
void notify_cb(const Glib::ustring &sender_name, const Glib::ustring &signal_name,
const Glib::VariantContainerBase &arguments);
void notify_cb(const Glib::ustring& sender_name, const Glib::ustring& signal_name,
const Glib::VariantContainerBase& arguments);
void RequestFailedUnits();
void RequestSystemState();
void updateData();

View File

@ -12,7 +12,7 @@ namespace waybar::modules {
class UPower final : public AIconLabel {
public:
UPower(const std::string &, const Json::Value &);
UPower(const std::string&, const Json::Value&);
virtual ~UPower();
auto update() -> void override;
@ -30,17 +30,17 @@ class UPower final : public AIconLabel {
// UPower device info
struct upDevice_output {
UpDevice *upDevice{NULL};
UpDevice* upDevice{NULL};
double percentage{0.0};
double temperature{0.0};
guint64 time_full{0u};
guint64 time_empty{0u};
gchar *icon_name{(char *)'\0'};
gchar* icon_name{(char*)'\0'};
bool upDeviceValid{false};
UpDeviceState state;
UpDeviceKind kind;
char *nativePath{(char *)'\0'};
char *model{(char *)'\0'};
char* nativePath{(char*)'\0'};
char* model{(char*)'\0'};
};
// Technical variables
@ -53,13 +53,13 @@ class UPower final : public AIconLabel {
bool sleeping_;
// Technical functions
void addDevice(UpDevice *);
void removeDevice(const gchar *);
void addDevice(UpDevice*);
void removeDevice(const gchar*);
void removeDevices();
void resetDevices();
void setDisplayDevice();
const Glib::ustring getText(const upDevice_output &upDevice_, const std::string &format);
bool queryTooltipCb(int, int, bool, const Glib::RefPtr<Gtk::Tooltip> &);
const Glib::ustring getText(const upDevice_output& upDevice_, const std::string& format);
bool queryTooltipCb(int, int, bool, const Glib::RefPtr<Gtk::Tooltip>&);
// DBUS variables
guint watcherID_;
@ -67,28 +67,28 @@ class UPower final : public AIconLabel {
guint subscrID_{0u};
// UPower variables
UpClient *upClient_;
UpClient* upClient_;
upDevice_output upDevice_; // Device to display
typedef std::unordered_map<std::string, upDevice_output> Devices;
Devices devices_;
bool upRunning_{true};
// DBus callbacks
void getConn_cb(Glib::RefPtr<Gio::AsyncResult> &result);
void onAppear(const Glib::RefPtr<Gio::DBus::Connection> &, const Glib::ustring &,
const Glib::ustring &);
void onVanished(const Glib::RefPtr<Gio::DBus::Connection> &, const Glib::ustring &);
void prepareForSleep_cb(const Glib::RefPtr<Gio::DBus::Connection> &connection,
const Glib::ustring &sender_name, const Glib::ustring &object_path,
const Glib::ustring &interface_name, const Glib::ustring &signal_name,
const Glib::VariantContainerBase &parameters);
void getConn_cb(Glib::RefPtr<Gio::AsyncResult>& result);
void onAppear(const Glib::RefPtr<Gio::DBus::Connection>&, const Glib::ustring&,
const Glib::ustring&);
void onVanished(const Glib::RefPtr<Gio::DBus::Connection>&, const Glib::ustring&);
void prepareForSleep_cb(const Glib::RefPtr<Gio::DBus::Connection>& connection,
const Glib::ustring& sender_name, const Glib::ustring& object_path,
const Glib::ustring& interface_name, const Glib::ustring& signal_name,
const Glib::VariantContainerBase& parameters);
// UPower callbacks
static void deviceAdded_cb(UpClient *client, UpDevice *device, gpointer data);
static void deviceRemoved_cb(UpClient *client, const gchar *objectPath, gpointer data);
static void deviceNotify_cb(UpDevice *device, GParamSpec *pspec, gpointer user_data);
static void deviceAdded_cb(UpClient* client, UpDevice* device, gpointer data);
static void deviceRemoved_cb(UpClient* client, const gchar* objectPath, gpointer data);
static void deviceNotify_cb(UpDevice* device, GParamSpec* pspec, gpointer user_data);
// UPower secondary functions
void getUpDeviceInfo(upDevice_output &upDevice_);
void getUpDeviceInfo(upDevice_output& upDevice_);
};
} // namespace waybar::modules

View File

@ -33,8 +33,8 @@ class Taskbar;
class Task {
public:
Task(const waybar::Bar &, const Json::Value &, Taskbar *,
struct zwlr_foreign_toplevel_handle_v1 *, struct wl_seat *);
Task(const waybar::Bar&, const Json::Value&, Taskbar*, struct zwlr_foreign_toplevel_handle_v1*,
struct wl_seat*);
~Task();
public:
@ -53,11 +53,11 @@ class Task {
static uint32_t global_id;
private:
const waybar::Bar &bar_;
const Json::Value &config_;
Taskbar *tbar_;
struct zwlr_foreign_toplevel_handle_v1 *handle_;
struct wl_seat *seat_;
const waybar::Bar& bar_;
const Json::Value& config_;
Taskbar* tbar_;
struct zwlr_foreign_toplevel_handle_v1* handle_;
struct wl_seat* seat_;
uint32_t id_;
@ -89,7 +89,7 @@ class Task {
std::string repr() const;
std::string state_string(bool = false) const;
void set_minimize_hint();
void on_button_size_allocated(Gtk::Allocation &alloc);
void on_button_size_allocated(Gtk::Allocation& alloc);
void hide_if_ignored();
public:
@ -105,26 +105,26 @@ class Task {
public:
/* Callbacks for the wlr protocol */
void handle_title(const char *);
void handle_app_id(const char *);
void handle_output_enter(struct wl_output *);
void handle_output_leave(struct wl_output *);
void handle_state(struct wl_array *);
void handle_title(const char*);
void handle_app_id(const char*);
void handle_output_enter(struct wl_output*);
void handle_output_leave(struct wl_output*);
void handle_state(struct wl_array*);
void handle_done();
void handle_closed();
/* Callbacks for Gtk events */
bool handle_clicked(GdkEventButton *);
bool handle_button_release(GdkEventButton *);
bool handle_motion_notify(GdkEventMotion *);
void handle_drag_data_get(const Glib::RefPtr<Gdk::DragContext> &context,
Gtk::SelectionData &selection_data, guint info, guint time);
void handle_drag_data_received(const Glib::RefPtr<Gdk::DragContext> &context, int x, int y,
bool handle_clicked(GdkEventButton*);
bool handle_button_release(GdkEventButton*);
bool handle_motion_notify(GdkEventMotion*);
void handle_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context,
Gtk::SelectionData& selection_data, guint info, guint time);
void handle_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y,
Gtk::SelectionData selection_data, guint info, guint time);
public:
bool operator==(const Task &) const;
bool operator!=(const Task &) const;
bool operator==(const Task&) const;
bool operator!=(const Task&) const;
public:
void update();
@ -142,12 +142,12 @@ using TaskPtr = std::unique_ptr<Task>;
class Taskbar : public waybar::AModule {
public:
Taskbar(const std::string &, const waybar::Bar &, const Json::Value &);
Taskbar(const std::string&, const waybar::Bar&, const Json::Value&);
~Taskbar();
void update();
private:
const waybar::Bar &bar_;
const waybar::Bar& bar_;
Gtk::Box box_;
std::vector<TaskPtr> tasks_;
@ -155,30 +155,30 @@ class Taskbar : public waybar::AModule {
std::unordered_set<std::string> ignore_list_;
std::map<std::string, std::string> app_ids_replace_map_;
struct zwlr_foreign_toplevel_manager_v1 *manager_;
struct wl_seat *seat_;
struct zwlr_foreign_toplevel_manager_v1* manager_;
struct wl_seat* seat_;
public:
/* Callbacks for global registration */
void register_manager(struct wl_registry *, uint32_t name, uint32_t version);
void register_seat(struct wl_registry *, uint32_t name, uint32_t version);
void register_manager(struct wl_registry*, uint32_t name, uint32_t version);
void register_seat(struct wl_registry*, uint32_t name, uint32_t version);
/* Callbacks for the wlr protocol */
void handle_toplevel_create(struct zwlr_foreign_toplevel_handle_v1 *);
void handle_toplevel_create(struct zwlr_foreign_toplevel_handle_v1*);
void handle_finished();
public:
void add_button(Gtk::Button &);
void move_button(Gtk::Button &, int);
void remove_button(Gtk::Button &);
void add_button(Gtk::Button&);
void move_button(Gtk::Button&, int);
void remove_button(Gtk::Button&);
void remove_task(uint32_t);
bool show_output(struct wl_output *) const;
bool show_output(struct wl_output*) const;
bool all_outputs() const;
const IconLoader &icon_loader() const;
const std::unordered_set<std::string> &ignore_list() const;
const std::map<std::string, std::string> &app_ids_replace_map() const;
const IconLoader& icon_loader() const;
const std::unordered_set<std::string>& ignore_list() const;
const std::map<std::string, std::string>& app_ids_replace_map() const;
};
} /* namespace waybar::modules::wlr */