-
Notifications
You must be signed in to change notification settings - Fork 4
/
eos-FindAppIcon
65 lines (54 loc) · 1.54 KB
/
eos-FindAppIcon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
#FindAppIconKDE() {
# local app="$1"
# local sz
# local path
#
# for sz in "48" "48x48" ; do
# path="$(/usr/bin/find /usr/share/icons -name "$app".\* | /usr/bin/grep -m1 /${sz}/)"
# test -n "$path" && {
# echo "$path"
# return
# }
# done
# #echo "Sorry, icon path not found for app '$app'." >&2
#}
FindDesktopIcon() {
local app="$1"
local path
local dir=/usr/share/applications
if [ -r $dir/"$app".desktop ] ; then
path="$(grep -m1 "^Icon=" $dir/"$app".desktop | cut -d '=' -f 2)"
if [ -n "$path" ] ; then
echo "$path"
return 0
fi
fi
return 1
}
FindAppIcon() {
source /etc/eos-script-lib-yad.conf || return 1
local progname="$(/usr/bin/basename "$0")"
local app="$1"
local sz
local path paths
local set
local icon_sets=()
for set in "${EOS_ICON_SETS_PREFERENCE[@]}" ; do
icon_sets+=("${set##*/}")
done
FindDesktopIcon "$app" && return
for set in "${icon_sets[@]}" ; do
paths="$(find "/usr/share/icons/$set" -name "$app".\*)"
path="$(echo "$paths" | grep -m1 "/scalable/")"
[ -z "$path" ] && path="$(echo "$paths" | sort -r | head -n1)"
[ -z "$path" ] && path=$(yad-tools -i "$app" 2>/dev/null)
if [ -n "$path" ] ; then
echo "$path"
return
fi
done
local log="/tmp/${progname}-issues-$EUID.log"
echo "$progname: sorry, icon path not found for app '$app'." >> "$log"
}
FindAppIcon "$@"