2017-02-18 07:57:14 -05:00
|
|
|
#!/usr/bin/env bash
|
2017-09-20 08:51:58 -04:00
|
|
|
#
|
2017-07-21 04:18:47 -04:00
|
|
|
# This script creates new symlinks to existing icons
|
2017-02-18 07:57:14 -05:00
|
|
|
|
|
|
|
set -eo pipefail
|
|
|
|
|
2018-09-03 02:37:39 -04:00
|
|
|
readonly SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
2017-10-04 12:13:12 -04:00
|
|
|
readonly TARGET_DIR="$SCRIPT_DIR/Papirus"
|
2017-02-18 07:57:14 -05:00
|
|
|
|
|
|
|
usage() {
|
|
|
|
cat <<-EOF
|
|
|
|
This script creates new symlinks to existing icons.
|
|
|
|
|
|
|
|
Usage:
|
2017-09-24 15:40:23 -04:00
|
|
|
$0 context <icon name> <symlink name>...
|
2017-02-18 07:57:14 -05:00
|
|
|
|
2017-07-21 04:18:47 -04:00
|
|
|
available contexts:
|
2017-02-18 07:57:14 -05:00
|
|
|
[ac]tions
|
|
|
|
[ap]ps
|
|
|
|
[d]evices
|
2018-09-18 13:54:48 -04:00
|
|
|
[emb]lems
|
|
|
|
[emo]tes
|
2017-02-18 07:57:14 -05:00
|
|
|
[m]imetypes
|
|
|
|
[pa]nel
|
|
|
|
[pl]aces
|
|
|
|
[s]tatus
|
|
|
|
|
|
|
|
Examples:
|
2017-09-24 15:40:23 -04:00
|
|
|
$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
|
2017-02-18 07:57:14 -05:00
|
|
|
EOF
|
|
|
|
|
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
|
2017-09-24 15:40:23 -04:00
|
|
|
_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' )
|
|
|
|
;;
|
2018-09-18 13:54:48 -04:00
|
|
|
emblems|emb*)
|
2017-09-24 15:40:23 -04:00
|
|
|
CONTEXT="emblems"
|
|
|
|
SIZES=( '16x16' '22x22' '24x24' '32x32' '48x48' )
|
|
|
|
;;
|
2018-09-18 13:54:48 -04:00
|
|
|
emotes|emo*)
|
2018-09-18 10:08:10 -04:00
|
|
|
CONTEXT="emotes"
|
|
|
|
SIZES=( '16x16' '22x22' '24x24' '32x32' '48x48' )
|
|
|
|
;;
|
2017-09-24 15:40:23 -04:00
|
|
|
mimetypes|m*)
|
|
|
|
CONTEXT="mimetypes"
|
|
|
|
SIZES=( '16x16' '22x22' '24x24' '32x32' '48x48' '64x64' )
|
|
|
|
;;
|
|
|
|
panel|pa*)
|
|
|
|
CONTEXT="panel"
|
2017-10-02 03:53:22 -04:00
|
|
|
SIZES=( '16x16' '22x22' '24x24' )
|
2017-09-24 15:40:23 -04:00
|
|
|
;;
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-09-27 13:04:07 -04:00
|
|
|
readonly RAW_CONTEXT="$1"
|
|
|
|
readonly TARGET_ICON="$2"
|
|
|
|
declare -a ARGS=("${@:3}")
|
2017-09-24 15:40:23 -04:00
|
|
|
|
2017-10-04 12:13:12 -04:00
|
|
|
[ "${#ARGS[@]}" -gt 0 ] || usage
|
2017-09-24 15:40:23 -04:00
|
|
|
|
|
|
|
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
|