cleaned up does-desktop-entry-exist
This commit is contained in:
parent
e3e9c20356
commit
2ce0cfb146
1 changed files with 14 additions and 5 deletions
|
@ -162,16 +162,25 @@ function flameshot-screenshot {
|
||||||
|
|
||||||
function does-desktop-entry-exist {
|
function does-desktop-entry-exist {
|
||||||
readonly desktopentry=${1:?Please provide the full filename of the desktop entry.}
|
readonly desktopentry=${1:?Please provide the full filename of the desktop entry.}
|
||||||
local entrypaths=(
|
|
||||||
"/usr/share/applications"
|
if (( $+commands[qtpaths] )); then
|
||||||
"/usr/local/share/applications"
|
local entrypaths=("${(@f)$(qtpaths --paths ApplicationsLocation | tr ':' '\n')}")
|
||||||
"$HOME/.local/share/applications"
|
else
|
||||||
)
|
echo "qtpaths is not installed, falling back to XDG_DATA_DIRS."
|
||||||
|
local entrypaths=(${(f)"$(echo $XDG_DATA_DIRS | tr ':' '\n' | sed 's|$|/applications|')"})
|
||||||
|
entrypaths+=("$HOME/.local/share/applications")
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Checking the following paths for $desktopentry:\n${(F)entrypaths}\n--------------------"
|
||||||
|
|
||||||
for entrypath in "${entrypaths[@]}"; do
|
for entrypath in "${entrypaths[@]}"; do
|
||||||
|
echo "Checking for $entrypath/$desktopentry"
|
||||||
if [[ -f "$entrypath/$desktopentry" ]]; then
|
if [[ -f "$entrypath/$desktopentry" ]]; then
|
||||||
|
echo "$desktopentry found in $entrypath"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Desktop entry $desktopentry does not exist."
|
echo "Desktop entry $desktopentry does not exist."
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue