diff --git a/i3ipc.py b/i3ipc.py
index <HASH>..<HASH> 100644
--- a/i3ipc.py
+++ b/i3ipc.py
@@ -5,6 +5,7 @@ import json
 import socket
 import os
 import re
+import subprocess
 from enum import Enum
 
 
@@ -172,7 +173,12 @@ class Connection(object):
             socket_path = os.environ.get("I3SOCK")
 
         if not socket_path:
-            raise Exception('could not get i3 socket path')
+            try:
+                socket_path = subprocess.check_output(
+                    ['i3', '--get-socketpath'],
+                    close_fds=True, universal_newlines=True)
+            except:
+                raise Exception('Failed to retrieve the i3 IPC socket path')
 
         self._pubsub = _PubSub(self)
         self.props = _PropsObject(self)
Retrieve the IPC socket path directly from i3

Call i3 with the `--get-socketpath' command-line option, which is
available since <I> release, to retrieve the i3 IPC socket path.

This restores backwards compatibility after the previous commit.