Skip to content

Commit

Permalink
Make socket path unique (#2490)
Browse files Browse the repository at this point in the history
* Make socket path unique

* Use XDG_RUNTIME_DIR to create ipc socket

* Fix runtime_dir not declared
  • Loading branch information
marcusbritanicus authored Oct 26, 2024
1 parent 6bbd362 commit 2d7070a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions plugins/ipc/ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,23 @@ class ipc_plugin_t : public wf::plugin_interface_t
public:
void init() override
{
char *pre_socket = getenv("_WAYFIRE_SOCKET");
const auto& dname = wf::get_core().wayland_display;
std::string socket = pre_socket ?: "/tmp/wayfire-" + dname + ".socket";
char *pre_socket = getenv("_WAYFIRE_SOCKET");
const auto& dname = wf::get_core().wayland_display;
pid_t pid = getpid();
const char *runtime_dir = getenv("XDG_RUNTIME_DIR");

std::string socket;
if (pre_socket)
{
socket = pre_socket;
} else if (runtime_dir)
{
socket = std::string(runtime_dir) + "/wayfire-" + dname + "-" + ".socket";
} else
{
socket = "/tmp/wayfire-" + dname + "-" + std::to_string(pid) + ".socket";
}

setenv("WAYFIRE_SOCKET", socket.c_str(), 1);
server->init(socket);
}
Expand Down

0 comments on commit 2d7070a

Please sign in to comment.