2018-08-08 23:54:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <fmt/format.h>
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
#include <gdk/gdkwayland.h>
|
2019-04-18 17:43:16 +02:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <wayland-client.h>
|
|
|
|
#include <wordexp.h>
|
2018-08-08 23:54:58 +02:00
|
|
|
#include "bar.hpp"
|
|
|
|
|
|
|
|
namespace waybar {
|
|
|
|
|
2018-08-16 14:29:41 +02:00
|
|
|
class Client {
|
2019-04-18 17:43:16 +02:00
|
|
|
public:
|
|
|
|
static Client *inst();
|
2019-04-18 17:52:00 +02:00
|
|
|
int main(int argc, char *argv[]);
|
|
|
|
|
|
|
|
Glib::RefPtr<Gtk::Application> gtk_app;
|
|
|
|
Glib::RefPtr<Gdk::Display> gdk_display;
|
|
|
|
struct wl_display * wl_display = nullptr;
|
|
|
|
struct wl_registry * registry = nullptr;
|
|
|
|
struct zwlr_layer_shell_v1 * layer_shell = nullptr;
|
|
|
|
struct zxdg_output_manager_v1 * xdg_output_manager = nullptr;
|
2020-10-31 18:30:25 +01:00
|
|
|
|
2019-04-18 17:43:16 +02:00
|
|
|
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = nullptr;
|
2020-11-01 14:33:28 +01:00
|
|
|
std::list<waybar::AModule*> idle_inhibitor_modules;
|
|
|
|
std::string idle_inhibitor_status = "deactivated";
|
2020-10-31 18:30:25 +01:00
|
|
|
|
2019-04-18 17:52:00 +02:00
|
|
|
std::vector<std::unique_ptr<Bar>> bars;
|
2019-04-18 17:43:16 +02:00
|
|
|
|
|
|
|
private:
|
2019-04-24 12:37:24 +02:00
|
|
|
Client() = default;
|
2019-05-24 09:49:09 +02:00
|
|
|
std::tuple<const std::string, const std::string> getConfigs(const std::string &config,
|
|
|
|
const std::string &style) const;
|
|
|
|
void bindInterfaces();
|
|
|
|
const std::string getValidPath(const std::vector<std::string> &paths) const;
|
2020-01-14 08:27:57 +01:00
|
|
|
void handleOutput(struct waybar_output &output);
|
|
|
|
bool isValidOutput(const Json::Value &config, struct waybar_output &output);
|
2019-05-24 09:49:09 +02:00
|
|
|
auto setupConfig(const std::string &config_file) -> void;
|
|
|
|
auto setupCss(const std::string &css_file) -> void;
|
2020-01-14 08:27:57 +01:00
|
|
|
struct waybar_output &getOutput(void *);
|
|
|
|
std::vector<Json::Value> getOutputConfigs(struct waybar_output &output);
|
2019-04-18 17:43:16 +02:00
|
|
|
|
|
|
|
static void handleGlobal(void *data, struct wl_registry *registry, uint32_t name,
|
|
|
|
const char *interface, uint32_t version);
|
|
|
|
static void handleGlobalRemove(void *data, struct wl_registry *registry, uint32_t name);
|
2019-08-28 05:57:23 +02:00
|
|
|
static void handleOutputName(void *, struct zxdg_output_v1 *, const char *);
|
|
|
|
void handleMonitorAdded(Glib::RefPtr<Gdk::Monitor> monitor);
|
|
|
|
void handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor> monitor);
|
2019-04-18 17:43:16 +02:00
|
|
|
|
2020-01-14 08:27:57 +01:00
|
|
|
Json::Value config_;
|
|
|
|
Glib::RefPtr<Gtk::StyleContext> style_context_;
|
|
|
|
Glib::RefPtr<Gtk::CssProvider> css_provider_;
|
|
|
|
std::list<struct waybar_output> outputs_;
|
2018-08-16 14:29:41 +02:00
|
|
|
};
|
|
|
|
|
2019-04-18 17:43:16 +02:00
|
|
|
} // namespace waybar
|