mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-11-16 22:25:59 +01:00
ipc: Added listloaded and listactive requests (#132)
This commit is contained in:
parent
43b6e9d2e2
commit
1013a80608
2 changed files with 64 additions and 14 deletions
|
@ -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
|
||||
```
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
m_szReply = "ok";
|
||||
m_bReplyReady = true;
|
||||
m_bRequestReady = 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;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
m_szReply = "invalid command";
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue