-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extraneous double-quotes in dmenuExtended_aliases_lookup.json
#108
Comments
do you really require the double quotes in your desktop file? |
Thanks for the feedback :)
I can't comment on when I'll get time to fix this, but please feel free to take a look if you have time. |
Thanks for the quick reaction! For sure I could have a look at it but I'd like to have a hint where I should start to render things quicker. |
No problem. dmenu-extended/dmenu_extended/main.py Lines 864 to 874 in 16bde81
This part is responsible for extracting the command from |
I just have a small patch for now: diff --git a/dmenu_extended/main.py b/dmenu_extended/main.py
index 4fc41e5..10f564e 100755
--- a/dmenu_extended/main.py
+++ b/dmenu_extended/main.py
@@ -863,9 +863,18 @@ class dmenu(object):
terminal = None
for line in f.readlines():
if line[0:5] == 'Exec=' and command is None:
- command_tmp = line[5:-1].split()
command = ''
- space = ''
+ if line[5:-1].strip().startswith('"'):
+ from_ = line.find('"')
+ to = line[(from_ + 1):].find('"') + from_
+ if to == -1:
+ if self.debug:
+ print('Malformed Exec=')
+ continue
+ command = line[(from_ + 1):(to + 1)].replace(' ', '\\ ')
+ line = line[:5] + line[(to + 2):-1].strip()
+ command_tmp = line[5:-1].strip().split()
+ space = ' ' if command else ''
for piece in command_tmp:
if piece.find('%') == -1:
command += space + piece I don't know what to do with spaces within command (I replaced with |
I have another more elegant version with diff --git a/dmenu_extended/main.py b/dmenu_extended/main.py
index 4fc41e5..a4ff874 100755
--- a/dmenu_extended/main.py
+++ b/dmenu_extended/main.py
@@ -10,6 +10,7 @@ import codecs
import locale
import operator
import time
+import shlex
Help = """
Dmenu Extended command line options
@@ -863,15 +864,13 @@ class dmenu(object):
terminal = None
for line in f.readlines():
if line[0:5] == 'Exec=' and command is None:
- command_tmp = line[5:-1].split()
- command = ''
- space = ''
- for piece in command_tmp:
- if piece.find('%') == -1:
- command += space + piece
- space = ' '
- else:
- break
+ splits = shlex.split(line[5:])
+ has_percent = [s.startswith('%') for s in splits]
+ if any(has_percent):
+ index_percent = has_percent.index(True) + 1
+ else:
+ index_percent = len(splits)
+ command = ' '.join(s.replace(' ', '\\ ') for s in splits[0:index_percent])
elif line[0:5] == 'Name=' and name is None:
name = line[5:-1]
elif line[0:12] == 'GenericName=' and name_generic is None: |
@Fuseteam, just to be clear... by double quotes are you referring to This is an interesting problem. I think dmenu-extended should work with quoted I agreee though, things would be much simpler if the quotes were just removed from the .desktop file. |
@MarkHedleyJones ah yes i agree with you, i was just pointing out the double may not be neccesary in @galou's case |
I wrote the code that handles the double-quotes in the |
@galou sorry for the delay! |
By "handling spaces in the |
I made an error in my script: |
I have a .desktop file with
Exec="/home/gael/.cache/cesnet-owncloud/03-tmp/AppImage/PrusaSlicer-2.2.0+linux-x64-202003211856.AppImage" %U
which dmenu-extended converts toThese extra double-quotes prevent the menu entry to work. Removing them fixes the issue but this could happen that the double-quotes are required in the .desktop file.
Otherwise, I like dmenu-extended very much.
The text was updated successfully, but these errors were encountered: