From 62f21113ef135c48b8e0bcf6b545cf7bee750841 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 26 Feb 2015 16:42:09 +0530 Subject: [PATCH] Fix %i substitution --- src/calibre/gui2/open_with.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/open_with.py b/src/calibre/gui2/open_with.py index aae33f21e7..2289aeddd3 100644 --- a/src/calibre/gui2/open_with.py +++ b/src/calibre/gui2/open_with.py @@ -291,7 +291,7 @@ else: path = os.path.abspath(path) rmap = { 'f':path, 'F':path, 'u':'file://'+path, 'U':'file://'+path, '%':'%', - 'i':entry.get('Icon', '%i'), 'c':entry.get('Name', ''), 'k':entry.get('desktop_file_path', ''), + 'c':entry.get('Name', ''), 'k':entry.get('desktop_file_path', ''), } def replace(match): char = match.group()[-1] @@ -299,6 +299,14 @@ else: return match.group() if repl is None else repl sub = re.compile(r'%[fFuUdDnNickvm%]').sub cmd = entry['Exec'] + try: + idx = cmd.index('%i') + except ValueError: + pass + else: + icon = entry.get('Icon') + repl = ['--icon', icon] if icon else [] + cmd[idx:idx+1] = repl return cmd[:1] + [sub(replace, x) for x in cmd[1:]] # }}}