-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathlauncher.sh
executable file
·46 lines (40 loc) · 1.12 KB
/
launcher.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
#!/usr/bin/env bash
# params: <选择框提示语> <初始选中的项目> <项目1> <项目2> …
# return: 选择的项目的下标
function select_from_array() {
local TITLE OPTS INDEX ITEM
TITLE=$1
shift
local DEFAULT_ITEM=$1
shift
OPTS=()
INDEX=0
for ITEM in "$@" ; do
(( INDEX++ )) || true
OPTS+=("$INDEX" "$ITEM")
done
ITEM=$(dialog --stdout --default-item "$DEFAULT_ITEM" --menu "$TITLE" 0 0 0 "${OPTS[@]}")
echo "$((${ITEM:-0} - 1))"
}
SELECTED_INDEX=$(select_from_array "欢迎使用Fcitx5优化脚本,请选择运行方式" 1 \
"在线运行最新版本 - 使用推荐配置" \
"在线运行最新版本 - 自选配置" \
"运行已下载的版本 - 使用推荐配置" \
"运行已下载的版本 - 自选配置" \
)
clear
CURRENT_DIR=$(cd "$(dirname "$0")" || exit; pwd)
case $SELECTED_INDEX in
0)
curl -sSL https://fcitx5.debuggerx.com/fcitx5_customizer.sh | bash -s -- recommend
;;
1)
bash -c "$(curl -fsSL https://fcitx5.debuggerx.com/fcitx5_customizer.sh)"
;;
2)
bash "$CURRENT_DIR"/fcitx5_customizer.sh recommend
;;
3)
bash "$CURRENT_DIR"/fcitx5_customizer.sh
;;
esac