summaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/sb-forecast
diff options
context:
space:
mode:
authoradam <56338480+adastx@users.noreply.github.com>2022-11-04 21:43:06 +0100
committeradam <56338480+adastx@users.noreply.github.com>2022-11-04 21:43:06 +0100
commit767c0821ee0a1ad893efe9b5bc8e84f5629f8416 (patch)
treeb3b8b619dd99f020f41f54fa1186421901d78fd0 /.local/bin/statusbar/sb-forecast
parentbb2359c30f8ade19fc7e60ab825d2744d0c04fcf (diff)
scripts: removed bashisms
Diffstat (limited to '.local/bin/statusbar/sb-forecast')
-rwxr-xr-x.local/bin/statusbar/sb-forecast19
1 files changed, 10 insertions, 9 deletions
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 "$@"