From b674afc1788ded090b2fbbdba4ce1db95465d81a Mon Sep 17 00:00:00 2001 From: Stephen Brown II Date: Thu, 31 Dec 2015 10:41:29 -0600 Subject: [PATCH] Use the I3SOCK environment variable, if available Similar to https://github.com/acrisci/i3ipc-python/pull/19 This library works on [sway](https://github.com/SirCmpwn/sway) with this patch applied. --- i3.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/i3.py b/i3.py index 48555d2..edad842 100644 --- a/i3.py +++ b/i3.py @@ -17,6 +17,7 @@ #====================================================================== +import os import sys import subprocess import json @@ -441,11 +442,13 @@ def callback(event, data, subscription): def get_socket_path(): """ - Gets the socket path via i3 command. + Gets the socket path from environment variable or via i3 command. """ - cmd = ['i3', '--get-socketpath'] - output = __call_cmd__(cmd) - return output + socket_path = os.environ.get('I3SOCK') + if not socket_path: + cmd = ['i3', '--get-socketpath'] + socket_path = __call_cmd__(cmd) + return socket_path def success(response):