forked from PapirusDevelopmentTeam/papirus-icon-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new-symlink.sh
executable file
·122 lines (103 loc) · 2.18 KB
/
new-symlink.sh
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env bash
#
# This script creates new symlinks to existing icons
set -eo pipefail
readonly SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
readonly TARGET_DIR="$SCRIPT_DIR/Papirus"
usage() {
cat <<-EOF
This script creates new symlinks to existing icons.
Usage:
$0 context <icon name> <symlink name>...
available contexts:
[ac]tions
[ap]ps
[d]evices
[emb]lems
[emo]tes
[m]imetypes
[pa]nel
[pl]aces
[s]tatus
Examples:
$0 apps radiotray.svg radiotray-ng-on.svg
$0 panel radiotray_off.svg radiotray-ng-off-panel.svg
$0 panel radiotray_on.svg radiotray-ng-on-panel.svg
EOF
exit 2
}
_get_icon_name() {
local icon_name="$1"
case "$icon_name" in
*.svg|*.png|*.xpm)
echo "${icon_name%.*}"
return 0
;;
*)
echo "${icon_name}"
return 0
;;
esac
return 1
}
_get_context() {
local CONTEXT
local -a SIZES
case "$1" in
actions|ac*)
CONTEXT="actions"
SIZES=( '16x16' '22x22' '24x24' )
;;
apps|ap*)
CONTEXT="apps"
SIZES=( '16x16' '22x22' '24x24' '32x32' '48x48' '64x64' )
;;
devices|d*)
CONTEXT="devices"
SIZES=( '16x16' '22x22' '24x24' '32x32' '48x48' '64x64' )
;;
emblems|emb*)
CONTEXT="emblems"
SIZES=( '16x16' '22x22' '24x24' '32x32' '48x48' )
;;
emotes|emo*)
CONTEXT="emotes"
SIZES=( '16x16' '22x22' '24x24' '32x32' '48x48' )
;;
mimetypes|m*)
CONTEXT="mimetypes"
SIZES=( '16x16' '22x22' '24x24' '32x32' '48x48' '64x64' )
;;
panel|pa*)
CONTEXT="panel"
SIZES=( '16x16' '22x22' '24x24' )
;;
places|pl*)
CONTEXT="places"
SIZES=( '16x16' '22x22' '24x24' '32x32' '48x48' '64x64' )
;;
status|s*)
CONTEXT="status"
SIZES=( '22x22' '24x24' '32x32' '48x48' )
;;
*)
printf "illegal context -- '%s'\n" "$1" >&2
printf false
return 1
;;
esac
declare -p CONTEXT SIZES
}
readonly RAW_CONTEXT="$1"
readonly TARGET_ICON="$2"
declare -a ARGS=("${@:3}")
[ "${#ARGS[@]}" -gt 0 ] || usage
eval "$(_get_context "$RAW_CONTEXT")" || usage
for i in "${ARGS[@]}"; do
symlink_name="$(_get_icon_name "$i")"
for size in "${SIZES[@]}"; do
ln -sfv "$TARGET_ICON" \
"${TARGET_DIR}/${CONTEXT}/${symlink_name}@${size}.svg"
done
done
exit 0