modify menu

This commit is contained in:
Ing 2023-09-26 10:01:39 +08:00
parent b28256e7e4
commit e6fbd67b85
8 changed files with 931 additions and 972 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -215,6 +215,9 @@ msgstr "目前只支援 dts 格式的檔案,請準備並點選確認上傳。\
msgid "Custom dts file # Need rebuild"
msgstr "自訂 dts 檔案 # 需要重新編譯"
msgid "DMI: "
msgstr ""
msgid "DOWN"
msgstr "關閉"
@ -242,11 +245,8 @@ msgstr "删除 cmdline 參數"
msgid "Delete synoinfo item(s)"
msgstr "删除 Synoinfo 參數"
msgid "Deselect all modules"
msgstr "取消所有模組"
msgid "Deselecting all modules"
msgstr "取消所有模組"
msgid "Deselect all"
msgstr "取消所有"
msgid "Detected %s network cards, %s MACs were customized, the rest will use the original MACs."
msgstr "檢測到 %s 個網路卡, 自訂了 %s 個 MAC其他網路卡將使用本身 MAC。"
@ -527,6 +527,9 @@ msgstr "回復開機碟 # 測試"
msgid "Restore bootloader disk with success to %s!\\nReboot?"
msgstr "成功回復開機碟到 %s!\\n重新開機"
msgid "Retry"
msgstr "重試"
msgid "Save is complete."
msgstr "儲存完成。"
@ -539,8 +542,8 @@ msgstr "儲存中..."
msgid "Select addon to remove"
msgstr "選擇要删除的增益集"
msgid "Select all modules"
msgstr "選擇所有模組"
msgid "Select all"
msgstr "選擇所有"
msgid "Select an addon"
msgstr "選擇增益集"
@ -557,9 +560,6 @@ msgstr "選擇要載入的增益集"
msgid "Select synoinfo entry to remove"
msgstr "選擇要删除的參數"
msgid "Selecting all modules"
msgstr "全選所有模組"
msgid "Selecting loaded modules"
msgstr "選擇已識別的模組"
@ -587,8 +587,8 @@ msgstr "顯示 dsm logo:"
msgid "Show model inherent cmdline"
msgstr "顯示型號預設的 cmdline 參數"
msgid "Show selected modules"
msgstr "顯示已選取的模組"
msgid "Show/Select modules"
msgstr "顯/選擇模組"
msgid "Show synoinfo entries"
msgstr "顯示 Synoinfo 參數"
@ -776,9 +776,6 @@ msgstr "警告:\\n該作業不可逆請提前備份重要資料。是否繼
msgid "Welcome to %s"
msgstr "歡迎使用 %s"
msgid "Writing to user config"
msgstr "寫入使用者設置"
msgid "Writing..."
msgstr "寫入中..."

View File

@ -182,6 +182,7 @@ function productversMenu() {
--msgbox "$(TEXT "This version only support usb startup, Please select another version or switch the startup mode.")" 0 0
# return
fi
while true; do
# get online pat data
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Product Version")" \
--infobox "$(TEXT "Get pat data ..")" 0 0
@ -210,9 +211,14 @@ function productversMenu() {
MSG="$(TEXT "Successfully to get pat data,\nPlease confirm or modify as needed.")"
fi
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Product Version")" \
--extra-button --extra-label "$(TEXT "Retry")" \
--form "${MSG}" 10 110 2 "URL" 1 1 "${paturl}" 1 5 100 0 "MD5" 2 1 "${patsum}" 2 5 100 0 \
2>"${TMP_PATH}/resp"
[ $? -ne 0 ] && return
RET=$?
[ ${RET} -eq 0 ] && break # ok-button
[ ${RET} -eq 3 ] && continue # extra-button
return # 1 or 255 # cancel-button or ESC
done
paturl="$(cat "${TMP_PATH}/resp" | tail -n +1 | head -1)"
patsum="$(cat "${TMP_PATH}/resp" | tail -n +2 | head -1)"
[ -z "${paturl}" -o -z "${patsum}" ] && return
@ -403,7 +409,21 @@ function moduleMenu() {
PLATFORM="$(readModelKey "${MODEL}" "platform")"
KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")"
KPRE="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kpre")"
NEXT="c"
# loop menu
while true; do
dialog --backtitle "$(backtitle)" --colors \
--default-item ${NEXT} --menu "$(TEXT "Choose a option")" 0 0 0 \
c "$(TEXT "Show/Select modules")" \
l "$(TEXT "Select loaded modules")" \
o "$(TEXT "Upload a external module")" \
p "$(TEXT "Priority use of official drivers:") \Z4${ODP}\Zn" \
e "$(TEXT "Exit")" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && break
case "$(<${TMP_PATH}/resp)" in
c)
while true; do
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Modules")" \
--infobox "$(TEXT "Reading modules")" 0 0
ALLMODULES=$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}")
@ -412,29 +432,46 @@ function moduleMenu() {
while IFS=': ' read KEY VALUE; do
[ -n "${KEY}" ] && USERMODULES["${KEY}"]="${VALUE}"
done < <(readConfigMap "modules" "${USER_CONFIG_FILE}")
NEXT="s"
# loop menu
while true; do
dialog --backtitle "$(backtitle)" --colors \
--default-item ${NEXT} --menu "$(TEXT "Choose a option")" 0 0 0 \
s "$(TEXT "Show selected modules")" \
l "$(TEXT "Select loaded modules")" \
a "$(TEXT "Select all modules")" \
d "$(TEXT "Deselect all modules")" \
c "$(TEXT "Choose modules to include")" \
o "$(TEXT "Upload a external module")" \
p "$(TEXT "Priority use of official drivers:") \Z4${ODP}\Zn" \
e "$(TEXT "Exit")" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && break
case "$(<${TMP_PATH}/resp)" in
s)
ITEMS=""
for KEY in ${!USERMODULES[@]}; do
ITEMS+="${KEY}: ${USERMODULES[$KEY]}\n"
done
rm -f "${TMP_PATH}/opts"
while read ID DESC; do
arrayExistItem "${ID}" "${!USERMODULES[@]}" && ACT="on" || ACT="off"
echo "${ID} ${DESC} ${ACT}" >>"${TMP_PATH}/opts"
done <<<${ALLMODULES}
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Modules")" \
--msgbox "${ITEMS}" 0 0
--extra-button --extra-label "$(TEXT "Select all")" \
--help-button --help-label "$(TEXT "Deselect all")" \
--checklist "$(TEXT "Select modules to include")" 0 0 0 --file "${TMP_PATH}/opts" \
2>${TMP_PATH}/resp
RET=$?
case ${RET} in
0) # ok-button
resp=$(<${TMP_PATH}/resp)
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
for ID in ${resp}; do
writeConfigKey "modules.${ID}" "" "${USER_CONFIG_FILE}"
done
DIRTY=1
break
;;
3) # extra-button
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
while read ID DESC; do
writeConfigKey "modules.${ID}" "" "${USER_CONFIG_FILE}"
done <<<${ALLMODULES}
DIRTY=1
;;
2) # help-button
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
DIRTY=1
;;
1) # cancel-button
break
;;
255) # ESC
break
;;
esac
done
;;
l)
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Modules")" \
@ -444,61 +481,12 @@ function moduleMenu() {
KOLIST+="$(getdepends "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}" "${I}") ${I} "
done
KOLIST=($(echo ${KOLIST} | tr ' ' '\n' | sort -u))
unset USERMODULES
declare -A USERMODULES
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
for ID in ${KOLIST[@]}; do
USERMODULES["${ID}"]=""
writeConfigKey "modules.${ID}" "" "${USER_CONFIG_FILE}"
done
DIRTY=1
;;
a)
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Modules")" \
--infobox "$(TEXT "Selecting all modules")" 0 0
unset USERMODULES
declare -A USERMODULES
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
while read ID DESC; do
USERMODULES["${ID}"]=""
writeConfigKey "modules.${ID}" "" "${USER_CONFIG_FILE}"
done <<<${ALLMODULES}
DIRTY=1
;;
d)
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Modules")" \
--infobox "$(TEXT "Deselecting all modules")" 0 0
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
unset USERMODULES
declare -A USERMODULES
DIRTY=1
;;
c)
rm -f "${TMP_PATH}/opts"
while read ID DESC; do
arrayExistItem "${ID}" "${!USERMODULES[@]}" && ACT="on" || ACT="off"
echo "${ID} ${DESC} ${ACT}" >>"${TMP_PATH}/opts"
done <<<${ALLMODULES}
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Modules")" \
--checklist "$(TEXT "Select modules to include")" 0 0 0 --file "${TMP_PATH}/opts" \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && continue
resp=$(<${TMP_PATH}/resp)
[ -z "${resp}" ] && continue
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Modules")" \
--infobox "$(TEXT "Writing to user config")" 0 0
unset USERMODULES
declare -A USERMODULES
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
for ID in ${resp}; do
USERMODULES["${ID}"]=""
writeConfigKey "modules.${ID}" "" "${USER_CONFIG_FILE}"
done
DIRTY=1
;;
o)
MSG=""
MSG+="$(TEXT "This function is experimental and dangerous. If you don't know much, please exit.\n")"