From 0712be626bca653c41a3bf9411d3d6ef3605bec5 Mon Sep 17 00:00:00 2001 From: fatalerrors Date: Wed, 1 Apr 2026 15:53:44 +0200 Subject: [PATCH] wording and other minor improvments --- profile.d/info.sh | 50 +++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/profile.d/info.sh b/profile.d/info.sh index 9109e1f..cf9768a 100644 --- a/profile.d/info.sh +++ b/profile.d/info.sh @@ -39,11 +39,14 @@ # Usage: ver ver() { - local PARSED=$(getopt -o h --long help -n 'ver' -- "$@") + local PARSED + + PARSED=$(getopt -o h --long help -n 'ver' -- "$@") if [[ $? -ne 0 ]]; then disp E "Invalid options, use \"ver --help\" to display usage." return 1 fi + eval set -- "$PARSED" while true; do case "$1" in @@ -72,11 +75,13 @@ export -f ver # ------------------------------------------------------------------------------ -# Display weather of the given city (or default one) +# Display weather for the given city (or the default one) # Usage: meteo [city1 city2 ...] meteo() { - local PARSED=$(getopt -o h --long help -n 'meteo' -- "$@") + local PARSED + + PARSED=$(getopt -o h --long help -n 'meteo' -- "$@") if [[ $? -ne 0 ]]; then disp E "Invalid options, use \"meteo --help\" to display usage." return 1 @@ -85,7 +90,9 @@ meteo() while true; do case "$1" in -h|--help) - printf "meteo: Fetch weather data.\nUsage: meteo [city1 city2 ...]\n" + printf "meteo: Fetch weather data.\n" + printf "Usage: meteo [city1 city2 ...]\n" + printf "If no city is provided, the default city from configuration will be used.\n" return 0 ;; --) @@ -100,12 +107,13 @@ meteo() done local cities=("$@") + local city="" encoded="" [[ $# -eq 0 ]] && cities=("$DEFAULT_CITY") for city in "${cities[@]}"; do encoded=$(urlencode "$city") dwl "https://wttr.in/$encoded" || \ - disp E "Failed fetching datas for $city." + disp E "Failed to fetch weather data for $city." done } export -f meteo @@ -117,16 +125,20 @@ export -f meteo # Usage: showinfo showinfo() { - local PARSED=$(getopt -o h --long help -n 'showinfo' -- "$@") + local PARSED + + PARSED=$(getopt -o h --long help -n 'showinfo' -- "$@") if [[ $? -ne 0 ]]; then disp E "Invalid options, use \"showinfo --help\" to display usage." return 1 fi eval set -- "$PARSED" + while true; do case "$1" in -h|--help) - printf "showinfo: Display system information (hostname, kernel, uptime).\nUsage: showinfo\n" + printf "showinfo: Display system information (hostname, kernel, uptime and fetch output when available).\n" + printf "Usage: showinfo\n" return 0 ;; --) @@ -140,20 +152,20 @@ showinfo() esac done + local hostname_str + local figopt=() + hostname_str="$(hostname)" + printf "\n" if command -v figlet >/dev/null 2>&1; then - if [[ -s /usr/share/figlet/ansi_shadow.flf ]]; then - local figopt="-f ansi_shadow" - fi - if [[ -n $figopt ]]; then - figlet -k $figopt $(hostname) - else - figlet $(hostname) - fi + [[ -s /usr/share/figlet/ansi_shadow.flf ]] && \ + figopt=(-f ansi_shadow) + figlet -k "${figopt[@]}" "$hostname_str" else - hostname -f + printf "%s\n" "$hostname_str" fi - echo "" + + printf "\n" if command -v neofetch >/dev/null 2>&1; then neofetch elif command -v fastfetch >/dev/null 2>&1; then @@ -163,11 +175,11 @@ showinfo() if [[ -s /etc/os-release ]]; then # shellcheck disable=SC1091 . /etc/os-release - printf "$NAME $VERSION\n" + printf "%s %s\n" "$NAME" "$VERSION" else cat /proc/version fi - printf "Uptime: $(uptime -p)\n" + printf "Uptime: %s\n" "$(uptime -p)" ) fi }