Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipc: Added listloaded and listactive requests #132

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ bind=SUPERSHIFT,1,movetoworkspace,1 #Superkey + Shift + 1 moves windows and swi
bind=SUPERSHIFT,1,exec,$w1 #SuperKey + Shift + 1 switches to wallpaper $w1 on DP-1 as defined in the variable
```

## Getting information from hyprpaper
You can also use `hyprctl hyprpaper` to get information about the state of hyprpaper using the following commands:
```
listloaded - lists the wallpapers that are currently preloaded (useful for dynamically preloading and unloading)
listactive - prints the active wallpapers hyprpaper is displaying, along with its accociated monitor
```

# Battery life
Since the IPC has to tick every now and then, and poll in the background, battery life might be a tiny bit worse with IPC on. If you want to fully disable it, use
```
Expand Down
71 changes: 57 additions & 14 deletions src/ipc/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,34 +90,77 @@ bool CIPCSocket::mainThreadParseRequest() {

std::string copy = m_szRequest;

// now we can work on the copy

if (copy == "")
return false;

// now we can work on the copy

Debug::log(LOG, "Received a request: %s", copy.c_str());

// parse
// set default reply
m_szReply = "ok";
m_bReplyReady = true;
m_bRequestReady = false;


// config commands
if (copy.find("wallpaper") == 0 || copy.find("preload") == 0 || copy.find("unload") == 0) {

const auto RESULT = g_pConfigManager->config->parseDynamic(copy.substr(0, copy.find_first_of(' ')).c_str(), copy.substr(copy.find_first_of(' ') + 1).c_str());

if (RESULT.error) {
m_szReply = RESULT.getError();
m_bReplyReady = true;
m_bRequestReady = false;
return false;
}
} else {
m_szReply = "invalid command";
m_bReplyReady = true;
m_bRequestReady = false;
return false;

return true;

}

if (copy.find("listloaded") == 0) {

const auto numWallpapersLoaded = g_pHyprpaper->m_mWallpaperTargets.size();
Debug::log(LOG, "numWallpapersLoaded: %d", numWallpapersLoaded);

if (numWallpapersLoaded == 0) {
m_szReply = "no wallpapers loaded";
return false;
}

m_szReply = "";
long unsigned int i = 0;
for (auto& [name, target] : g_pHyprpaper->m_mWallpaperTargets) {
m_szReply += name;
i++;
if (i < numWallpapersLoaded) m_szReply += '\n'; // dont add newline on last entry
}

return true;

}

m_szReply = "ok";
m_bReplyReady = true;
m_bRequestReady = false;
if (copy.find("listactive") == 0) {

const auto numWallpapersActive = g_pHyprpaper->m_mMonitorActiveWallpapers.size();
Debug::log(LOG, "numWallpapersActive: %d", numWallpapersActive);

if (numWallpapersActive == 0) {
m_szReply = "no wallpapers active";
return false;
}

m_szReply = "";
long unsigned int i = 0;
for (auto& [mon, path1] : g_pHyprpaper->m_mMonitorActiveWallpapers) {
m_szReply += mon + " = " + path1;
i++;
if (i < numWallpapersActive) m_szReply += '\n'; // dont add newline on last entry
}

return true;

}

return true;
m_szReply = "invalid command";
return false;
}
Loading