2020-10-20 02:34:48 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "modules/sway/ipc/client.hpp"
|
|
|
|
#include "util/SafeSignal.hpp"
|
|
|
|
#include "util/json.hpp"
|
|
|
|
|
|
|
|
namespace waybar {
|
|
|
|
|
|
|
|
class Bar;
|
|
|
|
|
|
|
|
namespace modules::sway {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Supported subset of i3/sway IPC barconfig object
|
|
|
|
*/
|
|
|
|
struct swaybar_config {
|
|
|
|
std::string id;
|
|
|
|
std::string mode;
|
|
|
|
std::string hidden_state;
|
|
|
|
std::string position;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* swaybar IPC client
|
|
|
|
*/
|
|
|
|
class BarIpcClient {
|
|
|
|
public:
|
|
|
|
BarIpcClient(waybar::Bar& bar);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void onInitialConfig(const struct Ipc::ipc_response& res);
|
|
|
|
void onIpcEvent(const struct Ipc::ipc_response&);
|
|
|
|
void onConfigUpdate(const swaybar_config& config);
|
|
|
|
void onVisibilityUpdate(bool visible_by_modifier);
|
2020-10-20 02:35:55 +00:00
|
|
|
void update();
|
2020-10-20 02:34:48 +00:00
|
|
|
|
|
|
|
Bar& bar_;
|
|
|
|
util::JsonParser parser_;
|
|
|
|
Ipc ipc_;
|
|
|
|
|
|
|
|
swaybar_config bar_config_;
|
2020-10-20 02:35:55 +00:00
|
|
|
bool visible_by_modifier_ = false;
|
2020-10-20 02:34:48 +00:00
|
|
|
|
|
|
|
SafeSignal<bool> signal_visible_;
|
|
|
|
SafeSignal<swaybar_config> signal_config_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace modules::sway
|
|
|
|
} // namespace waybar
|