generated from dracula/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·96 lines (81 loc) · 2.86 KB
/
install.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
#!/usr/bin/env bash
BE_QUIET=0
ROOT_DIR=$(dirname "$0")
COLOR_DIR="$ROOT_DIR/colors"
SCHEMA="/io/elementary/terminal/settings"
set_color_scheme() {
dconf write "$SCHEMA/palette" "'$(cat "$COLOR_DIR"/palette)'"
dconf write "$SCHEMA/foreground" "'$(cat "$COLOR_DIR"/foreground)'"
dconf write "$SCHEMA/background" "'$(cat "$COLOR_DIR"/background)'"
dconf write "$SCHEMA/prefer-dark-style" "true"
if [[ "$BE_QUIET" == '0' ]]; then
printf -- "\n"
printf -- "Dracula for Pantheon Terminal has been installed! :D\n"
fi
}
reset_color_scheme() {
dconf reset "$SCHEMA/palette"
dconf reset "$SCHEMA/foreground"
dconf reset "$SCHEMA/background"
dconf reset "$SCHEMA/prefer-dark-style"
if [[ "$BE_QUIET" == '0' ]]; then
printf -- "\n"
printf -- "Dracula for Pantheon Terminal has been uninstalled. :(\n"
fi
}
usage() {
printf -- "Usage: install.sh [-?hq] [--help] [--quiet] [--uninstall] \n\n"
printf -- "Options\n"
printf -- " -?, -h, --help Show this information.\n"
printf -- " -q, --quiet Suppress messages and assume YES on all prompts.\n"
printf -- " --uninstall Uninstalls the color scheme.\n\n"
}
install_confirm() {
local confirmation
printf -- "Pantheon Terminal does not support multiple profiles or more than one hard-\n"
printf -- "coded color scheme.\n\n"
printf -- "This install script will overwrite the default color palette for Pantheon\n"
printf -- "Terminal.\n\n"
printf -- "You may uninstall this color scheme at any time by executing this script\n"
printf -- "with the --uninstall flag.\n\n"
printf -- "Do you wish to proceed? (type YES to proceed): "
read -r confirmation
if [[ $(echo "$confirmation" | tr '[:lower:]' '[:upper:]') != YES ]]; then
printf -- "ERROR: Confirmation failed -- ABORTING!\n"
exit 1
fi
}
uninstall_confirm() {
local confirmation
printf -- "You have chosen to uninstall this color scheme and restore the default\n"
printf -- "palette in Pantheon Terminal.\n\n"
printf -- "You may reinstall this color scheme at any time by executing this script\n"
printf -- "again WITHOUT the --uninstall flag.\n\n"
printf -- "We're sad to see you go!\n\n"
printf -- "Do you wish to proceed? (type YES to proceed): "
read -r confirmation
if [[ $(echo "$confirmation" | tr '[:lower:]' '[:upper:]') != YES ]]; then
printf -- "ERROR: Confirmation failed -- ABORTING!\n"
exit 1
fi
}
while [ $# -gt 0 ]; do
case $1 in
-h | --help | '-?')
usage
exit 0
;;
--uninstall)
[[ "$BE_QUIET" == '0' ]] && uninstall_confirm
reset_color_scheme
exit 0
;;
-q | --quiet)
BE_QUIET=1
;;
esac
shift
done
[[ "$BE_QUIET" == '0' ]] && install_confirm
set_color_scheme
exit 0