Fix find_desktop_file and minor bug fixes.
find_desktop_file_by was previously using
[[ -z "$HOME/.local/share/applications" ]] &&
This is incorrect, the string in this test will never be empty instead what we want to do is check if the directory does not exist this can be achived with
[[ ! -d "$HOME/..." ]] &&
https://www.shellcheck.net/wiki/SC2157
protocol is changed from =file to "file" to make it obvious we are setting it to the string not the program https://www.shellcheck.net/wiki/SC2209
- if [[ -n "$(echo "$w" | grep '^$')" ]]; then + if echo "$w" | grep -q '^$';then
we change from [[ -n ]] to grep -q to quit early if we don't match and to make it a bit cleaner.
- program="$(echo "$w" | sed 's/^$//')" - app[$i] + program="${w#$}" + app[i] https://www.shellcheck.net/wiki/SC2001 https://www.shellcheck.net/wiki/SC2004
A little less overhead without an external call, also a bit easier to read
Remaining changes were simply explictly passing in a function argument and double quoting to prevent globbing.
[!NOTE] Shellcheck still complains about https://www.shellcheck.net/wiki/SC2207
Fixing that is probably a good idea.