Browse Source

use gio open if available

j 1 year ago
parent
commit
ee586ee194
2 changed files with 13 additions and 3 deletions
  1. 5
    1
      ctl
  2. 8
    2
      oml/utils.py

+ 5
- 1
ctl View File

@@ -147,7 +147,11 @@ if [ "$1" == "open" ]; then
147 147
     if [ $SYSTEM == "Linux" ]; then
148 148
         if [ -e "$PID" ]; then
149 149
             if ps -p `cat "$PID"` > /dev/null; then
150
-                xdg-open "file://${BASE}/openmedialibrary/static/html/load.html"
150
+                if [ -e /usr/bin/gio ]; then
151
+                    gio open "file://${BASE}/openmedialibrary/static/html/load.html"
152
+                else
153
+                    xdg-open "file://${BASE}/openmedialibrary/static/html/load.html"
154
+                fi
151 155
             else
152 156
                 $PYTHON "${NAME}/oml/gtkstatus.py" $@
153 157
                 exit $?

+ 8
- 2
oml/utils.py View File

@@ -264,7 +264,10 @@ def open_file(path=None):
264 264
     if sys.platform == 'darwin':
265 265
         cmd += ['open', path]
266 266
     elif sys.platform.startswith('linux'):
267
-        cmd += ['xdg-open', path]
267
+        if os.path.exists('/usr/bin/gio'):
268
+            cmd += ['gio', 'open', path]
269
+        else:
270
+            cmd += ['xdg-open', path]
268 271
     elif sys.platform == 'win32':
269 272
         path = '\\'.join(path.split('/'))
270 273
         os.startfile(path)
@@ -285,7 +288,10 @@ def open_folder(folder=None, path=None):
285 288
             path = folder
286 289
         cmd += ['open', '-R', path]
287 290
     elif sys.platform.startswith('linux'):
288
-        cmd += ['xdg-open', folder]
291
+        if os.path.exists('/usr/bin/gio'):
292
+            cmd += ['gio', 'open', folder]
293
+        else:
294
+            cmd += ['xdg-open', folder]
289 295
     elif sys.platform == 'win32':
290 296
         path = '\\'.join(path.split('/'))
291 297
         cmd = 'explorer.exe /select,"%s"' % path