Skip to content

Commit

Permalink
Added the from_i3 path source, which calls 'i3 --get-socketpath' as m…
Browse files Browse the repository at this point in the history
…entioned in the IPC docs.
  • Loading branch information
whitelynx committed Mar 20, 2012
1 parent 6012d02 commit 09193bd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion i3ipc/i3path.py
@@ -1,4 +1,5 @@
import os
import subprocess


I3_SOCK_ENV_VAR = 'I3SOCK'
Expand All @@ -9,7 +10,7 @@ def get():
"""Get the I3 socket path, trying several strategies.
"""
for source in (from_env, from_x11, from_xdg, default):
for source in (from_env, from_x11, from_xdg, from_i3, default):
try:
path = source()
if path is not None and os.path.exists(path):
Expand Down Expand Up @@ -100,6 +101,13 @@ def from_xdg():
return path


def from_i3():
try:
return subprocess.check_output(["i3", "--get-socketpath"])
except subprocess.CalledProcessError:
return


def default():
"""Get the default I3 socket path.
Expand Down

0 comments on commit 09193bd

Please sign in to comment.