mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-12-22 12:19:49 +01:00
move socket to runtime dir
This commit is contained in:
parent
4b3843e283
commit
05daf2e746
1 changed files with 18 additions and 17 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
|
||||||
void CIPCSocket::initialize() {
|
void CIPCSocket::initialize() {
|
||||||
std::thread([&]() {
|
std::thread([&]() {
|
||||||
|
@ -24,12 +25,14 @@ void CIPCSocket::initialize() {
|
||||||
sockaddr_un SERVERADDRESS = {.sun_family = AF_UNIX};
|
sockaddr_un SERVERADDRESS = {.sun_family = AF_UNIX};
|
||||||
|
|
||||||
const auto HISenv = getenv("HYPRLAND_INSTANCE_SIGNATURE");
|
const auto HISenv = getenv("HYPRLAND_INSTANCE_SIGNATURE");
|
||||||
|
const std::string USERID = std::to_string(getpwuid(getuid())->pw_uid);
|
||||||
|
|
||||||
std::string socketPath = HISenv ? "/tmp/hypr/" + std::string(HISenv) + "/.hyprpaper.sock" : "/tmp/hypr/.hyprpaper.sock";
|
const auto USERDIR = "/run/user/" + USERID + "/hypr/";
|
||||||
|
|
||||||
if (!HISenv) {
|
std::string socketPath = HISenv ? USERDIR + std::string(HISenv) + "/.hyprpaper.sock" : USERDIR + ".hyprpaper.sock";
|
||||||
mkdir("/tmp/hypr", S_IRWXU | S_IRWXG);
|
|
||||||
}
|
if (!HISenv)
|
||||||
|
mkdir(USERDIR.c_str(), S_IRWXU);
|
||||||
|
|
||||||
unlink(socketPath.c_str());
|
unlink(socketPath.c_str());
|
||||||
|
|
||||||
|
@ -102,7 +105,6 @@ bool CIPCSocket::mainThreadParseRequest() {
|
||||||
m_bReplyReady = true;
|
m_bReplyReady = true;
|
||||||
m_bRequestReady = false;
|
m_bRequestReady = false;
|
||||||
|
|
||||||
|
|
||||||
// config commands
|
// config commands
|
||||||
if (copy.find("wallpaper") == 0 || copy.find("preload") == 0 || copy.find("unload") == 0) {
|
if (copy.find("wallpaper") == 0 || copy.find("preload") == 0 || copy.find("unload") == 0) {
|
||||||
|
|
||||||
|
@ -114,7 +116,6 @@ bool CIPCSocket::mainThreadParseRequest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy.find("listloaded") == 0) {
|
if (copy.find("listloaded") == 0) {
|
||||||
|
@ -132,11 +133,11 @@ bool CIPCSocket::mainThreadParseRequest() {
|
||||||
for (auto& [name, target] : g_pHyprpaper->m_mWallpaperTargets) {
|
for (auto& [name, target] : g_pHyprpaper->m_mWallpaperTargets) {
|
||||||
m_szReply += name;
|
m_szReply += name;
|
||||||
i++;
|
i++;
|
||||||
if (i < numWallpapersLoaded) m_szReply += '\n'; // dont add newline on last entry
|
if (i < numWallpapersLoaded)
|
||||||
|
m_szReply += '\n'; // dont add newline on last entry
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy.find("listactive") == 0) {
|
if (copy.find("listactive") == 0) {
|
||||||
|
@ -154,11 +155,11 @@ bool CIPCSocket::mainThreadParseRequest() {
|
||||||
for (auto& [mon, path1] : g_pHyprpaper->m_mMonitorActiveWallpapers) {
|
for (auto& [mon, path1] : g_pHyprpaper->m_mMonitorActiveWallpapers) {
|
||||||
m_szReply += mon + " = " + path1;
|
m_szReply += mon + " = " + path1;
|
||||||
i++;
|
i++;
|
||||||
if (i < numWallpapersActive) m_szReply += '\n'; // dont add newline on last entry
|
if (i < numWallpapersActive)
|
||||||
|
m_szReply += '\n'; // dont add newline on last entry
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_szReply = "invalid command";
|
m_szReply = "invalid command";
|
||||||
|
|
Loading…
Reference in a new issue