-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·137 lines (105 loc) · 3.66 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·137 lines (105 loc) · 3.66 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/bash
readonly BASE_DIR="$( readlink -f "$(dirname "$0")" )"
readonly FIXES_DIR="$BASE_DIR/fixes"
readonly REQUIRED_FEATURES_DIR="$BASE_DIR/required-features"
readonly OPTIONAL_FEATURES_DIR="$BASE_DIR/optional-features"
readonly SCRIPTS_DIR="$BASE_DIR/scripts"
################################################################################
# Display menu to user with title and options
# Globals:
# None
# Arguments:
# title, Title of menu
# <option name> <option_function>... Unlimited pairs of option names and
# functions to call when corresponding option is selected. Each option name
# and function are separate arguments, but must be provided in pairs.
# Outputs:
# Prompts user with list of options
# Returns:
# 0 if successful
################################################################################
function show_menu() {
local option num_of_options i name name_idx func_idx
title="-----$1-----"
shift
option=0
num_of_options=$(( $# / 2 ))
while true; do
i=1
echo "$title"
while (( i <= num_of_options )); do
name_idx="$(( i * 2 - 1 ))"
name="${!name_idx}"
echo "$i. $name"
i=$(( i + 1 ))
done
read -rp "Option: " option
if echo "$option" | grep -q -P "^[0-9]+$"; then
if (( option > num_of_options )); then
continue
fi
else
continue
fi
func_idx=$(( option * 2 ))
"${!func_idx}"
done
}
function main_menu() {
show_menu "Main Menu" \
"Install LadOS" "install_lados" \
"Install Required Features" "required_features_menu" \
"Install Optional Features" "optional_features_menu" \
"Fixes" "fixes_menu" \
"Scripts" "scripts_menu" \
"Exit" "exit"
}
function install_lados() {
$BASE_DIR/install/install.sh
}
function fixes_menu() {
show_menu "Fixes" \
"Fix oh-my-zsh" "sh $FIXES_DIR/fix-oh-my-zsh.sh" \
"Fix suspend" "sh $FIXES_DIR/fix-suspend.sh" \
"Fix time" "sh $FIXES_DIR/fix-time.sh" \
"Fix DNS on ArchLinuxArm" "sh $FIXES_DIR/fix-rpi0w-archlinuxarm-dns.sh" \
"Go Back" "return"
}
function scripts_menu() {
show_menu "Scripts" \
"Setup DS4" "sh $SCRIPTS_DIR/setup-ds4.sh" \
"Change Dunst Theme" "sh $SCRIPTS_DIR/dunst_xr_theme_changer.sh" \
"Colors_esc" "sh $SCRIPTS_DIR/colors_esc.sh" \
"Go Back" "return"
}
function required_features_menu() {
local features menu_cmd feature feature_path name desc
mapfile -t features < <(ls "$REQUIRED_FEATURES_DIR")
menu_cmd=()
# Build menu command with option names and path to install script
for feature in "${features[@]}"; do
feature_path="$REQUIRED_FEATURES_DIR/$feature/feature.sh"
name="$("$feature_path" name)"
desc="$("$feature_path" desc)"
menu_cmd=("${menu_cmd[@]}" "$name" "$feature_path full")
done
show_menu "Install Required Features" \
"${menu_cmd[@]}" \
"Go Back" "return"
}
function optional_features_menu() {
local features menu_cmd feature feature_path name desc
mapfile -t features < <(ls "$OPTIONAL_FEATURES_DIR")
menu_cmd=()
# Build menu command with option names and path to install script
for feature in "${features[@]}"; do
feature_path="$OPTIONAL_FEATURES_DIR/$feature/feature.sh"
name="$("$feature_path" name)"
desc="$("$feature_path" desc)"
menu_cmd=("${menu_cmd[@]}" "$name" "$feature_path full")
done
show_menu "Install Optional Features" \
"${menu_cmd[@]}" \
"Go Back" "return"
}
main_menu