11
11
#include < sys/types.h>
12
12
#include < sys/un.h>
13
13
#include < unistd.h>
14
+ #include < pwd.h>
14
15
15
16
void CIPCSocket::initialize () {
16
17
std::thread ([&]() {
@@ -24,12 +25,14 @@ void CIPCSocket::initialize() {
24
25
sockaddr_un SERVERADDRESS = {.sun_family = AF_UNIX};
25
26
26
27
const auto HISenv = getenv (" HYPRLAND_INSTANCE_SIGNATURE" );
28
+ const std::string USERID = std::to_string (getpwuid (getuid ())->pw_uid );
27
29
28
- std::string socketPath = HISenv ? " /tmp/hypr /" + std::string (HISenv) + " /.hyprpaper.sock " : " /tmp/ hypr/.hyprpaper.sock " ;
30
+ const auto USERDIR = " /run/user /" + USERID + " /hypr/" ;
29
31
30
- if (!HISenv) {
31
- mkdir (" /tmp/hypr" , S_IRWXU | S_IRWXG);
32
- }
32
+ std::string socketPath = HISenv ? USERDIR + std::string (HISenv) + " /.hyprpaper.sock" : USERDIR + " .hyprpaper.sock" ;
33
+
34
+ if (!HISenv)
35
+ mkdir (USERDIR.c_str (), S_IRWXU);
33
36
34
37
unlink (socketPath.c_str ());
35
38
@@ -92,7 +95,7 @@ bool CIPCSocket::mainThreadParseRequest() {
92
95
93
96
if (copy == " " )
94
97
return false ;
95
-
98
+
96
99
// now we can work on the copy
97
100
98
101
Debug::log (LOG, " Received a request: %s" , copy.c_str ());
@@ -102,7 +105,6 @@ bool CIPCSocket::mainThreadParseRequest() {
102
105
m_bReplyReady = true ;
103
106
m_bRequestReady = false ;
104
107
105
-
106
108
// config commands
107
109
if (copy.find (" wallpaper" ) == 0 || copy.find (" preload" ) == 0 || copy.find (" unload" ) == 0 ) {
108
110
@@ -114,51 +116,50 @@ bool CIPCSocket::mainThreadParseRequest() {
114
116
}
115
117
116
118
return true ;
117
-
118
119
}
119
-
120
+
120
121
if (copy.find (" listloaded" ) == 0 ) {
121
-
122
+
122
123
const auto numWallpapersLoaded = g_pHyprpaper->m_mWallpaperTargets .size ();
123
124
Debug::log (LOG, " numWallpapersLoaded: %d" , numWallpapersLoaded);
124
125
125
126
if (numWallpapersLoaded == 0 ) {
126
127
m_szReply = " no wallpapers loaded" ;
127
128
return false ;
128
129
}
129
-
130
+
130
131
m_szReply = " " ;
131
132
long unsigned int i = 0 ;
132
133
for (auto & [name, target] : g_pHyprpaper->m_mWallpaperTargets ) {
133
134
m_szReply += name;
134
135
i++;
135
- if (i < numWallpapersLoaded) m_szReply += ' \n ' ; // dont add newline on last entry
136
+ if (i < numWallpapersLoaded)
137
+ m_szReply += ' \n ' ; // dont add newline on last entry
136
138
}
137
139
138
140
return true ;
139
-
140
141
}
141
142
142
143
if (copy.find (" listactive" ) == 0 ) {
143
-
144
+
144
145
const auto numWallpapersActive = g_pHyprpaper->m_mMonitorActiveWallpapers .size ();
145
146
Debug::log (LOG, " numWallpapersActive: %d" , numWallpapersActive);
146
147
147
148
if (numWallpapersActive == 0 ) {
148
149
m_szReply = " no wallpapers active" ;
149
150
return false ;
150
151
}
151
-
152
+
152
153
m_szReply = " " ;
153
154
long unsigned int i = 0 ;
154
155
for (auto & [mon, path1] : g_pHyprpaper->m_mMonitorActiveWallpapers ) {
155
156
m_szReply += mon + " = " + path1;
156
157
i++;
157
- if (i < numWallpapersActive) m_szReply += ' \n ' ; // dont add newline on last entry
158
+ if (i < numWallpapersActive)
159
+ m_szReply += ' \n ' ; // dont add newline on last entry
158
160
}
159
-
160
- return true ;
161
161
162
+ return true ;
162
163
}
163
164
164
165
m_szReply = " invalid command" ;
0 commit comments