typical call eq make_desktop_entry /usr/bin/xvst xVideoServiceThief xvst 'Qt;AudioVideo;Video' creates file with quite ugly name /usr/share/applications/_usr_bin_xvst-xvideoservicethief.desktop here is a simple fix that makes these names nicer (/usr/share/applications/xvst-xvideoservicethief.desktop for given example) Reproducible: Always Steps to Reproduce:
Created attachment 207889 [details, diff] makes .desktop file names more human-readable
Comment on attachment 207889 [details, diff] makes .desktop file names more human-readable you missed the entire point. the naming *guarantees* there will be no collisions. your change silently allows them. if you wanted to make a patch that used "nice" names by default but fell back to "full" names when a collision was detected, i'd be ok with that.
Created attachment 207956 [details] second try add fallback to "full" name if collision was detected
Created attachment 207960 [details, diff] third try (final?) in second try i forgot about commands in short form, my bad third try tested with: make_desktop_entry /bin/dummy somename make_desktop_entry /usr/bin/dummy somename make_desktop_entry dummy somename make_desktop_entry /usr/sbin/dummy somename make_desktop_entry /sbin/dummy somename got (as expected): /usr/share/applications/_bin_dummy-mytest.desktop /usr/share/applications/_sbin_dummy-mytest.desktop /usr/share/applications/_usr_bin_dummy-mytest.desktop /usr/share/applications/_usr_sbin_dummy-mytest.desktop /usr/share/applications/dummy-mytest.desktop
[[ ... ]] doesnt need quoting: [[ -e ${desktop} ]] but you do need quoting when accessing files like `cat "${desktop}"` using sed to basically do `basename` is overkill. use ${foo##*/}. that cat|grep|sed is wasteful. just do: sed -n '/Exec=/s:^Exec=::{p;q}' "${desktop}" then again, i dont think you need any of that Exec stuff. just do: - start with short name - if short name has collision, use long name (what we use today) - if long name has collision, abort with `die` i dont think there are any long name collisions today, and if there end up being ones, we can worry about the problem then.
This might cause some problems on Wayland. .desktop file name must be consistent with application internal name. I tested Plasma Wayland session and e.g. bitcoin-qt shows generic wayland icon in the taskbar (now .desktop file is named bitcoin-qt_%u-bitcoin-qt.desktop but should be org.bitcoin.bitcoin-qt.desktop)
From the Menu Entry Specification https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s07.html the Exec key doesn't need to have the full path. To write only the executable name is enough, the desktop will search in $PATH for it. So, it is just to use only the exec name, and to let the desktop do its job. Even a wm like fvwm do this very well.