69 lines
1.9 KiB
C++
69 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <glibmm.h>
|
|
#include <iostream>
|
|
#include <map>
|
|
#include <sigc++/sigc++.h>
|
|
#include <string>
|
|
|
|
class HyprlandService {
|
|
|
|
public:
|
|
typedef struct WorkspaceState {
|
|
int id;
|
|
bool active;
|
|
bool focused;
|
|
bool urgent;
|
|
} WorkspaceState;
|
|
|
|
typedef struct Monitor {
|
|
std::map<int, WorkspaceState> workspaceStates;
|
|
std::string name;
|
|
int x;
|
|
int y;
|
|
int id;
|
|
int focusedWorkspaceId;
|
|
} Monitor;
|
|
|
|
HyprlandService();
|
|
~HyprlandService();
|
|
|
|
// For debugging purposes
|
|
void printMonitor(const Monitor mon) {
|
|
std::cout << "=== Monitor Info ===\n";
|
|
std::cout << "Name: " << mon.name << " (ID: " << mon.id << ")\n";
|
|
std::cout << "Position: (" << mon.x << ", " << mon.y << ")\n";
|
|
std::cout << "Focused Workspace ID: " << mon.focusedWorkspaceId << "\n";
|
|
|
|
std::cout << "Workspaces:\n";
|
|
if (mon.workspaceStates.empty()) {
|
|
std::cout << " (None)\n";
|
|
} else {
|
|
for (const auto &pair : mon.workspaceStates) {
|
|
const WorkspaceState ws = pair.second;
|
|
std::cout << " - [ID: " << ws.id << "] "
|
|
<< "Active: " << (ws.active ? "Yes" : "No") << " | "
|
|
<< "Focused: " << (ws.focused ? "Yes" : "No") << " | "
|
|
<< "Urgent: " << (ws.urgent ? "Yes" : "No") << "\n";
|
|
}
|
|
}
|
|
std::cout << "====================\n";
|
|
}
|
|
|
|
sigc::signal<void(std::string, std::string)> socketEventSignal;
|
|
|
|
void start();
|
|
void on_hyprland_event(std::string event, std::string data);
|
|
|
|
Monitor* getMonitorById(const int &name);
|
|
|
|
private:
|
|
int m_fd = -1;
|
|
std::string m_buffer;
|
|
std::map<int, Monitor*> monitors;
|
|
|
|
bool on_socket_read(Glib::IOCondition condition);
|
|
void parse_message(const std::string &line);
|
|
std::string get_socket_path();
|
|
};
|