Using macros instead of hardcoded paths
This commit is contained in:
@@ -1,6 +1,13 @@
|
|||||||
#ifndef HYPRLAND_SERVICE_H
|
#ifndef HYPRLAND_SERVICE_H
|
||||||
#define 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 <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "Workspace.h"
|
#include "Workspace.h"
|
||||||
|
|||||||
@@ -24,12 +24,12 @@ std::string HyprlandService::exec(const std::string& command) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Workspace HyprlandService::getCurrentWorkspace() {
|
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<Workspace>();
|
return j.get<Workspace>();
|
||||||
};
|
};
|
||||||
|
|
||||||
std::list<Client> HyprlandService::getClients() {
|
std::list<Client> HyprlandService::getClients() {
|
||||||
json j = json::parse(exec("/usr/bin/hyprctl clients -j"));
|
json j = json::parse(exec(HYPRCTL_BINARY " clients -j"));
|
||||||
return j.get<std::list<Client>>();
|
return j.get<std::list<Client>>();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -49,11 +49,11 @@ std::list<Client> HyprlandService::getClientsOnActiveWorkspace() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void HyprlandService::setClientFloating(Client& c) {
|
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) {
|
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) {
|
void HyprlandService::toggleClientFloating(Client& c) {
|
||||||
|
|||||||
Reference in New Issue
Block a user