mirror of
https://github.com/swaywm/sway.git
synced 2025-11-06 13:29:50 -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
11
sway/main.c
11
sway/main.c
|
|
@ -107,10 +107,13 @@ int main(int argc, char **argv) {
|
|||
verbose = 1;
|
||||
break;
|
||||
case 'p': ; // --get-socketpath
|
||||
struct sockaddr_un *ipc_sockaddr = ipc_user_sockaddr();
|
||||
fprintf(stdout, "%s\n", ipc_sockaddr->sun_path);
|
||||
free(ipc_sockaddr);
|
||||
exit(0);
|
||||
if (getenv("SWAYSOCK")) {
|
||||
fprintf(stdout, "%s\n", getenv("SWAYSOCK"));
|
||||
exit(0);
|
||||
} else {
|
||||
fprintf(stderr, "sway socket not detected.\n");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue