From 13aa86e8d1080c24afdeac51fbb8235990c8a001 Mon Sep 17 00:00:00 2001 From: adam <56338480+adastx@users.noreply.github.com> Date: Sun, 30 Oct 2022 19:39:55 +0100 Subject: polybar: major cleanup, wttr.in forecast --- .local/bin/statusbar/sb-forecast | 48 ++++++++++++++++++++++++++++++++++++++++ .local/bin/statusbar/sb-packages | 22 ++++++++++++++++++ .local/bin/updates | 22 ------------------ 3 files changed, 70 insertions(+), 22 deletions(-) create mode 100755 .local/bin/statusbar/sb-forecast create mode 100755 .local/bin/statusbar/sb-packages delete mode 100755 .local/bin/updates (limited to '.local/bin') 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/statusbar/sb-packages b/.local/bin/statusbar/sb-packages new file mode 100755 index 0000000..bbdefb1 --- /dev/null +++ b/.local/bin/statusbar/sb-packages @@ -0,0 +1,22 @@ +#!/bin/sh + +if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then + updates_arch=0 +fi + +# if ! updates_aur=$(yay -Qum 2> /dev/null | wc -l); then +if ! updates_aur=$(paru -Qum 2> /dev/null | wc -l); then +# if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then +# if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then +# if ! updates_aur=$(pikaur -Qua 2> /dev/null | wc -l); then +# if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then + updates_aur=0 +fi + +aur_ignored=$($HOME/.local/bin/aurignored | wc -l) + +updates=$((updates_arch + updates_aur - $aur_ignored)) + +if [ "$updates" -gt 0 ]; then + echo " $updates" +fi diff --git a/.local/bin/updates b/.local/bin/updates deleted file mode 100755 index 7af054a..0000000 --- a/.local/bin/updates +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then - updates_arch=0 -fi - -# if ! updates_aur=$(yay -Qum 2> /dev/null | wc -l); then -if ! updates_aur=$(paru -Qum 2> /dev/null | wc -l); then -# if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then -# if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then -# if ! updates_aur=$(pikaur -Qua 2> /dev/null | wc -l); then -# if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then - updates_aur=0 -fi - -aur_ignored=$($HOME/.local/bin/aurignored | wc -l) - -updates=$((updates_arch + updates_aur - $aur_ignored)) - -if [ "$updates" -gt 0 ]; then - echo " $updates" -fi -- cgit v1.2.3-70-g09d2