From 20cf7fe8694cd1a3811c44129afea586e7b162ed Mon Sep 17 00:00:00 2001 From: EnumDev Date: Fri, 6 Sep 2024 18:49:50 +0300 Subject: [PATCH] Fixed error when attempting to use stormfetch without being connected to the internet and simplified fetch script --- config/fetch_script.sh | 51 +++++++++++++++++++++--------------------- utils.go | 2 +- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/config/fetch_script.sh b/config/fetch_script.sh index c0d8c29..2de4523 100644 --- a/config/fetch_script.sh +++ b/config/fetch_script.sh @@ -7,39 +7,38 @@ echo -e "${C3}Packages: ${C4}$(get_packages)" echo -e "${C3}Shell: ${C4}${USER_SHELL}" echo -e "${C3}Init: ${C4}${INIT_SYSTEM}" echo -e "${C3}Libc: ${C4}${LIBC}" -if [ ! -z "$CPU_MODEL" ]; then echo -e "${C3}CPU: ${C4}${CPU_MODEL} (${CPU_THREADS} threads)"; fi -for i in $(seq ${CONNECTED_GPUS}); do +[ -n "$CPU_MODEL" ] && echo -e "${C3}CPU: ${C4}${CPU_MODEL} (${CPU_THREADS} threads)" +for i in $(seq "${CONNECTED_GPUS}"); do gpu="GPU$i" echo -e "${C3}GPU: ${C4}${!gpu}" done -if [ ! -z "$MEM_TOTAL" ] && [ ! -z "$MEM_USED" ]; then echo -e "${C3}Memory: ${C4}${MEM_USED} MiB / ${MEM_TOTAL} MiB"; fi -for i in $(seq ${MOUNTED_PARTITIONS}); do - device="PARTITION${i}_DEVICE" - mountpoint="PARTITION${i}_MOUNTPOINT" - label="PARTITION${i}_LABEL" - type="PARTITION${i}_TYPE" - total="PARTITION${i}_TOTAL_SIZE" - used="PARTITION${i}_USED_SIZE" - if [ -z "${!type}" ]; then - if [ -z "${!label}" ]; then - echo -e "${C3}Partition ${!mountpoint}: ${C4}${!used}/${!total}" - else - echo -e "${C3}Partition ${!label}: ${C4}${!used}/${!total}" - fi +[ -n "$MEM_TOTAL" ] && [ -n "$MEM_USED" ] && echo -e "${C3}Memory: ${C4}${MEM_USED} MiB / ${MEM_TOTAL} MiB" +for i in $(seq "${MOUNTED_PARTITIONS}"); do + mountpoint="PARTITION${i}_MOUNTPOINT" + label="PARTITION${i}_LABEL" + type="PARTITION${i}_TYPE" + total="PARTITION${i}_TOTAL_SIZE" + used="PARTITION${i}_USED_SIZE" + if [ -z "${!type}" ]; then + if [ -z "${!label}" ]; then + echo -e "${C3}Partition ${!mountpoint}: ${C4}${!used}/${!total}" else - if [ -z "${!label}" ]; then - echo -e "${C3}Partition ${!mountpoint} (${!type}): ${C4}${!used}/${!total}" - else - echo -e "${C3}Partition ${!label} (${!type}): ${C4}${!used}/${!total}" - fi + echo -e "${C3}Partition ${!label}: ${C4}${!used}/${!total}" fi - done - echo -e "${C3}Local IPv4 Address: ${C4}${LOCAL_IPV4}" -if [ ! -z "$DISPLAY_PROTOCOL" ]; then + else + if [ -z "${!label}" ]; then + echo -e "${C3}Partition ${!mountpoint} (${!type}): ${C4}${!used}/${!total}" + else + echo -e "${C3}Partition ${!label} (${!type}): ${C4}${!used}/${!total}" + fi + fi +done +[ -n "$LOCAL_IPV4" ] && echo -e "${C3}Local IPv4 Address: ${C4}${LOCAL_IPV4}" +if [ -n "$DISPLAY_PROTOCOL" ]; then echo -e "${C3}Display Protocol: ${C4}${DISPLAY_PROTOCOL}" - for i in $(seq ${CONNECTED_MONITORS}); do + for i in $(seq "${CONNECTED_MONITORS}"); do monitor="MONITOR$i" echo -e "${C3}Screen $i: ${C4}${!monitor}" done fi -if [ ! -z "$DE_WM" ]; then echo -e "${C3}DE/WM: ${C4}${DE_WM}"; fi +[ -n "$DE_WM" ] && echo -e "${C3}DE/WM: ${C4}${DE_WM}" diff --git a/utils.go b/utils.go index 6f7203b..08bbeab 100644 --- a/utils.go +++ b/utils.go @@ -439,7 +439,7 @@ func GetLibc() string { func GetLocalIP() string { conn, err := net.Dial("udp", "8.8.8.8:80") if err != nil { - log.Fatal(err) + return "" } defer conn.Close()