From 4caf85aa0be4b5d60213fbe2b8f8115df1607c6d Mon Sep 17 00:00:00 2001 From: Axel Wagner Date: Tue, 11 Jan 2011 04:39:48 +0100 Subject: [PATCH] Use I3SOCK-environment-variable --- docs/ipc | 8 ++++++-- docs/userguide | 2 ++ i3-input/main.c | 5 ++++- i3-msg/main.c | 5 ++++- man/i3-input.man | 8 ++++++++ man/i3-msg.man | 8 ++++++++ man/i3.man | 8 ++++++++ src/main.c | 2 ++ 8 files changed, 42 insertions(+), 4 deletions(-) diff --git a/docs/ipc b/docs/ipc index 4e46bc9e..1c31d061 100644 --- a/docs/ipc +++ b/docs/ipc @@ -11,8 +11,12 @@ workspace bar. The method of choice for IPC in our case is a unix socket because it has very little overhead on both sides and is usually available without headaches in most languages. In the default configuration file, no ipc-socket path is -specified and thus no socket is created. The standard path (which +i3-msg+ and -+i3-input+ use) is +/tmp/i3-ipc.sock+. +specified and thus no socket is created. Alternatively you can set the +environment-variable +I3SOCK+. Setting a path in the configfile will override ++I3SOCK+. + ++i3-msg+ and +i3-input+ will use +I3SOCK+ to connect to i3, unless -s is passed. +If neither is given, they will default to +/tmp/i3-ipc.sock+. == Establishing a connection diff --git a/docs/userguide b/docs/userguide index 7e2438f0..35e587af 100644 --- a/docs/userguide +++ b/docs/userguide @@ -521,6 +521,8 @@ programs to get information from i3, such as the current workspaces To enable it, you have to configure a path where the unix socket will be stored. The default path is +/tmp/i3-ipc.sock+. +You can override the default path through the environment-variable +I3SOCK+. + *Examples*: ---------------------------- ipc-socket /tmp/i3-ipc.sock diff --git a/i3-input/main.c b/i3-input/main.c index 6c2b35a1..b9b4ba81 100644 --- a/i3-input/main.c +++ b/i3-input/main.c @@ -241,7 +241,10 @@ static int handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_press } int main(int argc, char *argv[]) { - char *socket_path = "/tmp/i3-ipc.sock"; + char *socket_path; + if ((socket_path = getenv("I3SOCK")) == NULL) { + socket_path = "/tmp/i3-ipc.sock"; + } char *pattern = "-misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1"; int o, option_index = 0; diff --git a/i3-msg/main.c b/i3-msg/main.c index a2cd9e0a..6a51ff55 100644 --- a/i3-msg/main.c +++ b/i3-msg/main.c @@ -107,7 +107,10 @@ static void ipc_recv_message(int sockfd, uint32_t message_type, } int main(int argc, char *argv[]) { - char *socket_path = "/tmp/i3-ipc.sock"; + char *socket_path; + if ((socket_path = getenv("I3SOCK")) == NULL) { + socket_path = "/tmp/i3-ipc.sock"; + } int o, option_index = 0; int message_type = I3_IPC_MESSAGE_TYPE_COMMAND; char *payload = ""; diff --git a/man/i3-input.man b/man/i3-input.man index fee4d92e..cd85c92c 100644 --- a/man/i3-input.man +++ b/man/i3-input.man @@ -23,6 +23,14 @@ mark/goto command. i3-input -p 'mark ' -l 1 -P 'Mark: ' ------------------------------------------------ +== ENVIRONMENT + +=== I3SOCK + +If no ipc-socket is specified on the commandline, this variable is used +to determine the path, at wich the unix domain socket is expected, on which +to connect to i3. + == SEE ALSO i3(1) diff --git a/man/i3-msg.man b/man/i3-msg.man index c723bd1e..116195b7 100644 --- a/man/i3-msg.man +++ b/man/i3-msg.man @@ -24,6 +24,14 @@ future (staying backwards-compatible, of course). i3-msg "bp" # Use 1-px border for current client ------------------------------------------------ +== ENVIRONMENT + +=== I3SOCK + +If no ipc-socket is specified on the commandline, this variable is used +to determine the path, at wich the unix domain socket is expected, on which +to connect to i3. + == SEE ALSO i3(1) diff --git a/man/i3.man b/man/i3.man index 5877f143..7dbe0dfa 100644 --- a/man/i3.man +++ b/man/i3.man @@ -282,6 +282,14 @@ echo "Starting at $(date)" >> ~/.i3/logfile exec /usr/bin/i3 >> ~/.i3/logfile ------------------------------------------------------------- +== ENVIRONMENT + +=== I3SOCK + +If no ipc-socket is specified in the configfile, this variable is used +to determine the path, at wich the unix domain socket is created, on which +i3 listenes to incoming connections. + == TODO There is still lot of work to do. Please check our bugtracker for up-to-date diff --git a/src/main.c b/src/main.c index 64a6e309..9cc70b9b 100644 --- a/src/main.c +++ b/src/main.c @@ -99,6 +99,8 @@ int main(int argc, char *argv[]) { if (!isatty(fileno(stdout))) setbuf(stdout, NULL); + config.ipc_socket_path = getenv("I3SOCK"); + start_argv = argv; while ((opt = getopt_long(argc, argv, "c:CvaL:hld:V", long_options, &option_index)) != -1) { -- 2.39.5