forked from jaxwilko/gtk-theme-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sh
executable file
·120 lines (103 loc) · 3.15 KB
/
main.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
#!/usr/bin/env bash
usage() {
cat << NOTICE
OPTIONS
-h show this message
-v print verbose info
-f force asset recompilation
-c compile theme
-i install theme
-o install icons
-is automatically set the theme/icons active after install
-t [theme-name] select a theme for compilation or installation
-n [theme-name] create a new theme template file
-x [style-name] create a new theme style
-y [style-name] force compilation of theme using a specific style
-d [/path/to/dir] install theme to a specific directory
-p [/path/to/dir] install icons to a specific directory
NOTICE
}
say() {
[ "$VERBOSE" ] || [ "$2" ] && echo "==> $1"
}
PROJ_DIR=$(cd $(dirname "${0}") && pwd)
VERBOSE=""
FORCE=""
INSTALL=""
COMPILE=""
SET_THEME_ACTIVE=""
INSTALL_ICONS=""
THEME_DIR=""
ICON_DIR=""
NEW_THEME=""
NEW_THEME_STYLES=""
THEME_NAME="palenight"
FORCE_STYLE=""
while getopts hvficost:n:d:p:x:y: opts; do
case ${opts} in
h) usage && exit 0 ;;
v) VERBOSE=1 ;;
f) FORCE=1 ;;
i) INSTALL=1 ;;
c) COMPILE=1 ;;
s) SET_THEME_ACTIVE=1 ;;
o) INSTALL_ICONS=1 ;;
d) THEME_DIR=${OPTARG} ;;
p) ICON_DIR=${OPTARG} ;;
t) THEME_NAME=${OPTARG} ;;
n) NEW_THEME=${OPTARG} ;;
x) NEW_THEME_STYLES=${OPTARG} ;;
y) FORCE_STYLE=${OPTARG} ;;
*);;
esac
done
if [ ! -f "${PROJ_DIR}/themes/${THEME_NAME}.sh" ]; then
say "Could not find theme ${THEME_NAME}" "true"
exit 1
fi
if [ "$THEME_DIR" ] && [ ! -d "$THEME_DIR" ]; then
say "${THEME_DIR} does not exists, please create it then run this script again"
exit 1
fi
if [ "$NEW_THEME" ]; then
if [ -f "${PROJ_DIR}/themes/${NEW_THEME}.sh" ]; then
say "Theme ${NEW_THEME} already exists, please pick another name" "true"
exit 1
fi
cp "${PROJ_DIR}/themes/palenight.sh" "${PROJ_DIR}/themes/${NEW_THEME}.sh"
exit 0
fi
if [ "$NEW_THEME_STYLES" ]; then
if [ -d "${PROJ_DIR}/src/${NEW_THEME_STYLES}" ]; then
say "Theme styles ${NEW_THEME_STYLES} already exists, please pick another name" "true"
exit 1
fi
cp -r "${PROJ_DIR}/src/material" "${PROJ_DIR}/src/${NEW_THEME_STYLES}"
exit 0
fi
if [ "$COMPILE" ]; then
FLAG="-t ${THEME_NAME}"
[[ "$VERBOSE" ]] && FLAG="$FLAG -v"
[[ "$FORCE" ]] && FLAG="$FLAG -f"
[[ "$FORCE_STYLE" ]] && FLAG="$FLAG -y $FORCE_STYLE"
sh -c "${PROJ_DIR}/scripts/compile.sh $FLAG"
EXIT_CODE=$?
if [ ! $EXIT_CODE -eq 0 ]; then
say "Compile failed, exiting" "true"
exit 1
fi
fi
if [ "$INSTALL" ]; then
FLAG="-t ${THEME_NAME}"
[[ "$VERBOSE" ]] && FLAG="$FLAG -v"
[[ "$SET_THEME_ACTIVE" ]] && FLAG="$FLAG -s"
[[ "$INSTALL_ICONS" ]] && FLAG="$FLAG -o"
[[ "$THEME_DIR" ]] && FLAG="$FLAG -d ${THEME_DIR}"
[[ "$ICON_DIR" ]] && FLAG="$FLAG -p ${ICON_DIR}"
sh -c "${PROJ_DIR}/scripts/install.sh $FLAG"
EXIT_CODE=$?
if [ ! $EXIT_CODE -eq 0 ]; then
say "Install failed, exiting" "true"
exit 1
fi
fi