Files
bar/include/services/hyprland.hpp

71 lines
1.7 KiB
C++

#pragma once
#include <glibmm.h>
#include <map>
#include <memory>
#include <sigc++/sigc++.h>
#include <string>
#include <sys/stat.h>
#include <vector>
#include "components/workspaceIndicator.hpp"
#include "gtkmm/box.h"
#define NUM_WORKSPACES 7
class HyprlandService {
inline static HyprlandService *instance = nullptr;
public:
struct WorkspaceState {
int id;
int monitorId;
bool alive = false; // window count above 0 (exists in hyprctl workspaces array)
bool presenting = false; // $(hyprctl monitors).activeWorkspace == id
bool focused = false; // $(hyprctl monitors).activeWorkspace == id && (hyprctl monitors).focused
bool urgent = false; // check ctl clients, and find ws with urgent window
std::string label;
};
struct Workspace {
WorkspaceState state;
std::shared_ptr<WorkspaceIndicator> view;
};
struct Monitor {
int id;
int activeWorkspaceId;
bool focused = false;
std::string name;
std::map<int, std::shared_ptr<Workspace>> monitorWorkspaces;
};
static HyprlandService *getInstance() {
if (!instance) {
instance = new HyprlandService();
}
return instance;
}
std::shared_ptr<Gtk::Box> getWorkspaceIndicatorsForMonitor(int monitorId);
private:
HyprlandService();
std::map<int, std::shared_ptr<Monitor>> monitors;
std::map<int, std::shared_ptr<Workspace>> workspaces;
/// maybe refactor into reusable class
std::string socketBuffer;
int socketFd;
///
std::string getSocketPath();
void bindSocket();
void init();
void updateIndicator(Workspace &workspace, const WorkspaceState newState);
};