From 767c0821ee0a1ad893efe9b5bc8e84f5629f8416 Mon Sep 17 00:00:00 2001 From: adam <56338480+adastx@users.noreply.github.com> Date: Fri, 4 Nov 2022 21:43:06 +0100 Subject: scripts: removed bashisms --- .local/bin/statusbar/sb-forecast | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to '.local/bin/statusbar') diff --git a/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast index c70f671..dd997c8 100755 --- a/.local/bin/statusbar/sb-forecast +++ b/.local/bin/statusbar/sb-forecast @@ -1,24 +1,25 @@ #!/bin/sh -LOCATION=$(<$XDG_CONFIG_HOME/forecast/location) +LOCATION=$(cat "$XDG_CONFIG_HOME/forecast/location") main () { case "$1" in -b|--browser) - xdg-open https://wttr.in/$LOCATION + xdg-open "https://wttr.in/$LOCATION" exit 0 ;; esac - res=$(curl -sf wttr.in/$LOCATION?format="%x+%t") || exit 1 - arr=($res) + res=$(curl -sf wttr.in/"$LOCATION"?format="%x+%t") || exit 1 - icon=$(condition_icon ${arr[0]}) - temp=$(temperature ${arr[1]}) - echo $icon $temp + icon=$(condition_icon "$res") + temp=$(temperature "$res") + echo "$icon" "$temp" } condition_icon () { - case "$1" in + icon=$(echo "$1" | cut -d\ -f1) + + case "$icon" in 'mm') echo  ;; '=') echo  ;; '///') echo  ;; @@ -42,7 +43,7 @@ condition_icon () { } temperature () { - echo $1 | sed 's/+//' | sed 's/C//' + echo "$1" | cut -d\ -f2 | sed 's/+//' | sed 's/C//' } main "$@" -- cgit v1.2.3-70-g09d2