Skip to content

Commit

Permalink
also check mon description
Browse files Browse the repository at this point in the history
  • Loading branch information
bvr-yr committed Mar 22, 2024
1 parent f88579e commit 48a4093
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/core/Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ static void handleName(void* data, wl_output* output, const char* name) {
}

static void handleDescription(void* data, wl_output* output, const char* description) {
const auto POUTPUT = (COutput*)data;
Debug::log(LOG, "output {} description {}", POUTPUT->name, description ? description : "");
const auto POUTPUT = (COutput*)data;
POUTPUT->description = description ? std::string{description} : "";
Debug::log(LOG, "output {} description {}", POUTPUT->name, POUTPUT->description);
}

static const wl_output_listener outputListener = {
Expand All @@ -61,4 +62,4 @@ static const wl_output_listener outputListener = {

COutput::COutput(wl_output* output, uint32_t name) : name(name), output(output) {
wl_output_add_listener(output, &outputListener, this);
}
}
9 changes: 5 additions & 4 deletions src/core/Output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ class COutput {
bool focused = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
Vector2D size;
int scale = 1;
std::string stringName = "";
std::string stringPort = "";
int scale = 1;
std::string stringName = "";
std::string stringPort = "";
std::string description = "";

std::unique_ptr<CSessionLockSurface> sessionLockSurface;

wl_output* output = nullptr;

private:
};
};
6 changes: 4 additions & 2 deletions src/helpers/Ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ std::unordered_map<std::string, std::string> requestHyprpaper() {
close(SERVERSOCKET);

for (const auto& s : CVarList((std::string)buffer, 0, '\n')) {
const std::string MON = s.substr(0, s.find_first_of('=') - 1);
resp[MON] = s.substr(s.find_first_of('=') + 2);
const CVarList MONWP(s, 0, '=');
const std::string MON = MONWP[0].starts_with("desc:") ? MONWP[0].substr(5) : MONWP[0];
if (!MON.empty())
resp[MON] = MONWP[1];
}

return resp;
Expand Down
9 changes: 6 additions & 3 deletions src/renderer/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,12 @@ std::vector<std::unique_ptr<IWidget>>* CRenderer::getOrCreateWidgetsFor(const CS
if (PATH == "screenshot") {
resourceID = "dma:" + surf->output->stringPort;
} else if (PATH == "hyprpaper") {
const auto HMAP = g_pConfigManager->hyprpaperMonToPath;
if (HMAP.contains(surf->output->stringPort))
resourceID = "hyprpaper:" + surf->output->stringPort + ":" + HMAP.at(surf->output->stringPort);
for (const auto& h : g_pConfigManager->hyprpaperMonToPath) {
if (h.first == surf->output->stringPort || surf->output->description.find(h.first) == 0) {
resourceID = "hyprpaper:" + h.first + ":" + h.second;
break;
}
}
} else if (!PATH.empty())
resourceID = "background:" + PATH;

Expand Down

0 comments on commit 48a4093

Please sign in to comment.