sane-open: more robust auto-application/file detection

This commit is contained in:
2024-05-05 05:07:32 +00:00
parent 8c04023eba
commit c0a7b831cd

View File

@@ -17,7 +17,7 @@ usage() {
log() {
if [ -n "$SANE_OPEN_DEBUG" ]; then
printf 'sane-open: %s\n' $@ >&2
printf 'sane-open: %s\n' "$1" >&2
fi
}
@@ -147,9 +147,15 @@ if [ -z "$resourceType" ]; then
if [ -e "$HOME/.local/share/applications/$resource" ]; then
log "detected resourceType=application"
resourceType=application
else
elif [ -e "$resource" ]; then
log "detected resourceType=file"
resourceType=file
elif [[ "$resource" == *.desktop ]]; then
log "detected resourceType=application (warning: '$resource' is not visible on disk)"
resourceType=application
else
log "detected resourceType=file (warning: '$resource' is not visible on disk)"
resourceType=file
fi
fi