diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2014-12-01 14:05:14 +0300 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2014-12-01 14:06:09 +0300 |
commit | b154e1baa1ba7a03dfe5b78bf5b71d6ccb881359 (patch) | |
tree | ea6df46057bfea0d936eaefcccd12f2ace8677d1 /shell_integration | |
parent | 119a9983a9f3bea36a62464f9374ad86b1966f63 (diff) |
Nautilus shell integration: Use fallback when XDG_RUNTIME_DIR is not defined
Same fallback as in Qt5
Task #2477
Diffstat (limited to 'shell_integration')
-rwxr-xr-x | shell_integration/nautilus/syncstate.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/shell_integration/nautilus/syncstate.py b/shell_integration/nautilus/syncstate.py index 93fec41bf..ca8b2b1f4 100755 --- a/shell_integration/nautilus/syncstate.py +++ b/shell_integration/nautilus/syncstate.py @@ -18,6 +18,19 @@ import socket from gi.repository import GObject, Nautilus + +def get_runtime_dir(): + """Returns the value of $XDG_RUNTIME_DIR, a directory path. + + If the value is not set, returns the same default as in Qt5 + """ + try: + return os.environ['XDG_RUNTIME_DIR'] + except KeyError: + fallback = '/tmp/runtime-' + os.environ['USER'] + return fallback + + class syncStateExtension(GObject.GObject, Nautilus.ColumnProvider, Nautilus.InfoProvider): nautilusVFSFile_table = {} @@ -38,7 +51,7 @@ class syncStateExtension(GObject.GObject, Nautilus.ColumnProvider, Nautilus.Info try: self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) postfix = "/"+self.appname+"/socket" - sock_file = os.environ["XDG_RUNTIME_DIR"]+postfix + sock_file = get_runtime_dir()+postfix print ("XXXX " + sock_file + " <=> " + postfix) if sock_file != postfix: try: |