Open Tomas-M opened 7 years ago
Could we also expand this issue to include the delimitation (using cut -d "=" -f 2
)?
I've noticed that this will mangle entries that rely on a command-line parameter than contain "=". This is the case with the Atom text editor that relies on Electron.
Exec=electron --app=/usr/lib/atom %F
will become electron --app
Instead I suggest that we simply behead the string using something like sed 's/Exec=//'
or cut -c 6-
Livvy
Thanks for bug report, fixed in newest version. Original issue remains so keeping open.
Thanks :+1: I'll have a think about this issue and get back with some ideas or a PR.
It's really only %k
, %i
, and %c
which makes sense for xlunch to replace as the others are for taking extra files. One thing I've noticed is that if you have a Exec line like xdg-su -c "my-program %U"
the last quotation mark will be removed and the command breaks. This is caused by the split by token on spaces and then replace strategy. A more robust option might be a regex which searches for space-percentage-UuFfDdNnickvm. Note that using these inside quotes is not technically supported by the spec but I think it would be nice to support it anyways.
Patches welcome :)
Working on it, patched the genconf to remove % through sed. But since xlunch splits the command and then runs execvp it really doesn't like quotations, complaining that arg"
isn't valid (so they get passed as two separate arguments..). The better option would probably be to treat the command as a black-box (handled by genconf and the user) and not try to do anything fancy with it in C.
There is a project https://github.com/enkore/j4-dmenu-desktop Maybe it would be good idea to adopt this instead of not-completed bash script? Also author show his time measurements to be around 0.01s, so this is fast enough to run it every time before xlunch to have up-to-date list of .desktop entries. Edit: I forgot to mention that dmenu also have a perl script to handle .desktop entries.
j4 doesn't support images though. The current method of conversion for svg images for example is to convert them into a cache directory. This would not work very well if you had to search for it every time. As of one of the later versions there is also an option to only generate an entry for a single file. This can be integrated with your package manager to allow new programs to be added to the list on the fly. To see this in action take a look at the AUR package for xlunch.
That said I would be interested in seeing a PR for this, so if you have the time feel free to implement it and we can compare the two versions.
What is the final solution of the initial topic here? Percent signs are simply erased? And xlunch now handles quoted arguments properly?
Currently % sign operations are currently ignored, and the new version doesn't do the splitting as before (only happens with the recur keyword) so quoted arguments works as you would expect.
If you take a look at the % flags most of them take extra information. The ones that don't should be pretty easy to expand with the bash script by simply reading some extra information and running a search and replace.
The .desktop files from which we autogenerate config file (genconf) can contain flags such as %u, %f, etc. It's described here what they mean: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html Currently xlunch ignores parameters starting with %, but that may be a problem. Better way will be to properly replace those flags.