Compare commits
No commits in common. "0eb7823f56aa73a6b8ef897b0bcd774274ef53a0" and "25e7e3f454ac414cb34aab0c5a2cf5e5b9e21058" have entirely different histories.
0eb7823f56
...
25e7e3f454
@ -6,12 +6,13 @@
|
|||||||
##
|
##
|
||||||
# Configuration
|
# Configuration
|
||||||
|
|
||||||
|
name=$(basename "$(readlink -f "$0")")
|
||||||
IFS=":"
|
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}
|
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
|
help=false
|
||||||
verbose=false
|
verbose=false
|
||||||
show_directives_regex=".*"
|
show_directives_regex=.*
|
||||||
search_directives_regex="(Name|Exec)"
|
search_directives_regex="(Name|Exec)"
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -161,40 +162,26 @@ parse_options() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ "${#search_directives[@]}" -gt 0 ]] && search_directives_regex="($(join "|" "${search_directives[@]}"))"
|
[[ "${#search_directives[@]}" -gt 0 ]] && search_directives_regex="($(join "|" ${search_directives[@]}))"
|
||||||
[[ "${#show_directives[@]}" -gt 0 ]] && show_directives_regex="^($(join "|" "${show_directives[@]}"))="
|
[[ "${#show_directives[@]}" -gt 0 ]] && show_directives_regex="^($(join "|" ${show_directives[@]}))="
|
||||||
[[ "${#search[@]}" -gt 0 ]] && search_regex="^$search_directives_regex=.*($(join "|" "${search[@]}"))"
|
[[ "${#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[*]}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
##
|
##
|
||||||
# Main Program
|
# Main Program
|
||||||
|
|
||||||
parse_options "$@"
|
parse_options $@
|
||||||
|
|
||||||
"$help" && { usage ; exit 0 ; }
|
"$help" && { usage ; exit 0 ; }
|
||||||
|
|
||||||
found=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")
|
data_dir=$(realpath --canonicalize-missing --no-symlinks "$_data_dir")
|
||||||
applications="$data_dir/applications"
|
applications="$data_dir/applications"
|
||||||
|
|
||||||
[[ -d $applications ]] && for desktop in "$applications"/*.desktop ; do
|
[[ -d $applications ]] && for desktop in "$applications"/*.desktop ; do
|
||||||
grep -Eiqs "$search_regex" "$desktop" && {
|
grep -Eiq "$search_regex" "$desktop" && {
|
||||||
(( found++ ))
|
(( found++ ))
|
||||||
if "$verbose" ; then
|
if "$verbose" ; then
|
||||||
echo "# $desktop"
|
echo "# $desktop"
|
||||||
|
Loading…
Reference in New Issue
Block a user