From ee3cddc7ca8a5476ceada5fb54b80b612d4af744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miskolczi=20Rich=C3=A1rd?= Date: Tue, 10 Jun 2025 15:45:03 +0200 Subject: [PATCH] Using macros instead of hardcoded paths --- include/HyprlandService.h | 7 +++++++ src/HyprlandService.cpp | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/HyprlandService.h b/include/HyprlandService.h index 8d62753..262c641 100644 --- a/include/HyprlandService.h +++ b/include/HyprlandService.h @@ -1,6 +1,13 @@ #ifndef HYPRLAND_SERVICE_H #define HYPRLAND_SERVICE_H +#define HYPRLAND_CONF_DIR "~/.config/hypr/" +#define FLOATING_RULE_CONF_FILE HYPRLAND_CONF_DIR "hyprland/floatbydefault.conf" +#define HYPRCTL_BINARY "/usr/bin/hyprctl" +#define NULL_PATH "/dev/null" +#define SET_FLOATING_RULE "/usr/bin/echo 'windowrule = float,class:.*' > " FLOATING_RULE_CONF_FILE +#define REMOVE_FLOATING_RULE "/usr/bin/cat " NULL_PATH " > " FLOATING_RULE_CONF_FILE + #include #include #include "Workspace.h" diff --git a/src/HyprlandService.cpp b/src/HyprlandService.cpp index 2e3312a..f72699b 100644 --- a/src/HyprlandService.cpp +++ b/src/HyprlandService.cpp @@ -24,12 +24,12 @@ std::string HyprlandService::exec(const std::string& command) { }; Workspace HyprlandService::getCurrentWorkspace() { - json j = json::parse(exec("/usr/bin/hyprctl activeworkspace -j")); + json j = json::parse(exec(HYPRCTL_BINARY " activeworkspace -j")); return j.get(); }; std::list HyprlandService::getClients() { - json j = json::parse(exec("/usr/bin/hyprctl clients -j")); + json j = json::parse(exec(HYPRCTL_BINARY " clients -j")); return j.get>(); }; @@ -49,11 +49,11 @@ std::list HyprlandService::getClientsOnActiveWorkspace() { }; void HyprlandService::setClientFloating(Client& c) { - exec("/usr/bin/hyprctl dispatch setfloating address:" + c.address); + exec(HYPRCTL_BINARY " dispatch setfloating address:" + c.address); }; void HyprlandService::setClientTiled(Client& c) { - exec("/usr/bin/hyprctl dispatch settiled address:" + c.address); + exec(HYPRCTL_BINARY " dispatch settiled address:" + c.address); } void HyprlandService::toggleClientFloating(Client& c) {