diff --git a/include/HyprlandService.h b/include/HyprlandService.h index 262c641..01a3fe4 100644 --- a/include/HyprlandService.h +++ b/include/HyprlandService.h @@ -19,6 +19,7 @@ class HyprlandService { static Workspace getCurrentWorkspace(); static std::list getClients(); static std::list getClientsOnActiveWorkspace(); + static void setFloatingRule(bool); static void setClientFloating(Client&); static void setClientTiled(Client&); static void toggleClientFloating(Client&); diff --git a/src/HyprlandService.cpp b/src/HyprlandService.cpp index f72699b..ada5d1a 100644 --- a/src/HyprlandService.cpp +++ b/src/HyprlandService.cpp @@ -57,5 +57,14 @@ void HyprlandService::setClientTiled(Client& c) { } void HyprlandService::toggleClientFloating(Client& c) { - exec("/usr/bin/hyprctl dispatch togglefloating address:" + c.address); + exec(HYPRCTL_BINARY " dispatch togglefloating address:" + c.address); +}; + +void HyprlandService::setFloatingRule(bool b) { + if (b) { + exec(SET_FLOATING_RULE); + } + else { + exec(REMOVE_FLOATING_RULE); + } }; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index e07601d..5db62d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,76 +3,15 @@ #include int main(int, char**){ - Workspace w = HyprlandService::getCurrentWorkspace(); - std::cout << "Active workspace:" << std::endl; - std::cout << " id: " << w.id << std::endl; - std::cout << " name: " << w.name << std::endl; - std::cout << " monitor: " << w.monitor << std::endl; - std::cout << " monitorID: " << w.monitorID << std::endl; - std::cout << " windows: " << w.windows << std::endl; - std::cout << " hasfullscreen: " << w.hasfullscreen << std::endl; - std::cout << " lastwindow: " << w.lastwindow << std::endl; - std::cout << " lastwindowtitle: " << w.lastwindowtitle << std::endl; - std::cout << " ispersistent: " << w.ispersistent << std::endl; - std::cout << std::endl; + for (auto& c : HyprlandService::getClientsOnActiveWorkspace()) { + HyprlandService::setClientFloating(c); + } + HyprlandService::setFloatingRule(true); - std::cout << "---------------------------------------------" << std::endl << std::endl; + sleep(5); - std::list clients = HyprlandService::getClients(); - for (const auto& c : clients) { - std::cout << "Client:" << std::endl; - std::cout << " address: " << c.address << std::endl; - std::cout << " mapped: " << c.mapped << std::endl; - std::cout << " hidden: " << c.hidden << std::endl; - std::cout << " size: [" << c.size[0] << ", " << c.size[1] << "]" << std::endl; - std::cout << " workspace.id: " << c.workspace.id << std::endl; - std::cout << " workspace.name: " << c.workspace.name << std::endl; - std::cout << " floating: " << c.floating << std::endl; - std::cout << " pseudo: " << c.pseudo << std::endl; - std::cout << " monitor: " << c.monitor << std::endl; - std::cout << " className: " << c.className << std::endl; - std::cout << " title: " << c.title << std::endl; - std::cout << " initialClass: " << c.initialClass << std::endl; - std::cout << " initialTitle: " << c.initialTitle << std::endl; - std::cout << " pid: " << c.pid << std::endl; - std::cout << " xwayland: " << c.xwayland << std::endl; - std::cout << " pinned: " << c.pinned << std::endl; - std::cout << " fullscreen: " << c.fullscreen << std::endl; - std::cout << " fullscreenClient: " << c.fullscreenClient << std::endl; - std::cout << " swallowing: " << c.swallowing << std::endl; - std::cout << " focusHistory: " << c.focusHistory << std::endl; - std::cout << " inhibitingIdle: " << c.inhibitingIdle << std::endl; - std::cout << " xdgTag: " << c.xdgTag << std::endl; - std::cout << " xdgDescription: " << c.xdgDescription << std::endl; - std::cout << std::endl; - } - - std::cout << "---------------------------------------------" << std::endl << std::endl; - - std::list 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()); -} + for (auto& c : HyprlandService::getClientsOnActiveWorkspace()) { + HyprlandService::setClientTiled(c); + } + HyprlandService::setFloatingRule(false); +} \ No newline at end of file