mirror of
https://github.com/swaywm/sway.git
synced 2025-11-09 13:29:49 -05:00
ipc: Store socketname in SWAYSOCK. Fixes --get-socketpath.
After adding pid to the socket path the `--get-socketpath` command broke because it doesn't know the pid of the running instance. Fix this by setting and querying `SWAYSOCK`. Also ignore `SWAYSOCK` upon normal startup if a socket exists at that location (ie. from another sway instance), and don't overwrite `I3SOCK` if it exists either.
This commit is contained in:
parent
2cc6d39d46
commit
f64b7e71d4
2 changed files with 15 additions and 6 deletions
10
sway/ipc.c
10
sway/ipc.c
|
|
@ -52,7 +52,8 @@ void ipc_init(void) {
|
|||
|
||||
ipc_sockaddr = ipc_user_sockaddr();
|
||||
|
||||
if (getenv("SWAYSOCK") != NULL) {
|
||||
// We want to use socket name set by user, not existing socket from another sway instance.
|
||||
if (getenv("SWAYSOCK") != NULL && access(getenv("SWAYSOCK"), F_OK) == -1) {
|
||||
strncpy(ipc_sockaddr->sun_path, getenv("SWAYSOCK"), sizeof(ipc_sockaddr->sun_path));
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +67,12 @@ void ipc_init(void) {
|
|||
}
|
||||
|
||||
// Set i3 IPC socket path so that i3-msg works out of the box
|
||||
setenv("I3SOCK", ipc_sockaddr->sun_path, 1);
|
||||
if (!getenv("I3SOCK")) {
|
||||
setenv("I3SOCK", ipc_sockaddr->sun_path, 1);
|
||||
}
|
||||
if (!getenv("SWAYSOCK")) {
|
||||
setenv("SWAYSOCK", ipc_sockaddr->sun_path, 1);
|
||||
}
|
||||
|
||||
ipc_client_list = create_list();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue