summaryrefslogtreecommitdiff
path: root/.local/bin
diff options
context:
space:
mode:
authoradam <56338480+adastx@users.noreply.github.com>2022-10-30 19:39:55 +0100
committeradam <56338480+adastx@users.noreply.github.com>2022-10-30 19:39:55 +0100
commit13aa86e8d1080c24afdeac51fbb8235990c8a001 (patch)
treef401944da6d0db2b5c01af284945bee0c8ec3988 /.local/bin
parent82e2195e2e191b9885b32a888f013a945e066ab1 (diff)
polybar: major cleanup, wttr.in forecast
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/statusbar/sb-forecast48
-rwxr-xr-x.local/bin/statusbar/sb-packages (renamed from .local/bin/updates)2
2 files changed, 49 insertions, 1 deletions
diff --git a/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast
new file mode 100755
index 0000000..ec3e590
--- /dev/null
+++ b/.local/bin/statusbar/sb-forecast
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+LOCATION=$(<$XDG_CONFIG_HOME/forecast/location)
+
+main () {
+ case "$1" in
+ -b|--browser)
+ xdg-open https://wttr.in/$LOCATION
+ exit 0 ;;
+ esac
+
+ res=$(curl -sf wttr.in/$LOCATION?format="%x+%t") || exit 1
+ arr=($res)
+
+ icon=$(condition_icon ${arr[0]})
+ temp=$(temperature ${arr[1]})
+ echo $icon $temp
+}
+
+condition_icon () {
+ case "$1" in
+ 'mm') echo  ;;
+ '=') echo  ;;
+ '///') echo  ;;
+ '//') echo  ;;
+ '**') echo  ;;
+ '*/*') echo  ;;
+ '/') echo  ;;
+ '.') echo  ;;
+ 'x') echo  ;;
+ 'x/') echo  ;;
+ '*') echo  ;;
+ '*/') echo  ;;
+ 'm') echo  ;;
+ 'o') echo  ;;
+ '/!/') echo  ;;
+ '!/') echo  ;;
+ '*!*') echo  ;;
+ 'mmm') echo  ;;
+ *) echo ? ;;
+ esac
+}
+
+temperature () {
+ echo $1 | sed 's/+//' | sed 's/C//'
+}
+
+main "$@"
diff --git a/.local/bin/updates b/.local/bin/statusbar/sb-packages
index 7af054a..bbdefb1 100755
--- a/.local/bin/updates
+++ b/.local/bin/statusbar/sb-packages
@@ -18,5 +18,5 @@ aur_ignored=$($HOME/.local/bin/aurignored | wc -l)
updates=$((updates_arch + updates_aur - $aur_ignored))
if [ "$updates" -gt 0 ]; then
- echo " $updates"
+ echo " $updates"
fi