diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index bcfc88d239..fc9c542b92 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -401,8 +401,9 @@ def communicate(opts, args): shutdown_other(t) else: if len(args) > 1: - args[1] = os.path.abspath(args[1]) - t.conn.send('launched:'+repr(args)) + args[1:] = [os.path.abspath(x) if os.path.exists(x) else x for x in args[1:]] + import json + t.conn.send('launched:'+json.dumps(args)) t.conn.close() raise SystemExit(0) diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index e2f02eb578..43740876ea 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -520,11 +520,12 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ except Empty: return if msg.startswith('launched:'): - argv = eval(msg[len('launched:'):]) - if len(argv) > 1: - path = os.path.abspath(argv[1]) - if os.access(path, os.R_OK): - self.iactions['Add Books'].add_filesystem_book(path) + import json + argv = json.loads(msg[len('launched:'):]) + if isinstance(argv, (list, tuple)) and len(argv) > 1: + files = [os.path.abspath(p) for p in argv[1:] if not os.path.isdir(p) and os.access(p, os.R_OK)] + if files: + self.iactions['Add Books'].add_filesystem_book(files) self.setWindowState(self.windowState() & ~Qt.WindowMinimized|Qt.WindowActive) self.show_windows() diff --git a/src/calibre/linux.py b/src/calibre/linux.py index 41af312c41..98d68816f3 100644 --- a/src/calibre/linux.py +++ b/src/calibre/linux.py @@ -833,7 +833,7 @@ Name=LRF Viewer GenericName=Viewer for LRF files Comment=Viewer for LRF files (SONY ebook format files) TryExec=lrfviewer -Exec=lrfviewer %F +Exec=lrfviewer %f Icon=calibre-viewer MimeType=application/x-sony-bbeb; Categories=Graphics;Viewer; @@ -847,7 +847,7 @@ Name=E-book Viewer GenericName=Viewer for E-books Comment=Viewer for E-books in all the major formats TryExec=ebook-viewer -Exec=ebook-viewer %F +Exec=ebook-viewer %f Icon=calibre-viewer Categories=Graphics;Viewer; ''' @@ -857,7 +857,7 @@ GUI = '''\ [Desktop Entry] Version=1.0 Type=Application -Name=calibre +Name=calibre %F GenericName=E-book library management Comment=E-book library management: Convert, view, share, catalogue all your e-books TryExec=calibre