about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2019-07-26 00:06:37 +0200
committerManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2019-07-26 00:06:37 +0200
commitc7072bb60470f08cc061913d9911fda33cf26f25 (patch)
treeec312dfe6c274b151e1ae93f18ab555eadfecae7
parentFormatting (diff)
downloaddwm-c7072bb60470f08cc061913d9911fda33cf26f25.tar.gz
dwm-c7072bb60470f08cc061913d9911fda33cf26f25.tar.bz2
dwm-c7072bb60470f08cc061913d9911fda33cf26f25.zip
Added support for devel update checking (2/2)
-rwxr-xr-xscripts/dwm-status33
1 files 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' ' ')"