forked from themix-project/themix-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgnome_colors.sh
executable file
·117 lines (93 loc) · 2.24 KB
/
gnome_colors.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
#!/bin/bash
set -ueo pipefail
root="$(readlink -e $(dirname "$0"))"
print_usage() {
echo "
usage:
$0 [-o OUTPUT_THEME_NAME] PRESET_NAME_OR_PATH
examples:
$0 monovedek
$0 -o my-theme-name ./colors/retro/twg"
exit 1
}
darker_channel() {
value=${1}
light_delta=${2}
result=$(echo "ibase=16; ${value} - ${light_delta}" | bc)
if [[ ${result} -lt 0 ]] ; then
result=0
fi
if [[ ${result} -gt 255 ]] ; then
result=255
fi
echo "${result}"
}
darker() {
hexinput=$(echo $1 | tr '[:lower:]' '[:upper:]')
light_delta=${2-10}
a=`echo $hexinput | cut -c-2`
b=`echo $hexinput | cut -c3-4`
c=`echo $hexinput | cut -c5-6`
r=$(darker_channel ${a} ${light_delta})
g=$(darker_channel ${b} ${light_delta})
b=$(darker_channel ${c} ${light_delta})
printf '%02x%02x%02x\n' ${r} ${g} ${b}
}
while [[ $# > 0 ]]
do
case ${1} in
-h|--help)
print_usage
exit 0
;;
-o|--output)
OUTPUT_THEME_NAME="${2}"
shift
;;
*)
if [[ "${1}" == -* ]] || [[ ${THEME-} ]]; then
echo "unknown option ${1}"
print_usage
exit 2
fi
THEME="${1}"
;;
esac
shift
done
if [[ -z "${THEME:-}" ]] ; then
print_usage
fi
if [[ ${THEME} == */* ]] || [[ ${THEME} == *.* ]] ; then
source "$THEME"
THEME=$(basename ${THEME})
else
source "${root}/colors/$THEME"
fi
light_folder_base_fallback="$(darker ${SEL_BG} -10)"
medium_base_fallback="$(darker ${SEL_BG} 37)"
dark_stroke_fallback="$(darker ${SEL_BG} 50)"
light_folder_base="${ICONS_LIGHT_FOLDER-$light_folder_base_fallback}"
light_base="${ICONS_LIGHT-$SEL_BG}"
medium_base="${ICONS_MEDIUM-$medium_base_fallback}"
dark_stroke="${ICONS_DARK-$dark_stroke_fallback}"
OUTPUT_THEME_NAME="${OUTPUT_THEME_NAME-oomox-$THEME}"
output_dir="${HOME}/.icons/${OUTPUT_THEME_NAME}"
mkdir -p "${output_dir}" || true
tmp_dir="$(mktemp -d)"
function post_clean_up {
rm -r "${tmp_dir}" || true
}
trap post_clean_up EXIT SIGHUP SIGINT SIGTERM
cp -r "${root}/gnome-colors/"* "${tmp_dir}/"
cd "${tmp_dir}"
cat > ./themes/"${OUTPUT_THEME_NAME}" <<EOF
Name=${OUTPUT_THEME_NAME}
Distribution=gnome-colors
LightFolderBase=#${light_folder_base}
LightBase=#${light_base}
MediumBase=#${medium_base}
DarkStroke=#${dark_stroke}
EOF
make "${OUTPUT_THEME_NAME}"
cp -r ./"${OUTPUT_THEME_NAME}"/* "${output_dir}"/