From c7072bb60470f08cc061913d9911fda33cf26f25 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Fri, 26 Jul 2019 00:06:37 +0200 Subject: Added support for devel update checking (2/2) --- scripts/dwm-status | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/scripts/dwm-status b/scripts/dwm-status index 91905fc..4fcfcaa 100755 --- a/scripts/dwm-status +++ b/scripts/dwm-status @@ -1,13 +1,17 @@ #!/bin/sh +#TODO: Clean up the status function with individual separate functions (battery etc) + + # This script sets the statusbar with the xsetroot command at the end. Have it # started by ~/.xinitrc or ~/.xprofile. # Set the deliminter character. - delim="|" + internet=false counter=0 +updates_aur=0 checkinternet() { echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 @@ -19,6 +23,16 @@ checkinternet() { fi } +setaurupdates(){ + if [ "$internet" = true ]; then + if (( $counter % 30 == 0 )); then + if ! updates_aur=$(yay -Qum --devel 2> /dev/null | wc -l); then + updates_aur=0 + fi + fi + fi +} + updates() { if [ "$internet" = true ]; then @@ -27,14 +41,6 @@ updates() { updates_arch=0 fi - #if (( $counter % 60 == 0 )); then #this is done to add a delay and not saturate aur requests - if ! updates_aur=$(yay -Qum --devel 2> /dev/null | wc -l); then - updates_aur=0 - fi - #else - # updates_aur=0 # this is wrong. There shouldnt be else but fi - #fi - updates=$(("$updates_arch" + "$updates_aur")) if [ "$updates" -gt 0 ]; then @@ -44,9 +50,6 @@ updates() { fi echo $delim - - else - : fi } @@ -192,8 +195,10 @@ while :; do # to prevent some weird issues that cause significant slowing of # everything in dwm. Note entirely sure of the cause, but again, the tr # command easily avoids it. - - checkinternet + + checkinternet + + setaurupdates xsetroot -name "$(status | tr '\n' ' ')" -- cgit 1.4.1