From 23796ea90075855ef6522e4fee8bc3e6777514c2 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 2 Oct 2011 16:12:10 +0100 Subject: [PATCH] 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 :). --- include/all.h | 1 + src/main.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/all.h b/include/all.h index 9c08ebef..38cda89c 100644 --- a/include/all.h +++ b/include/all.h @@ -65,5 +65,6 @@ #include "ewmh.h" #include "assignments.h" #include "regex.h" +#include "libi3.h" #endif diff --git a/src/main.c b/src/main.c index d51c8c65..19c45681 100644 --- a/src/main.c +++ b/src/main.c @@ -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); -- 2.39.5