Closed marcusbritanicus closed 1 month ago
If we're going to do this, move the socket to XDG_RUNTIME_DIR :)
If we're going to do this, move the socket to XDG_RUNTIME_DIR :)
void init() override
{
char *pre_socket = getenv("_WAYFIRE_SOCKET");
const char *runtime_dir = getenv("XDG_RUNTIME_DIR");
const auto& dname = wf::get_core().wayland_display;
pid_t pid = getpid();
std::string socket;
if (pre_socket)
{
socket = pre_socket;
}
else if (runtime_dir)
{
socket = std::string(runtime_dir) + "/wayfire-" + dname + "-" + std::to_string(pid) + ".socket";
}
else
{
socket = "/tmp/wayfire-" + dname + "-" + std::to_string(pid) + ".socket";
}
setenv("WAYFIRE_SOCKET", socket.c_str(), 1);
server->init(socket);
}
@killown I think you should open a PR. You're clearly doing a much better job than I can.
I don't think we need the pid when the socket is in $XDG_RUNTIME_DIR, without the pid I also think it is just a little bit simpler to find the socket when running from somewhere where $WAYFIRE_SOCKET is not set. Otherwise @killown's patch lgtm, I don't know why you won't send a pr :)
The solution proposed by @killown to make the socket path unique. I have tested this and confirm that it works.