Controlling tiled/floating mode works
This commit is contained in:
@@ -11,6 +11,10 @@ class HyprlandService {
|
||||
public:
|
||||
static Workspace getCurrentWorkspace();
|
||||
static std::list<Client> getClients();
|
||||
static std::list<Client> getClientsOnActiveWorkspace();
|
||||
static void setClientFloating(Client&);
|
||||
static void setClientTiled(Client&);
|
||||
static void toggleClientFloating(Client&);
|
||||
static std::string exec(const std::string& command);
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -32,3 +32,30 @@ std::list<Client> HyprlandService::getClients() {
|
||||
json j = json::parse(exec("/usr/bin/hyprctl clients -j"));
|
||||
return j.get<std::list<Client>>();
|
||||
};
|
||||
|
||||
std::list<Client> HyprlandService::getClientsOnActiveWorkspace() {
|
||||
std::list<Client> clients = HyprlandService::getClients();
|
||||
int activeWorkspaceID = HyprlandService::getCurrentWorkspace().id;
|
||||
|
||||
for (auto it = clients.begin(); it != clients.end(); ) {
|
||||
if (it->workspace.id != activeWorkspaceID) {
|
||||
it = clients.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
return clients;
|
||||
};
|
||||
|
||||
void HyprlandService::setClientFloating(Client& c) {
|
||||
exec("/usr/bin/hyprctl dispatch setfloating address:" + c.address);
|
||||
};
|
||||
|
||||
void HyprlandService::setClientTiled(Client& c) {
|
||||
exec("/usr/bin/hyprctl dispatch settiled address:" + c.address);
|
||||
}
|
||||
|
||||
void HyprlandService::toggleClientFloating(Client& c) {
|
||||
exec("/usr/bin/hyprctl dispatch togglefloating address:" + c.address);
|
||||
};
|
||||
32
src/main.cpp
32
src/main.cpp
@@ -1,5 +1,6 @@
|
||||
#include <iostream>
|
||||
#include "../include/HyprlandService.h"
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int, char**){
|
||||
Workspace w = HyprlandService::getCurrentWorkspace();
|
||||
@@ -15,6 +16,8 @@ int main(int, char**){
|
||||
std::cout << " ispersistent: " << w.ispersistent << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "---------------------------------------------" << std::endl << std::endl;
|
||||
|
||||
std::list<Client> clients = HyprlandService::getClients();
|
||||
for (const auto& c : clients) {
|
||||
std::cout << "Client:" << std::endl;
|
||||
@@ -43,4 +46,33 @@ int main(int, char**){
|
||||
std::cout << " xdgDescription: " << c.xdgDescription << std::endl;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "---------------------------------------------" << std::endl << std::endl;
|
||||
|
||||
std::list<Client> activeClients = HyprlandService::getClientsOnActiveWorkspace();
|
||||
for (const auto& c : activeClients) {
|
||||
std::cout << "Active client:" << std::endl;
|
||||
std::cout << " workspace.id: " << c.workspace.id << std::endl;
|
||||
std::cout << " workspace.name: " << c.workspace.name << std::endl;
|
||||
std::cout << " className: " << c.className << std::endl;
|
||||
std::cout << " title: " << c.title << std::endl;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
|
||||
std::cout << "Setting " << activeClients.front().className << " into floating mode..." << std::endl;
|
||||
sleep(2);
|
||||
HyprlandService::setClientFloating(activeClients.front());
|
||||
|
||||
std::cout << "Setting " << activeClients.front().className << " into tiled mode..." << std::endl;
|
||||
sleep(2);
|
||||
HyprlandService::setClientTiled(activeClients.front());
|
||||
|
||||
std::cout << "Toggling floating mode for " << activeClients.front().className << " ..." << std::endl;
|
||||
sleep(2);
|
||||
HyprlandService::toggleClientFloating(activeClients.front());
|
||||
|
||||
std::cout << "Toggling floating mode for " << activeClients.front().className << " once more..." << std::endl;
|
||||
sleep(2);
|
||||
HyprlandService::toggleClientFloating(activeClients.front());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user