Merge remote-tracking branch 'origin/master' into pr-4537
# Conflicts: # include/modules/niri/workspaces.hpp # src/modules/niri/workspaces.cpp
This commit is contained in:
@@ -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_;
|
||||
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
#if defined(__linux__)
|
||||
#include <sys/inotify.h>
|
||||
#endif
|
||||
#include <poll.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -15,6 +17,7 @@
|
||||
#include "ALabel.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
#include "util/udev_deleter.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
@@ -37,16 +40,23 @@ 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_;
|
||||
bool smoothPowerEnable_{false};
|
||||
double time_constant_s_{260.0};
|
||||
double smooth_power_{0.0}; // µW
|
||||
std::chrono::steady_clock::time_point last_t_{std::chrono::steady_clock::now()};
|
||||
std::string old_status_raw_{""};
|
||||
|
||||
util::SleeperThread thread_;
|
||||
util::SleeperThread thread_battery_update_;
|
||||
|
||||
@@ -41,6 +41,7 @@ class Bluetooth : public ALabel {
|
||||
bool services_resolved;
|
||||
// NOTE: experimental feature in bluez
|
||||
std::optional<unsigned char> battery_percentage;
|
||||
std::optional<unsigned char> battery_percentage_peripheral;
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -59,6 +60,12 @@ class Bluetooth : public ALabel {
|
||||
gpointer) -> void;
|
||||
|
||||
auto getDeviceBatteryPercentage(GDBusObject*) -> std::optional<unsigned char>;
|
||||
auto getDeviceGattBatteryLevels(GDBusObject*, std::optional<unsigned char>&,
|
||||
std::optional<unsigned char>&) -> void;
|
||||
static auto processBatteryServiceCharacteristics(GList*, const std::string&, const std::string&,
|
||||
const std::string&,
|
||||
std::optional<unsigned char>&,
|
||||
std::optional<unsigned char>&) -> void;
|
||||
auto getDeviceProperties(GDBusObject*, DeviceInfo&) -> bool;
|
||||
auto getControllerProperties(GDBusObject*, ControllerInfo&) -> bool;
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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}};
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -80,6 +80,7 @@ class Clock final : public ALabel {
|
||||
void cldShift_reset();
|
||||
void tz_up();
|
||||
void tz_down();
|
||||
void action_exec(const std::string& action);
|
||||
// Module Action Map
|
||||
static inline std::map<const std::string, void (waybar::modules::Clock::* const)()> actionMap_{
|
||||
{"mode", &waybar::modules::Clock::cldModeSwitch},
|
||||
@@ -88,6 +89,9 @@ class Clock final : public ALabel {
|
||||
{"shift_reset", &waybar::modules::Clock::cldShift_reset},
|
||||
{"tz_up", &waybar::modules::Clock::tz_up},
|
||||
{"tz_down", &waybar::modules::Clock::tz_down}};
|
||||
static inline std::map<const std::string,
|
||||
void (waybar::modules::Clock::* const)(const std::string& action)>
|
||||
actionWithArgsMap_{{"exec", &waybar::modules::Clock::action_exec}};
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "AGraph.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class CpuGraph : public AGraph {
|
||||
public:
|
||||
CpuGraph(const std::string&, const Json::Value&);
|
||||
virtual ~CpuGraph() = default;
|
||||
auto update() -> void override;
|
||||
|
||||
private:
|
||||
static constexpr const char* MODERATE_CLASS = "cpu-moderate";
|
||||
static constexpr const char* HIGH_CLASS = "cpu-high";
|
||||
static constexpr const char* INTENSIVE_CLASS = "cpu-intensive";
|
||||
|
||||
std::vector<std::tuple<size_t, size_t>> prev_times_;
|
||||
util::SleeperThread thread_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
@@ -5,14 +5,14 @@
|
||||
#include <csignal>
|
||||
#include <string>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "AIconLabel.hpp"
|
||||
#include "util/command.hpp"
|
||||
#include "util/json.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Custom : public ALabel {
|
||||
class Custom : public AIconLabel {
|
||||
public:
|
||||
Custom(const std::string&, const std::string&, const Json::Value&, const std::string&);
|
||||
virtual ~Custom();
|
||||
@@ -35,6 +35,10 @@ class Custom : public ALabel {
|
||||
std::string id_;
|
||||
std::string alt_;
|
||||
std::string tooltip_;
|
||||
std::string last_tooltip_markup_;
|
||||
std::string image_path_;
|
||||
std::string image_name_;
|
||||
unsigned app_icon_size_{24};
|
||||
const bool tooltip_format_enabled_;
|
||||
std::vector<std::string> class_;
|
||||
int percentage_;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <csignal>
|
||||
#include <string>
|
||||
|
||||
#include "AGraph.hpp"
|
||||
#include "util/command.hpp"
|
||||
#include "util/json.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class CustomGraph : public AGraph {
|
||||
public:
|
||||
CustomGraph(const std::string&, const std::string&, const Json::Value&, const std::string&);
|
||||
virtual ~CustomGraph();
|
||||
auto update() -> void override;
|
||||
void refresh(int /*signal*/) override;
|
||||
|
||||
private:
|
||||
void delayWorker();
|
||||
void continuousWorker();
|
||||
void waitingWorker();
|
||||
void parseOutputRaw();
|
||||
void parseOutputJson();
|
||||
void handleEvent();
|
||||
bool handleScroll(GdkEventScroll* e) override;
|
||||
bool handleToggle(GdkEventButton* const& e) override;
|
||||
|
||||
const std::string name_;
|
||||
const std::string output_name_;
|
||||
std::string text_;
|
||||
std::string id_;
|
||||
std::string alt_;
|
||||
std::string tooltip_;
|
||||
const bool tooltip_format_enabled_;
|
||||
std::vector<std::string> class_;
|
||||
int percentage_;
|
||||
FILE* fp_;
|
||||
int pid_;
|
||||
util::command::res output_;
|
||||
util::JsonParser parser_;
|
||||
|
||||
util::SleeperThread thread_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "util/format.hpp"
|
||||
@@ -19,10 +20,12 @@ class Disk : public ALabel {
|
||||
|
||||
private:
|
||||
util::SleeperThread thread_;
|
||||
std::string path_;
|
||||
std::string header_;
|
||||
std::vector<std::string> paths_;
|
||||
std::string separator_;
|
||||
std::string unit_;
|
||||
|
||||
float calc_specific_divisor(const std::string divisor);
|
||||
float calc_specific_divisor(const std::string& divisor);
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
||||
@@ -12,23 +12,26 @@ 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_;
|
||||
void handle_active_output(zdwl_ipc_output_v2* zdwl_output_v2, uint32_t active);
|
||||
|
||||
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_;
|
||||
bool hide_vacant_;
|
||||
struct zdwl_ipc_output_v2* output_status_;
|
||||
};
|
||||
|
||||
} /* namespace waybar::modules::dwl */
|
||||
|
||||
@@ -13,26 +13,30 @@ 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_active(const uint32_t active);
|
||||
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_;
|
||||
bool active_;
|
||||
bool hide_inactive_;
|
||||
bool hide_empty_;
|
||||
uint32_t layout_;
|
||||
|
||||
struct zdwl_ipc_output_v2 *output_status_;
|
||||
struct zdwl_ipc_output_v2* output_status_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::dwl
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -26,20 +26,20 @@ class Gamemode : public AModule {
|
||||
const std::string DEFAULT_FORMAT = "{glyph}";
|
||||
const std::string DEFAULT_FORMAT_ALT = "{glyph} {count}";
|
||||
const std::string DEFAULT_TOOLTIP_FORMAT = "Games running: {count}";
|
||||
const std::string DEFAULT_GLYPH = "";
|
||||
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 ¶meters);
|
||||
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;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <filesystem>
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
@@ -34,19 +36,33 @@ class IPC {
|
||||
Json::Value getSocket1JsonReply(const std::string& rq);
|
||||
static std::filesystem::path getSocketFolder(const char* instanceSig);
|
||||
|
||||
/// Dispatch a Hyprland command. Automatically uses the correct protocol
|
||||
/// (legacy text or Lua-based) depending on the running Hyprland version.
|
||||
static std::string dispatch(const std::string& dispatcher, const std::string& arg);
|
||||
|
||||
/// Build a Lua-format dispatch command string.
|
||||
static std::string buildLuaDispatch(const std::string& dispatcher, const std::string& arg);
|
||||
|
||||
protected:
|
||||
static std::filesystem::path socketFolder_;
|
||||
|
||||
/// Detect whether the running Hyprland uses the Lua-based IPC protocol.
|
||||
/// Returns true for Hyprland >= 0.54 (Lua config), false for older versions.
|
||||
static bool isLuaProtocol();
|
||||
|
||||
static std::optional<bool> s_luaProtocolDetected_; // cached detection result
|
||||
|
||||
private:
|
||||
void socketListener();
|
||||
void parseIPC(const std::string&);
|
||||
|
||||
std::thread ipcThread_;
|
||||
std::mutex callbackMutex_;
|
||||
std::mutex socketMutex_;
|
||||
util::JsonParser parser_;
|
||||
std::list<std::pair<std::string, EventHandler*>> callbacks_;
|
||||
int socketfd_; // the hyprland socket file descriptor
|
||||
pid_t socketOwnerPid_;
|
||||
bool running_ = true; // the ipcThread will stop running when this is false
|
||||
int socketfd_ = -1; // the hyprland socket file descriptor
|
||||
pid_t socketOwnerPid_ = -1;
|
||||
std::atomic<bool> running_ = true; // the ipcThread will stop running when this is false
|
||||
};
|
||||
}; // namespace waybar::modules::hyprland
|
||||
|
||||
@@ -30,6 +30,8 @@ class Language : public waybar::ALabel, public EventHandler {
|
||||
std::string short_description;
|
||||
};
|
||||
|
||||
auto removeXkbLayoutCssClass() -> void;
|
||||
auto addXkbLayoutCssClass() -> void;
|
||||
static auto getLayout(const std::string&) -> Layout;
|
||||
|
||||
std::mutex mutex_;
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ class Window : public waybar::AAppIconLabel, public EventHandler {
|
||||
|
||||
private:
|
||||
struct Workspace {
|
||||
int id;
|
||||
int windows;
|
||||
int id = 0;
|
||||
int windows = 0;
|
||||
std::string last_window;
|
||||
std::string last_window_title;
|
||||
|
||||
@@ -29,14 +29,14 @@ class Window : public waybar::AAppIconLabel, public EventHandler {
|
||||
};
|
||||
|
||||
struct WindowData {
|
||||
bool floating;
|
||||
bool floating = false;
|
||||
int monitor = -1;
|
||||
std::string class_name;
|
||||
std::string initial_class_name;
|
||||
std::string title;
|
||||
std::string initial_title;
|
||||
bool fullscreen;
|
||||
bool grouped;
|
||||
bool fullscreen = false;
|
||||
bool grouped = false;
|
||||
|
||||
static auto parse(const Json::Value&) -> WindowData;
|
||||
};
|
||||
@@ -47,7 +47,7 @@ class Window : public waybar::AAppIconLabel, public EventHandler {
|
||||
void queryActiveWorkspace();
|
||||
void setClass(const std::string&, bool enable);
|
||||
|
||||
bool separateOutputs_;
|
||||
bool separateOutputs_ = false;
|
||||
std::mutex mutex_;
|
||||
const Bar& bar_;
|
||||
util::JsonParser parser_;
|
||||
@@ -55,11 +55,11 @@ class Window : public waybar::AAppIconLabel, public EventHandler {
|
||||
Workspace workspace_;
|
||||
std::string soloClass_;
|
||||
std::string lastSoloClass_;
|
||||
bool solo_;
|
||||
bool allFloating_;
|
||||
bool swallowing_;
|
||||
bool fullscreen_;
|
||||
bool focused_;
|
||||
bool solo_ = false;
|
||||
bool allFloating_ = false;
|
||||
bool swallowing_ = false;
|
||||
bool fullscreen_ = false;
|
||||
bool focused_ = false;
|
||||
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
@@ -40,10 +40,11 @@ struct WindowRepr {
|
||||
|
||||
class WindowCreationPayload {
|
||||
public:
|
||||
WindowCreationPayload(std::string workspace_name, WindowAddress window_address,
|
||||
WindowCreationPayload(const std::string& workspace_name, WindowAddress window_address,
|
||||
WindowRepr window_repr);
|
||||
WindowCreationPayload(std::string workspace_name, WindowAddress window_address,
|
||||
std::string window_class, std::string window_title, bool is_active);
|
||||
WindowCreationPayload(const std::string& workspace_name, WindowAddress window_address,
|
||||
const std::string& window_class, const std::string& window_title,
|
||||
bool is_active);
|
||||
WindowCreationPayload(Json::Value const& client_data);
|
||||
|
||||
int incrementTimeSpentUncreated();
|
||||
|
||||
@@ -30,6 +30,7 @@ class Workspace {
|
||||
public:
|
||||
explicit Workspace(const Json::Value& workspace_data, Workspaces& workspace_manager,
|
||||
const Json::Value& clients_data = Json::Value::nullRef);
|
||||
~Workspace();
|
||||
std::string& selectIcon(std::map<std::string, std::string>& icons_map);
|
||||
Gtk::Button& button() { return m_button; };
|
||||
|
||||
@@ -45,6 +46,15 @@ class Workspace {
|
||||
bool isUrgent() const { return m_isUrgent; };
|
||||
|
||||
bool handleClicked(GdkEventButton* bt) const;
|
||||
|
||||
bool handleEnter(GdkEventCrossing* event);
|
||||
bool handleLeave(GdkEventCrossing* event);
|
||||
|
||||
void startHoverCheck();
|
||||
void stopHoverCheck();
|
||||
bool syncHoverClass();
|
||||
bool pointerInsideButton();
|
||||
|
||||
void setActive(bool value = true) { m_isActive = value; };
|
||||
void setPersistentRule(bool value = true) { m_isPersistentRule = value; };
|
||||
void setPersistentConfig(bool value = true) { m_isPersistentConfig = value; };
|
||||
@@ -71,6 +81,7 @@ class Workspace {
|
||||
|
||||
int m_id;
|
||||
std::string m_name;
|
||||
std::string m_prevNameClass;
|
||||
std::string m_output;
|
||||
uint m_windows;
|
||||
bool m_isActive = false;
|
||||
@@ -80,6 +91,8 @@ class Workspace {
|
||||
bool m_isUrgent = false;
|
||||
bool m_isVisible = false;
|
||||
|
||||
sigc::connection m_hoverCheckConnection;
|
||||
|
||||
std::vector<WindowRepr> m_windowMap;
|
||||
|
||||
Gtk::Button m_button;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <gtkmm/enums.h>
|
||||
#include <gtkmm/label.h>
|
||||
#include <json/value.h>
|
||||
#include <sigc++/connection.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
@@ -38,11 +39,13 @@ class Workspaces : public AModule, public EventHandler {
|
||||
auto allOutputs() const -> bool { return m_allOutputs; }
|
||||
auto showSpecial() const -> bool { return m_showSpecial; }
|
||||
auto activeOnly() const -> bool { return m_activeOnly; }
|
||||
auto hideActive() const -> bool { return m_hideActive; }
|
||||
auto specialVisibleOnly() const -> bool { return m_specialVisibleOnly; }
|
||||
auto persistentOnly() const -> bool { return m_persistentOnly; }
|
||||
auto moveToMonitor() const -> bool { return m_moveToMonitor; }
|
||||
auto enableTaskbar() const -> bool { return m_enableTaskbar; }
|
||||
auto taskbarWithIcon() const -> bool { return m_taskbarWithIcon; }
|
||||
auto barScroll() const -> bool { return m_barScroll; }
|
||||
|
||||
auto getBarOutput() const -> std::string { return m_bar.output->name; }
|
||||
auto formatBefore() const -> std::string { return m_formatBefore; }
|
||||
@@ -54,12 +57,15 @@ class Workspaces : public AModule, public EventHandler {
|
||||
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; }
|
||||
auto maxWindows() const -> int { return m_maxWindows; }
|
||||
|
||||
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 getRewrite(const std::string& window_class, const std::string& window_title);
|
||||
std::string& getWindowSeparator() { return m_formatWindowSeparator; }
|
||||
auto windowRewriteGroupThreshold() const -> int { return m_windowRewriteGroupThreshold; }
|
||||
auto const& getWindowRewriteGroupFormat() const { return m_windowRewriteGroupFormat; }
|
||||
bool isWorkspaceIgnored(std::string const& workspace_name);
|
||||
|
||||
bool windowRewriteConfigUsesTitle() const { return m_anyWindowRewriteRuleUsesTitle; }
|
||||
@@ -87,6 +93,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
auto populateIgnoreWorkspacesConfig(const Json::Value& config) -> void;
|
||||
auto populateFormatWindowSeparatorConfig(const Json::Value& config) -> void;
|
||||
auto populateWindowRewriteConfig(const Json::Value& config) -> void;
|
||||
auto populateMaxWindowsConfig(const Json::Value& config) -> void;
|
||||
auto populateWorkspaceTaskbarConfig(const Json::Value& config) -> void;
|
||||
|
||||
void registerIpc();
|
||||
@@ -122,6 +129,8 @@ class Workspaces : public AModule, public EventHandler {
|
||||
static std::pair<std::string, std::string> splitDoublePayload(std::string const& payload);
|
||||
static std::tuple<std::string, std::string, std::string> splitTriplePayload(
|
||||
std::string const& payload);
|
||||
// scroll events
|
||||
bool handleScroll(GdkEventScroll* e) override;
|
||||
|
||||
// Update methods
|
||||
void doUpdate();
|
||||
@@ -142,9 +151,11 @@ class Workspaces : public AModule, public EventHandler {
|
||||
bool m_allOutputs = false;
|
||||
bool m_showSpecial = false;
|
||||
bool m_activeOnly = false;
|
||||
bool m_hideActive = false;
|
||||
bool m_specialVisibleOnly = false;
|
||||
bool m_persistentOnly = false;
|
||||
bool m_moveToMonitor = false;
|
||||
bool m_barScroll = false;
|
||||
Json::Value m_persistentWorkspaceConfig;
|
||||
|
||||
// Map for windows stored in workspaces not present in the current bar.
|
||||
@@ -168,6 +179,8 @@ class Workspaces : public AModule, public EventHandler {
|
||||
util::RegexCollection m_windowRewriteRules;
|
||||
bool m_anyWindowRewriteRuleUsesTitle = false;
|
||||
std::string m_formatWindowSeparator;
|
||||
int m_windowRewriteGroupThreshold = 0;
|
||||
std::string m_windowRewriteGroupFormat = "{icon}×{count}";
|
||||
|
||||
bool m_withIcon;
|
||||
uint64_t m_monitorId;
|
||||
@@ -197,6 +210,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
};
|
||||
std::string m_onClickWindow;
|
||||
std::string m_currentActiveWindowAddress;
|
||||
int m_maxWindows = 0;
|
||||
|
||||
std::vector<std::regex> m_ignoreWorkspaces;
|
||||
std::vector<std::regex> m_ignoreWindows;
|
||||
@@ -204,6 +218,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
std::mutex m_mutex;
|
||||
const Bar& m_bar;
|
||||
Gtk::Box m_box;
|
||||
sigc::connection m_scrollEventConnection_;
|
||||
IPC& m_ipc;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,25 +6,35 @@
|
||||
#include "bar.hpp"
|
||||
#include "client.hpp"
|
||||
|
||||
struct ext_idle_notification_v1;
|
||||
|
||||
namespace waybar::modules {
|
||||
|
||||
class IdleInhibitor : public ALabel {
|
||||
sigc::connection timeout_;
|
||||
ext_idle_notification_v1* idle_notification_;
|
||||
uint32_t idle_timeout_ms_;
|
||||
|
||||
public:
|
||||
IdleInhibitor(const std::string&, const waybar::Bar&, const Json::Value&);
|
||||
virtual ~IdleInhibitor();
|
||||
auto update() -> void override;
|
||||
auto refresh(int) -> void override;
|
||||
static std::list<waybar::AModule*> modules;
|
||||
static bool status;
|
||||
|
||||
private:
|
||||
bool handleToggle(GdkEventButton* const& e) override;
|
||||
void toggleStatus();
|
||||
void setupIdleNotification();
|
||||
void teardownIdleNotification();
|
||||
static void handleIdled(void* data, ext_idle_notification_v1* notification);
|
||||
static void handleResumed(void* data, ext_idle_notification_v1* notification);
|
||||
|
||||
const Bar& bar_;
|
||||
struct zwp_idle_inhibitor_v1* idle_inhibitor_;
|
||||
int pid_;
|
||||
bool wait_for_activity_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <fmt/chrono.h>
|
||||
#include <gtkmm/label.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -35,12 +36,12 @@ class KeyboardState : public AModule {
|
||||
std::string capslock_format_;
|
||||
std::string scrolllock_format_;
|
||||
const std::chrono::seconds interval_;
|
||||
std::string icon_locked_;
|
||||
std::string icon_unlocked_;
|
||||
std::unordered_map<std::string, std::vector<std::string>> key_icon_states_;
|
||||
std::string devices_path_;
|
||||
|
||||
struct libinput* libinput_;
|
||||
std::unordered_map<std::string, struct libinput_device*> libinput_devices_;
|
||||
std::mutex devices_mutex_; // protects libinput_devices_
|
||||
std::set<int> binding_keys;
|
||||
|
||||
util::SleeperThread libinput_thread_, hotplug_thread_;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// include/modules/mango/backend.hpp
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "util/json.hpp"
|
||||
|
||||
namespace waybar::modules::mango {
|
||||
|
||||
class EventHandler {
|
||||
public:
|
||||
virtual void onEvent(const Json::Value& ev) = 0;
|
||||
virtual ~EventHandler() = default;
|
||||
};
|
||||
|
||||
class IPC {
|
||||
public:
|
||||
static IPC& getInstance();
|
||||
IPC(const IPC&) = delete;
|
||||
IPC& operator=(const IPC&) = delete;
|
||||
|
||||
void registerForIPC(const std::string& ev, EventHandler* handler);
|
||||
void unregisterForIPC(EventHandler* handler);
|
||||
|
||||
static Json::Value send(const Json::Value& request);
|
||||
static void sendAsync(const Json::Value& request);
|
||||
|
||||
std::unique_lock<std::mutex> lockData() { return std::unique_lock<std::mutex>(data_mutex_); }
|
||||
|
||||
std::unordered_map<std::string, Json::Value> getMonitors() const;
|
||||
Json::Value getMonitor(const std::string& name);
|
||||
Json::Value getActiveClientForMonitor(const std::string& name) const;
|
||||
std::string getKeyboardLayout() const;
|
||||
std::string getKeymode() const;
|
||||
std::string getLayoutSymbolForMonitor(const std::string& name) const;
|
||||
|
||||
private:
|
||||
IPC();
|
||||
~IPC();
|
||||
void startIPC();
|
||||
static int connectToSocket();
|
||||
void parseIPC(const std::string& line);
|
||||
|
||||
void handleMonitorUpdate(const Json::Value& mon);
|
||||
void updateFocusingClient(const Json::Value& client);
|
||||
void updateKeyboardLayout(const std::string& layout);
|
||||
|
||||
static Json::Value sendCommand(const std::string& cmd);
|
||||
|
||||
int sockfd_ = -1;
|
||||
std::thread ipc_thread_;
|
||||
mutable std::mutex data_mutex_;
|
||||
std::unordered_map<std::string, Json::Value> monitors_;
|
||||
std::unordered_map<uint64_t, Json::Value> clients_;
|
||||
uint64_t focusing_client_id_ = 0;
|
||||
std::string keyboard_layout_;
|
||||
std::string keymode_;
|
||||
Json::Value active_client_;
|
||||
std::mutex callback_mutex_;
|
||||
std::list<std::pair<std::string, EventHandler*>> callbacks_;
|
||||
};
|
||||
} // namespace waybar::modules::mango
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/mango/backend.hpp"
|
||||
|
||||
namespace waybar::modules::mango {
|
||||
|
||||
class Keymode : public ALabel, public EventHandler {
|
||||
public:
|
||||
Keymode(const std::string&, const Bar&, const Json::Value&);
|
||||
~Keymode() override;
|
||||
void update() override;
|
||||
|
||||
private:
|
||||
void onEvent(const Json::Value& ev) override;
|
||||
void doUpdate();
|
||||
|
||||
std::mutex mutex_;
|
||||
const Bar& bar_;
|
||||
std::string last_keymode_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::mango
|
||||
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <xkbcommon/xkbregistry.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/mango/backend.hpp"
|
||||
|
||||
namespace waybar::modules::mango {
|
||||
|
||||
class Language : public ALabel, public EventHandler {
|
||||
public:
|
||||
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 doUpdate();
|
||||
|
||||
struct Layout {
|
||||
std::string full_name;
|
||||
std::string short_name;
|
||||
std::string variant;
|
||||
std::string short_description;
|
||||
};
|
||||
|
||||
Layout getLayout(const std::string& fullName);
|
||||
|
||||
std::mutex mutex_;
|
||||
const Bar& bar_;
|
||||
|
||||
std::vector<Layout> layouts_;
|
||||
unsigned current_idx_;
|
||||
std::string last_short_name_;
|
||||
|
||||
struct rxkb_context* rxkb_ctx_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::mango
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/mango/backend.hpp"
|
||||
|
||||
namespace waybar::modules::mango {
|
||||
|
||||
class Layout : public ALabel, public EventHandler {
|
||||
public:
|
||||
Layout(const std::string&, const Bar&, const Json::Value&);
|
||||
~Layout() override;
|
||||
void update() override;
|
||||
|
||||
private:
|
||||
void onEvent(const Json::Value& ev) override;
|
||||
void doUpdate();
|
||||
|
||||
std::mutex mutex_;
|
||||
const Bar& bar_;
|
||||
std::string last_symbol_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::mango
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <json/value.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "AAppIconLabel.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/mango/backend.hpp"
|
||||
|
||||
namespace waybar::modules::mango {
|
||||
|
||||
class Window : public AAppIconLabel, public EventHandler {
|
||||
public:
|
||||
Window(const std::string&, const Bar&, const Json::Value&);
|
||||
~Window() override;
|
||||
void update() override;
|
||||
|
||||
private:
|
||||
void onEvent(const Json::Value& ev) override;
|
||||
void doUpdate();
|
||||
void setClass(const std::string& className, bool enable);
|
||||
|
||||
const Bar& bar_;
|
||||
std::string oldAppId_;
|
||||
std::mutex mutex_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::mango
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <json/value.h>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "AModule.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/mango/backend.hpp"
|
||||
|
||||
namespace waybar::modules::mango {
|
||||
|
||||
class Workspaces : public AModule, public EventHandler {
|
||||
public:
|
||||
Workspaces(const std::string&, const Bar&, const Json::Value&);
|
||||
~Workspaces() override;
|
||||
void update() override;
|
||||
|
||||
private:
|
||||
void onEvent(const Json::Value& ev) override;
|
||||
void doUpdate();
|
||||
|
||||
Gtk::Button& addButton(uint64_t idx);
|
||||
void updateButtonState(Gtk::Button& button, const Json::Value& tag, const Json::Value& monitor);
|
||||
std::string getIcon(const std::string& value, const Json::Value& tag);
|
||||
bool handleButtonClick(GdkEventButton* event, uint64_t idx, bool isOverview);
|
||||
|
||||
const Bar& bar_;
|
||||
Gtk::Box box_;
|
||||
|
||||
std::unordered_map<uint64_t, Gtk::Button> buttons_;
|
||||
Gtk::Button* overview_button_ = nullptr;
|
||||
|
||||
std::string on_click_left_;
|
||||
std::string on_click_middle_;
|
||||
std::string on_click_right_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::mango
|
||||
@@ -22,6 +22,8 @@ class Memory : public ALabel {
|
||||
std::unordered_map<std::string, unsigned long> meminfo_;
|
||||
|
||||
util::SleeperThread thread_;
|
||||
|
||||
std::string unit_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
||||
@@ -28,11 +28,14 @@ class MPD : public ALabel {
|
||||
|
||||
unsigned timeout_;
|
||||
|
||||
unsigned playing_interval_;
|
||||
|
||||
detail::unique_connection connection_;
|
||||
|
||||
detail::unique_status status_;
|
||||
mpd_state state_;
|
||||
detail::unique_song song_;
|
||||
std::string ellipsis_;
|
||||
|
||||
public:
|
||||
MPD(const std::string&, const Json::Value&);
|
||||
@@ -44,7 +47,11 @@ class MPD : public ALabel {
|
||||
std::string getFilename() const;
|
||||
void setLabel();
|
||||
std::string getStateIcon() const;
|
||||
std::string getOptionIcon(std::string optionName, bool activated) const;
|
||||
std::string getOptionIcon(const std::string& optionName, bool activated) const;
|
||||
std::string getArtistStr(bool truncated) const;
|
||||
std::string getAlbumArtistStr(bool truncated) const;
|
||||
std::string getAlbumStr(bool truncated) const;
|
||||
std::string getTitleStr(bool truncated) const;
|
||||
|
||||
// GUI-side methods
|
||||
bool handlePlayPause(GdkEventButton* const&);
|
||||
@@ -54,11 +61,11 @@ class MPD : public ALabel {
|
||||
void tryConnect();
|
||||
void checkErrors(mpd_connection* conn);
|
||||
void fetchState();
|
||||
void queryMPD();
|
||||
|
||||
inline bool stopped() const { return connection_ && state_ == MPD_STATE_STOP; }
|
||||
inline bool playing() const { return connection_ && state_ == MPD_STATE_PLAY; }
|
||||
inline bool paused() const { return connection_ && state_ == MPD_STATE_PAUSE; }
|
||||
inline unsigned playing_interval() const { return playing_interval_; }
|
||||
};
|
||||
|
||||
#if !defined(MPD_NOINLINE)
|
||||
|
||||
@@ -82,6 +82,7 @@ class Idle : public State {
|
||||
class Playing : public State {
|
||||
Context* const ctx_;
|
||||
sigc::connection timer_connection_;
|
||||
sigc::connection idle_connection_;
|
||||
|
||||
public:
|
||||
Playing(Context* const ctx) : ctx_{ctx} {}
|
||||
@@ -98,7 +99,10 @@ class Playing : public State {
|
||||
Playing(Playing const&) = delete;
|
||||
Playing& operator=(Playing const&) = delete;
|
||||
|
||||
void timer() noexcept;
|
||||
void idle() noexcept;
|
||||
bool on_timer();
|
||||
bool on_io(Glib::IOCondition const&);
|
||||
};
|
||||
|
||||
class Paused : public State {
|
||||
@@ -194,10 +198,10 @@ class Context {
|
||||
bool is_paused() const;
|
||||
bool is_stopped() const;
|
||||
constexpr std::size_t interval() const;
|
||||
unsigned playing_interval() const;
|
||||
void tryConnect() const;
|
||||
void checkErrors(mpd_connection*) const;
|
||||
void do_update();
|
||||
void queryMPD() const;
|
||||
void fetchState() const;
|
||||
constexpr mpd_state state() const;
|
||||
void emit() const;
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
namespace detail {
|
||||
using namespace std::literals::chrono_literals;
|
||||
|
||||
inline bool Context::is_connected() const { return mpd_module_->connection_ != nullptr; }
|
||||
inline bool Context::is_playing() const { return mpd_module_->playing(); }
|
||||
inline bool Context::is_paused() const { return mpd_module_->paused(); }
|
||||
inline bool Context::is_stopped() const { return mpd_module_->stopped(); }
|
||||
|
||||
constexpr inline std::size_t Context::interval() const { return mpd_module_->interval_.count(); }
|
||||
constexpr inline std::size_t Context::interval() const { return mpd_module_->interval_ / 1s; }
|
||||
inline unsigned Context::playing_interval() const { return mpd_module_->playing_interval(); }
|
||||
inline void Context::tryConnect() const { mpd_module_->tryConnect(); }
|
||||
inline unique_connection& Context::connection() { return mpd_module_->connection_; }
|
||||
constexpr inline mpd_state Context::state() const { return mpd_module_->state_; }
|
||||
@@ -15,7 +17,6 @@ constexpr inline mpd_state Context::state() const { return mpd_module_->state_;
|
||||
inline void Context::do_update() { mpd_module_->setLabel(); }
|
||||
|
||||
inline void Context::checkErrors(mpd_connection* conn) const { mpd_module_->checkErrors(conn); }
|
||||
inline void Context::queryMPD() const { mpd_module_->queryMPD(); }
|
||||
inline void Context::fetchState() const { mpd_module_->fetchState(); }
|
||||
inline void Context::emit() const { mpd_module_->emit(); }
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ class Mpris : public ALabel {
|
||||
|
||||
std::optional<std::string> artist;
|
||||
std::optional<std::string> album;
|
||||
std::optional<std::string> album_artist;
|
||||
std::optional<std::string> title;
|
||||
std::optional<std::string> length; // as HH:MM:SS
|
||||
std::optional<std::string> position; // same format
|
||||
@@ -76,8 +77,11 @@ class Mpris : public ALabel {
|
||||
std::string player_;
|
||||
std::vector<std::string> ignored_players_;
|
||||
|
||||
bool prefer_album_artist_;
|
||||
|
||||
PlayerctlPlayerManager* manager;
|
||||
PlayerctlPlayer* player;
|
||||
PlayerctlPlayer* last_active_player_ = nullptr;
|
||||
std::string lastStatus;
|
||||
std::string lastPlayer;
|
||||
|
||||
|
||||
@@ -70,6 +70,9 @@ class Network : public ALabel {
|
||||
|
||||
unsigned long long bandwidth_down_total_{0};
|
||||
unsigned long long bandwidth_up_total_{0};
|
||||
unsigned long long bandwidth_down_prev_{0};
|
||||
unsigned long long bandwidth_up_prev_{0};
|
||||
std::chrono::steady_clock::time_point bandwidth_last_sample_time_;
|
||||
|
||||
std::string state_;
|
||||
std::string essid_;
|
||||
|
||||
@@ -17,7 +17,7 @@ class EventHandler {
|
||||
|
||||
class IPC {
|
||||
public:
|
||||
IPC() { startIPC(); }
|
||||
IPC();
|
||||
|
||||
void registerForIPC(const std::string& ev, EventHandler* ev_handler);
|
||||
void unregisterForIPC(EventHandler* handler);
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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_;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <json/value.h>
|
||||
|
||||
#include <regex>
|
||||
#include <vector>
|
||||
|
||||
@@ -13,23 +14,29 @@ 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);
|
||||
bool isWorkspaceIgnored(const std::string &name);
|
||||
void sortWorkspaces(std::vector<Json::Value>& workspaces) const;
|
||||
Gtk::Button& addButton(const Json::Value& ws);
|
||||
std::string getIcon(const std::string& value, const Json::Value& ws);
|
||||
bool isWorkspaceIgnored(const std::string& name);
|
||||
bool handleScroll(GdkEventScroll* /*unused*/) override;
|
||||
|
||||
const Bar &bar_;
|
||||
const Bar& bar_;
|
||||
Gtk::Box box_;
|
||||
// Map from niri workspace id to button.
|
||||
std::unordered_map<uint64_t, Gtk::Button> buttons_;
|
||||
// Vec of regex rules to ignore workspaces.
|
||||
std::vector<std::regex> ignoreWorkspaces_;
|
||||
|
||||
bool sort_by_id_ = false;
|
||||
bool sort_by_name_ = false;
|
||||
bool sort_by_coordinates_ = false;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::niri
|
||||
|
||||
@@ -9,22 +9,31 @@ namespace waybar::modules {
|
||||
|
||||
struct Profile {
|
||||
std::string name;
|
||||
// Legacy driver field, kept for backward compatibility with the
|
||||
// `{driver}` format placeholder and with older power-profiles-daemon
|
||||
// versions that only expose a single `Driver` DBus property.
|
||||
std::string driver;
|
||||
std::string cpuDriver;
|
||||
std::string platformDriver;
|
||||
|
||||
Profile(std::string n, std::string d) : name(std::move(n)), driver(std::move(d)) {}
|
||||
Profile(std::string n, std::string d, std::string cd, std::string pd)
|
||||
: name(std::move(n)),
|
||||
driver(std::move(d)),
|
||||
cpuDriver(std::move(cd)),
|
||||
platformDriver(std::move(pd)) {}
|
||||
};
|
||||
|
||||
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 +41,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
|
||||
|
||||
@@ -13,21 +13,22 @@ 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;
|
||||
|
||||
// Config
|
||||
Gtk::Box box_;
|
||||
std::vector<PrivacyItem*> modules_;
|
||||
uint iconSpacing = 4;
|
||||
uint iconSize = 20;
|
||||
uint transition_duration = 250;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ class Pulseaudio : public ALabel {
|
||||
const std::vector<std::string> getPulseIcon() const;
|
||||
|
||||
std::shared_ptr<util::AudioBackend> backend = nullptr;
|
||||
util::PulseaudioTarget target = util::PulseaudioTarget::Sink;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
||||
@@ -6,11 +6,6 @@
|
||||
#include "util/audio_backend.hpp"
|
||||
namespace waybar::modules {
|
||||
|
||||
enum class PulseaudioSliderTarget {
|
||||
Sink,
|
||||
Source,
|
||||
};
|
||||
|
||||
class PulseaudioSlider : public ASlider {
|
||||
public:
|
||||
PulseaudioSlider(const std::string&, const Json::Value&);
|
||||
@@ -21,7 +16,15 @@ class PulseaudioSlider : public ASlider {
|
||||
|
||||
private:
|
||||
std::shared_ptr<util::AudioBackend> backend = nullptr;
|
||||
PulseaudioSliderTarget target = PulseaudioSliderTarget::Sink;
|
||||
util::PulseaudioTarget target = util::PulseaudioTarget::Sink;
|
||||
|
||||
bool zero_on_mute = true;
|
||||
bool unmute_on_volume_change = true;
|
||||
// zero_on_mute and unmute_on_volume_change default to true
|
||||
// in order to maintain previous behaviour when using a
|
||||
// config in which these values are undefined
|
||||
|
||||
bool previously_muted = false;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
} // namespace waybar::modules
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -10,19 +10,19 @@ 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::string mode_;
|
||||
struct zriver_seat_status_v1 *seat_status_;
|
||||
struct zriver_seat_status_v1* seat_status_;
|
||||
};
|
||||
|
||||
} /* namespace waybar::modules::river */
|
||||
|
||||
@@ -13,27 +13,31 @@ 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_output(struct wl_output* output);
|
||||
void handle_unfocused_output(struct wl_output* output);
|
||||
|
||||
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 wl_seat *seat_;
|
||||
struct zriver_status_manager_v1* status_manager_;
|
||||
struct zriver_control_v1* control_;
|
||||
struct wl_seat* seat_;
|
||||
|
||||
private:
|
||||
const waybar::Bar &bar_;
|
||||
const waybar::Bar& bar_;
|
||||
struct wl_output* output_; // stores the output this module belongs to
|
||||
Gtk::Box box_;
|
||||
std::vector<Gtk::Button> buttons_;
|
||||
struct zriver_output_status_v1 *output_status_;
|
||||
struct zriver_output_status_v1* output_status_;
|
||||
struct zriver_seat_status_v1* seat_status_;
|
||||
};
|
||||
|
||||
} /* namespace waybar::modules::river */
|
||||
|
||||
@@ -12,22 +12,22 @@ 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);
|
||||
void handle_focused_output(struct wl_output *output);
|
||||
void handle_unfocused_output(struct wl_output *output);
|
||||
void handle_focused_view(const char* title);
|
||||
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_;
|
||||
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_;
|
||||
const waybar::Bar& bar_;
|
||||
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 */
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -14,11 +14,14 @@ namespace waybar::modules::SNI {
|
||||
|
||||
class Host {
|
||||
public:
|
||||
Host(const std::size_t id, const Json::Value&, const Bar&,
|
||||
Host(const std::size_t id, const Json::Value&, const Bar&, const std::vector<std::string>&,
|
||||
const std::function<void(std::unique_ptr<Item>&)>&,
|
||||
const std::function<void(std::unique_ptr<Item>&)>&);
|
||||
const std::function<void(std::unique_ptr<Item>&)>&, const std::function<void()>&);
|
||||
~Host();
|
||||
|
||||
void checkIgnoreList(const std::vector<std::string>& ignore_list,
|
||||
const std::function<void(std::unique_ptr<Item>&)>& on_remove);
|
||||
|
||||
private:
|
||||
void busAcquired(const Glib::RefPtr<Gio::DBus::Connection>&, Glib::ustring);
|
||||
void nameAppeared(const Glib::RefPtr<Gio::DBus::Connection>&, Glib::ustring,
|
||||
@@ -28,9 +31,13 @@ class Host {
|
||||
static void registerHost(GObject*, GAsyncResult*, gpointer);
|
||||
static void itemRegistered(SnWatcher*, const gchar*, gpointer);
|
||||
static void itemUnregistered(SnWatcher*, const gchar*, gpointer);
|
||||
void itemReady(Item&);
|
||||
void itemInvalidated(Item&);
|
||||
void removeItem(std::vector<std::unique_ptr<Item>>::iterator);
|
||||
void clearItems();
|
||||
|
||||
std::tuple<std::string, std::string> getBusNameAndObjectPath(const std::string);
|
||||
void addRegisteredItem(std::string service);
|
||||
void addRegisteredItem(const std::string& service);
|
||||
|
||||
std::vector<std::unique_ptr<Item>> items_;
|
||||
const std::string bus_name_;
|
||||
@@ -39,10 +46,14 @@ class Host {
|
||||
std::size_t watcher_id_;
|
||||
GCancellable* cancellable_ = nullptr;
|
||||
SnWatcher* watcher_ = nullptr;
|
||||
sigc::connection retry_connection_;
|
||||
unsigned retry_count_ = 0;
|
||||
const Json::Value& config_;
|
||||
const Bar& bar_;
|
||||
const std::vector<std::string> ignore_list_;
|
||||
const std::function<void(std::unique_ptr<Item>&)> on_add_;
|
||||
const std::function<void(std::unique_ptr<Item>&)> on_remove_;
|
||||
const std::function<void()> on_update_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::SNI
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <libdbusmenu-gtk/dbusmenu-gtk.h>
|
||||
#include <sigc++/trackable.h>
|
||||
|
||||
#include <functional>
|
||||
#include <set>
|
||||
#include <string_view>
|
||||
|
||||
@@ -25,9 +26,13 @@ struct ToolTip {
|
||||
|
||||
class Item : public sigc::trackable {
|
||||
public:
|
||||
Item(const std::string&, const std::string&, const Json::Value&, const Bar&);
|
||||
Item(const std::string&, const std::string&, const Json::Value&, const Bar&,
|
||||
const std::function<void(Item&)>&, const std::function<void(Item&)>&,
|
||||
const std::function<void()>&);
|
||||
~Item();
|
||||
|
||||
bool isReady() const;
|
||||
|
||||
std::string bus_name;
|
||||
std::string object_path;
|
||||
|
||||
@@ -41,9 +46,12 @@ class Item : public sigc::trackable {
|
||||
std::string title;
|
||||
std::string icon_name;
|
||||
Glib::RefPtr<Gdk::Pixbuf> icon_pixmap;
|
||||
bool has_custom_icon_ = false;
|
||||
Glib::RefPtr<Gtk::IconTheme> icon_theme;
|
||||
std::string overlay_icon_name;
|
||||
Glib::RefPtr<Gdk::Pixbuf> overlay_icon_pixmap;
|
||||
std::string attention_icon_name;
|
||||
Glib::RefPtr<Gdk::Pixbuf> attention_icon_pixmap;
|
||||
std::string attention_movie_name;
|
||||
std::string icon_theme_path;
|
||||
std::string menu;
|
||||
@@ -62,6 +70,8 @@ class Item : public sigc::trackable {
|
||||
void proxyReady(Glib::RefPtr<Gio::AsyncResult>& result);
|
||||
void setProperty(const Glib::ustring& name, Glib::VariantBase& value);
|
||||
void setStatus(const Glib::ustring& value);
|
||||
void setReady();
|
||||
void invalidate();
|
||||
void setCustomIcon(const std::string& id);
|
||||
void getUpdatedProperties();
|
||||
void processUpdatedProperties(Glib::RefPtr<Gio::AsyncResult>& result);
|
||||
@@ -69,8 +79,13 @@ class Item : public sigc::trackable {
|
||||
const Glib::VariantContainerBase& arguments);
|
||||
|
||||
void updateImage();
|
||||
Glib::RefPtr<Gdk::Pixbuf> extractPixBuf(GVariant* variant);
|
||||
static Glib::RefPtr<Gdk::Pixbuf> extractPixBuf(GVariant* variant);
|
||||
Glib::RefPtr<Gdk::Pixbuf> getIconPixbuf();
|
||||
Glib::RefPtr<Gdk::Pixbuf> getAttentionIconPixbuf();
|
||||
Glib::RefPtr<Gdk::Pixbuf> getOverlayIconPixbuf();
|
||||
Glib::RefPtr<Gdk::Pixbuf> loadIconFromNameOrFile(const std::string& name, bool log_failure);
|
||||
static Glib::RefPtr<Gdk::Pixbuf> overlayPixbufs(const Glib::RefPtr<Gdk::Pixbuf>&,
|
||||
const Glib::RefPtr<Gdk::Pixbuf>&);
|
||||
Glib::RefPtr<Gdk::Pixbuf> getIconByName(const std::string& name, int size);
|
||||
double getScaledIconSize();
|
||||
static void onMenuDestroyed(Item* self, GObject* old_menu_pointer);
|
||||
@@ -86,8 +101,13 @@ class Item : public sigc::trackable {
|
||||
gdouble distance_scrolled_y_ = 0;
|
||||
// visibility of items with Status == Passive
|
||||
bool show_passive_ = false;
|
||||
bool ready_ = false;
|
||||
Glib::ustring status_ = "active";
|
||||
|
||||
const Bar& bar_;
|
||||
const std::function<void(Item&)> on_ready_;
|
||||
const std::function<void(Item&)> on_invalidate_;
|
||||
const std::function<void()> on_updated_;
|
||||
|
||||
Glib::RefPtr<Gio::DBus::Proxy> proxy_;
|
||||
Glib::RefPtr<Gio::Cancellable> cancellable_;
|
||||
|
||||
@@ -19,11 +19,14 @@ class Tray : public AModule {
|
||||
private:
|
||||
void onAdd(std::unique_ptr<Item>& item);
|
||||
void onRemove(std::unique_ptr<Item>& item);
|
||||
void checkIgnoreList(std::unique_ptr<Item>* item);
|
||||
std::vector<std::string> parseIgnoreList(const Json::Value& config);
|
||||
void queueUpdate();
|
||||
|
||||
static inline std::size_t nb_hosts_ = 0;
|
||||
bool show_passive_ = false;
|
||||
Gtk::Box box_;
|
||||
SNI::Watcher::singleton watcher_;
|
||||
std::vector<std::string> ignore_list_;
|
||||
SNI::Host host_;
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -37,7 +37,7 @@ class BarIpcClient {
|
||||
void onModeUpdate(bool visible_by_modifier);
|
||||
void onUrgencyUpdate(bool visible_by_urgency);
|
||||
void update();
|
||||
bool isModuleEnabled(std::string name);
|
||||
bool isModuleEnabled(const std::string& name);
|
||||
|
||||
Bar& bar_;
|
||||
util::JsonParser parser_;
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <sigc++/sigc++.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "ipc.hpp"
|
||||
#include "util/SafeSignal.hpp"
|
||||
#include "util/scoped_fd.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules::sway {
|
||||
@@ -27,25 +25,26 @@ class Ipc {
|
||||
std::string payload;
|
||||
};
|
||||
|
||||
sigc::signal<void, const struct ipc_response &> signal_event;
|
||||
sigc::signal<void, const struct ipc_response &> signal_cmd;
|
||||
::waybar::SafeSignal<const struct ipc_response&> signal_event;
|
||||
::waybar::SafeSignal<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 = "");
|
||||
static std::string getSocketPath();
|
||||
static int open(const std::string&);
|
||||
|
||||
struct ipc_response send(int fd, uint32_t type, const std::string& payload = "");
|
||||
struct ipc_response recv(int fd);
|
||||
|
||||
int fd_;
|
||||
int fd_event_;
|
||||
util::ScopedFd fd_;
|
||||
util::ScopedFd fd_event_;
|
||||
std::mutex mutex_;
|
||||
util::SleeperThread thread_;
|
||||
};
|
||||
|
||||
@@ -47,7 +47,7 @@ class Language : public ALabel, public sigc::trackable {
|
||||
void onEvent(const struct Ipc::ipc_response&);
|
||||
void onCmd(const struct Ipc::ipc_response&);
|
||||
|
||||
auto set_current_layout(std::string current_layout) -> void;
|
||||
auto set_current_layout(const std::string& current_layout) -> void;
|
||||
auto init_layouts_map(const std::vector<std::string>& used_layouts) -> void;
|
||||
|
||||
const static std::string XKB_LAYOUT_NAMES_KEY;
|
||||
|
||||
@@ -24,12 +24,15 @@ class Workspaces : public AModule, public sigc::trackable {
|
||||
|
||||
private:
|
||||
static constexpr std::string_view workspace_switch_cmd_ = "workspace {} \"{}\"";
|
||||
static constexpr std::string_view workspace_switch_number_cmd_ = "workspace {} number {}";
|
||||
static constexpr std::string_view persistent_workspace_switch_cmd_ =
|
||||
R"(workspace {} "{}"; move workspace to output "{}"; workspace {} "{}")";
|
||||
|
||||
static int convertWorkspaceNameToNum(std::string name);
|
||||
static int convertWorkspaceNameToNum(const std::string& name);
|
||||
static int windowRewritePriorityFunction(std::string const& window_rule);
|
||||
|
||||
auto populateIgnoreWorkspacesConfig(const Json::Value& config) -> void;
|
||||
bool isWorkspaceIgnored(std::string const& name);
|
||||
void onCmd(const struct Ipc::ipc_response&);
|
||||
void onEvent(const struct Ipc::ipc_response&);
|
||||
bool filterButtons();
|
||||
@@ -40,7 +43,7 @@ class Workspaces : public AModule, public sigc::trackable {
|
||||
std::string getIcon(const std::string&, const Json::Value&);
|
||||
std::string getCycleWorkspace(std::vector<Json::Value>::iterator, bool prev) const;
|
||||
uint16_t getWorkspaceIndex(const std::string& name) const;
|
||||
static std::string trimWorkspaceName(std::string);
|
||||
static std::string trimWorkspaceName(const std::string&);
|
||||
bool handleScroll(GdkEventScroll* /*unused*/) override;
|
||||
|
||||
const Bar& bar_;
|
||||
@@ -49,6 +52,7 @@ class Workspaces : public AModule, public sigc::trackable {
|
||||
std::vector<std::string> workspaces_order_;
|
||||
Gtk::Box box_;
|
||||
std::string m_formatWindowSeparator;
|
||||
std::vector<std::regex> m_ignoreWorkspaces;
|
||||
util::RegexCollection m_windowRewriteRules;
|
||||
util::JsonParser parser_;
|
||||
std::unordered_map<std::string, Gtk::Button> buttons_;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <giomm/dbusproxy.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
|
||||
@@ -10,24 +11,43 @@ namespace waybar::modules {
|
||||
|
||||
class SystemdFailedUnits : public ALabel {
|
||||
public:
|
||||
SystemdFailedUnits(const std::string &, const Json::Value &);
|
||||
virtual ~SystemdFailedUnits();
|
||||
SystemdFailedUnits(const std::string&, const Json::Value&);
|
||||
virtual ~SystemdFailedUnits() = default;
|
||||
auto update() -> void override;
|
||||
|
||||
private:
|
||||
bool hide_on_ok;
|
||||
std::string format_ok;
|
||||
struct FailedUnit {
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string load_state;
|
||||
std::string active_state;
|
||||
std::string sub_state;
|
||||
std::string scope;
|
||||
};
|
||||
|
||||
bool update_pending;
|
||||
std::string system_state, user_state, overall_state;
|
||||
uint32_t nr_failed_system, nr_failed_user, nr_failed;
|
||||
std::string last_status;
|
||||
Glib::RefPtr<Gio::DBus::Proxy> system_proxy, user_proxy;
|
||||
bool hide_on_ok_;
|
||||
std::string format_ok_;
|
||||
std::string tooltip_format_;
|
||||
std::string tooltip_format_ok_;
|
||||
std::string tooltip_unit_format_;
|
||||
|
||||
void notify_cb(const Glib::ustring &sender_name, const Glib::ustring &signal_name,
|
||||
const Glib::VariantContainerBase &arguments);
|
||||
bool update_pending_;
|
||||
std::string system_state_, user_state_, overall_state_;
|
||||
uint32_t nr_failed_system_, nr_failed_user_, nr_failed_;
|
||||
std::string last_status_;
|
||||
Glib::RefPtr<Gio::DBus::Proxy> system_props_proxy_, user_props_proxy_;
|
||||
Glib::RefPtr<Gio::DBus::Proxy> system_manager_proxy_, user_manager_proxy_;
|
||||
std::vector<FailedUnit> failed_units_;
|
||||
|
||||
void notify_cb(const Glib::ustring& sender_name, const Glib::ustring& signal_name,
|
||||
const Glib::VariantContainerBase& arguments);
|
||||
void RequestFailedUnits();
|
||||
void RequestFailedUnitsList();
|
||||
void RequestSystemState();
|
||||
std::vector<FailedUnit> LoadFailedUnitsList(const char* kind,
|
||||
Glib::RefPtr<Gio::DBus::Proxy>& proxy,
|
||||
const std::string& scope);
|
||||
std::string BuildTooltipFailedList() const;
|
||||
void updateData();
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ class Temperature : public ALabel {
|
||||
Temperature(const std::string&, const Json::Value&);
|
||||
virtual ~Temperature() = default;
|
||||
auto update() -> void override;
|
||||
void suspend() override;
|
||||
void resume() override;
|
||||
|
||||
private:
|
||||
float getTemperature();
|
||||
|
||||
+22
-22
@@ -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 ¶meters);
|
||||
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
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include "util/scoped_fd.hpp"
|
||||
|
||||
namespace waybar::modules::wayfire {
|
||||
|
||||
using EventHandler = std::function<void(const std::string& event)>;
|
||||
@@ -71,25 +73,9 @@ struct State {
|
||||
auto update_view(const Json::Value& view) -> void;
|
||||
};
|
||||
|
||||
struct Sock {
|
||||
int fd;
|
||||
using Sock = util::ScopedFd;
|
||||
|
||||
Sock(int fd) : fd{fd} {}
|
||||
~Sock() { close(fd); }
|
||||
Sock(const Sock&) = delete;
|
||||
auto operator=(const Sock&) = delete;
|
||||
Sock(Sock&& rhs) noexcept {
|
||||
fd = rhs.fd;
|
||||
rhs.fd = -1;
|
||||
}
|
||||
auto& operator=(Sock&& rhs) noexcept {
|
||||
fd = rhs.fd;
|
||||
rhs.fd = -1;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
class IPC {
|
||||
class IPC : public std::enable_shared_from_this<IPC> {
|
||||
static std::weak_ptr<IPC> instance;
|
||||
Json::CharReaderBuilder reader_builder;
|
||||
Json::StreamWriterBuilder writer_builder;
|
||||
@@ -98,7 +84,7 @@ class IPC {
|
||||
State state;
|
||||
std::mutex state_mutex;
|
||||
|
||||
IPC() { start(); }
|
||||
IPC() = default;
|
||||
|
||||
static auto connect() -> Sock;
|
||||
auto receive(Sock& sock) -> Json::Value;
|
||||
|
||||
@@ -33,6 +33,7 @@ class Wireplumber : public ALabel {
|
||||
static void onDefaultNodesApiChanged(waybar::modules::Wireplumber* self);
|
||||
|
||||
bool handleScroll(GdkEventScroll* e) override;
|
||||
std::vector<std::string> getWPIcon();
|
||||
|
||||
static std::list<waybar::modules::Wireplumber*> modules;
|
||||
|
||||
@@ -54,6 +55,7 @@ class Wireplumber : public ALabel {
|
||||
bool source_muted_;
|
||||
double source_volume_;
|
||||
gchar* default_source_name_;
|
||||
std::string form_factor_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "AModule.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "client.hpp"
|
||||
#include "ext-workspace-v1-client-protocol.h"
|
||||
#include "giomm/desktopappinfo.h"
|
||||
#include "util/icon_loader.hpp"
|
||||
#include "util/json.hpp"
|
||||
@@ -33,8 +34,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 +54,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_;
|
||||
|
||||
@@ -80,6 +81,7 @@ class Task {
|
||||
std::string title_;
|
||||
std::string app_id_;
|
||||
uint32_t state_ = 0;
|
||||
struct ext_workspace_handle_v1* workspace_ = nullptr;
|
||||
|
||||
int32_t drag_start_x;
|
||||
int32_t drag_start_y;
|
||||
@@ -89,7 +91,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:
|
||||
@@ -102,29 +104,32 @@ class Task {
|
||||
bool minimized() const { return state_ & MINIMIZED; }
|
||||
bool active() const { return state_ & ACTIVE; }
|
||||
bool fullscreen() const { return state_ & FULLSCREEN; }
|
||||
bool visible() const { return button_visible_; }
|
||||
struct ext_workspace_handle_v1* workspace() const { return workspace_; }
|
||||
void set_workspace(struct ext_workspace_handle_v1* workspace) { workspace_ = workspace; }
|
||||
|
||||
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 +147,18 @@ using TaskPtr = std::unique_ptr<Task>;
|
||||
|
||||
class Taskbar : public waybar::AModule {
|
||||
public:
|
||||
Taskbar(const std::string &, const waybar::Bar &, const Json::Value &);
|
||||
struct WorkspaceState {
|
||||
Taskbar* taskbar;
|
||||
struct ext_workspace_handle_v1* handle;
|
||||
uint32_t state = 0;
|
||||
};
|
||||
|
||||
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 +166,46 @@ 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 ext_workspace_manager_v1* workspace_manager_;
|
||||
struct wl_seat* seat_;
|
||||
std::vector<struct ext_workspace_group_handle_v1*> workspace_groups_;
|
||||
std::vector<std::unique_ptr<WorkspaceState>> workspaces_;
|
||||
struct ext_workspace_handle_v1* current_workspace_ = nullptr;
|
||||
|
||||
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_workspace_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();
|
||||
void handle_workspace_group_create(struct ext_workspace_group_handle_v1*);
|
||||
void handle_workspace_group_removed(struct ext_workspace_group_handle_v1*);
|
||||
void handle_workspace_create(struct ext_workspace_handle_v1*);
|
||||
void handle_workspace_done();
|
||||
void handle_workspace_finished();
|
||||
void handle_workspace_removed(struct ext_workspace_handle_v1*);
|
||||
|
||||
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);
|
||||
void assign_current_workspace(Task&);
|
||||
void update_bar_css_classes();
|
||||
|
||||
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;
|
||||
|
||||
private:
|
||||
void set_bar_css_class(const std::string&, bool);
|
||||
};
|
||||
|
||||
} /* namespace waybar::modules::wlr */
|
||||
|
||||
Reference in New Issue
Block a user