mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Merge pull request #226 from sce/fix_get_socketpath
ipc: Store socketname in SWAYSOCK. Fixes `--get-socketpath`.
This commit is contained in:
		
						commit
						3dbdc40b0e
					
				
					 2 changed files with 15 additions and 6 deletions
				
			
		| 
						 | 
					@ -52,7 +52,8 @@ void ipc_init(void) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ipc_sockaddr = ipc_user_sockaddr();
 | 
						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));
 | 
							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
 | 
						// Set i3 IPC socket path so that i3-msg works out of the box
 | 
				
			||||||
 | 
						if (!getenv("I3SOCK")) {
 | 
				
			||||||
		setenv("I3SOCK", ipc_sockaddr->sun_path, 1);
 | 
							setenv("I3SOCK", ipc_sockaddr->sun_path, 1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (!getenv("SWAYSOCK")) {
 | 
				
			||||||
 | 
							setenv("SWAYSOCK", ipc_sockaddr->sun_path, 1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ipc_client_list = create_list();
 | 
						ipc_client_list = create_list();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -107,10 +107,13 @@ int main(int argc, char **argv) {
 | 
				
			||||||
			verbose = 1;
 | 
								verbose = 1;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case 'p': ; // --get-socketpath
 | 
							case 'p': ; // --get-socketpath
 | 
				
			||||||
			struct sockaddr_un *ipc_sockaddr = ipc_user_sockaddr();
 | 
								if (getenv("SWAYSOCK")) {
 | 
				
			||||||
			fprintf(stdout, "%s\n", ipc_sockaddr->sun_path);
 | 
									fprintf(stdout, "%s\n", getenv("SWAYSOCK"));
 | 
				
			||||||
			free(ipc_sockaddr);
 | 
					 | 
				
			||||||
				exit(0);
 | 
									exit(0);
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									fprintf(stderr, "sway socket not detected.\n");
 | 
				
			||||||
 | 
									exit(1);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue