Compare commits

..

No commits in common. "0eb7823f56aa73a6b8ef897b0bcd774274ef53a0" and "25e7e3f454ac414cb34aab0c5a2cf5e5b9e21058" have entirely different histories.

View File

@ -6,12 +6,13 @@
##
# Configuration
name=$(basename "$(readlink -f "$0")")
IFS=":"
xdg_data_dirs=${XDG_DATA_DIRS:-/usr/share/gnome:$HOME/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share}
search_regex=".*"
search_regex=.*
help=false
verbose=false
show_directives_regex=".*"
show_directives_regex=.*
search_directives_regex="(Name|Exec)"
##
@ -161,40 +162,26 @@ parse_options() {
esac
done
[[ "${#search_directives[@]}" -gt 0 ]] && search_directives_regex="($(join "|" "${search_directives[@]}"))"
[[ "${#show_directives[@]}" -gt 0 ]] && show_directives_regex="^($(join "|" "${show_directives[@]}"))="
[[ "${#search[@]}" -gt 0 ]] && search_regex="^$search_directives_regex=.*($(join "|" "${search[@]}"))"
}
valid_data_dirs() {
local dirs=$1
local IFS=:
local result=()
for dir in $dirs ; do
if [[ -d $dir/applications ]] && [[ -r $dir/applications ]] ; then
result+=( "$dir" )
fi
done
echo "${result[*]}"
[[ "${#search_directives[@]}" -gt 0 ]] && search_directives_regex="($(join "|" ${search_directives[@]}))"
[[ "${#show_directives[@]}" -gt 0 ]] && show_directives_regex="^($(join "|" ${show_directives[@]}))="
[[ "${#search[@]}" -gt 0 ]] && search_regex="^$search_directives_regex=.*($(join "|" ${search[@]}))"
}
##
# Main Program
parse_options "$@"
parse_options $@
"$help" && { usage ; exit 0 ; }
found=0
for _data_dir in $(valid_data_dirs "$xdg_data_dirs") ; do
for _data_dir in $xdg_data_dirs ; do
data_dir=$(realpath --canonicalize-missing --no-symlinks "$_data_dir")
applications="$data_dir/applications"
[[ -d $applications ]] && for desktop in "$applications"/*.desktop ; do
grep -Eiqs "$search_regex" "$desktop" && {
grep -Eiq "$search_regex" "$desktop" && {
(( found++ ))
if "$verbose" ; then
echo "# $desktop"