2020-10-20 04:34:48 +02:00
|
|
|
#pragma once
|
2022-04-09 13:18:03 +02:00
|
|
|
#include <atomic>
|
2020-10-20 04:34:48 +02:00
|
|
|
#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;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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&);
|
2022-04-06 15:53:49 +02:00
|
|
|
void onCmd(const struct Ipc::ipc_response&);
|
2020-10-20 04:34:48 +02:00
|
|
|
void onConfigUpdate(const swaybar_config& config);
|
|
|
|
void onVisibilityUpdate(bool visible_by_modifier);
|
2022-04-09 13:49:22 +02:00
|
|
|
void onModeUpdate(bool visible_by_modifier);
|
2022-04-06 15:53:49 +02:00
|
|
|
void onUrgencyUpdate(bool visible_by_urgency);
|
2020-10-20 04:35:55 +02:00
|
|
|
void update();
|
2022-04-12 20:34:04 +02:00
|
|
|
bool isModuleEnabled(std::string name);
|
2020-10-20 04:34:48 +02:00
|
|
|
|
2022-04-06 08:37:19 +02:00
|
|
|
Bar& bar_;
|
2020-10-20 04:34:48 +02:00
|
|
|
util::JsonParser parser_;
|
2022-04-06 08:37:19 +02:00
|
|
|
Ipc ipc_;
|
2020-10-20 04:34:48 +02:00
|
|
|
|
|
|
|
swaybar_config bar_config_;
|
2022-04-14 14:39:42 +02:00
|
|
|
std::string modifier_reset_;
|
2022-04-09 13:49:22 +02:00
|
|
|
bool visible_by_mode_ = false;
|
2022-04-06 08:37:19 +02:00
|
|
|
bool visible_by_modifier_ = false;
|
2022-04-06 15:53:49 +02:00
|
|
|
bool visible_by_urgency_ = false;
|
2022-04-09 13:18:03 +02:00
|
|
|
std::atomic<bool> modifier_no_action_ = false;
|
2020-10-20 04:34:48 +02:00
|
|
|
|
2022-04-09 13:49:22 +02:00
|
|
|
SafeSignal<bool> signal_mode_;
|
2022-04-06 08:37:19 +02:00
|
|
|
SafeSignal<bool> signal_visible_;
|
2022-04-06 15:53:49 +02:00
|
|
|
SafeSignal<bool> signal_urgency_;
|
2020-10-20 04:34:48 +02:00
|
|
|
SafeSignal<swaybar_config> signal_config_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace modules::sway
|
|
|
|
} // namespace waybar
|