arc: rewrite more api related

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-10-31 02:03:36 +01:00
parent 7a5932fea5
commit 99bb6937eb
2 changed files with 6 additions and 4 deletions

View File

@ -60,7 +60,7 @@ BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
###############################################################################
# Mounts backtitle dynamically
function backtitle() {
BACKTITLE="${ARC_TITLE} | "
BACKTITLE="${ARC_TITLE}$([ -n "${NEWTAG}" ] && [ ${ARC_VERSION//[!0-9]/} -lt ${NEWTAG//[!0-9]/} ] && echo " > ${NEWTAG}") | "
BACKTITLE+="${MODEL:-(Model)} | "
BACKTITLE+="${PRODUCTVER:-(Version)} | "
BACKTITLE+="${IPCON:-(IP)} | "

View File

@ -496,14 +496,16 @@ function livepatch() {
function onlineCheck() {
LAYOUT="$(readConfigKey "layout" "${USER_CONFIG_FILE}")"
KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")"
REGION="$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f1)"
TIMEZONE="$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f2)"
[ -z "${KEYMAP}" ] && KEYMAP="$(curl -m 5 -v "http://ip-api.com/line?fields=countryCode" 2>/dev/null | tr '[:upper:]' '[:lower:]')"
REGION="$(curl -m 10 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f1)"
TIMEZONE="$(curl -m 10 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f2)"
[ -z "${KEYMAP}" ] && KEYMAP="$(curl -m 10 -v "http://ip-api.com/line?fields=countryCode" 2>/dev/null | tr '[:upper:]' '[:lower:]')"
writeConfigKey "time.region" "${REGION}" "${USER_CONFIG_FILE}"
writeConfigKey "time.timezone" "${TIMEZONE}" "${USER_CONFIG_FILE}"
if [ -n "${REGION}" ] && [ -n "${TIMEZONE}" ]; then
ln -sf "/usr/share/zoneinfo/${REGION}/${TIMEZONE}" /etc/localtime
writeConfigKey "arc.offline" "false" "${USER_CONFIG_FILE}"
[ $(echo "${ARC_VERSION}" | grep "dev" | wc -l) -eq 0 ] && NEWTAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)"
[ $(echo "${ARC_VERSION}" | grep "dev" | wc -l) -gt 0 ] && NEWTAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | grep "dev" | sort -rV | head -1)"
else
writeConfigKey "arc.offline" "true" "${USER_CONFIG_FILE}"
fi