Implement i3 --get-socketpath, useful for IPC scripts

In order to not depend on X11 just for getting the socket paths, scripts or
other programs can now use i3 --get-socketpath. Since i3 must be present on the
computer anyways, this saves one dependency :).
This commit is contained in:
Michael Stapelberg 2011-10-02 16:12:10 +01:00
parent 6af8b0941c
commit 23796ea900
2 changed files with 10 additions and 0 deletions

View File

@ -65,5 +65,6 @@
#include "ewmh.h"
#include "assignments.h"
#include "regex.h"
#include "libi3.h"
#endif

View File

@ -189,6 +189,7 @@ int main(int argc, char *argv[]) {
{"restart", required_argument, 0, 0},
{"force-xinerama", no_argument, 0, 0},
{"disable-signalhandler", no_argument, 0, 0},
{"get-socketpath", no_argument, 0, 0},
{0, 0, 0, 0}
};
int option_index = 0, opt;
@ -247,6 +248,14 @@ int main(int argc, char *argv[]) {
} else if (strcmp(long_options[option_index].name, "disable-signalhandler") == 0) {
disable_signalhandler = true;
break;
} else if (strcmp(long_options[option_index].name, "get-socketpath") == 0) {
char *socket_path = socket_path_from_x11();
if (socket_path) {
printf("%s\n", socket_path);
return 0;
}
return 1;
} else if (strcmp(long_options[option_index].name, "restart") == 0) {
FREE(layout_path);
layout_path = sstrdup(optarg);