소스 검색

refactor bar script

siduck76 3 년 전
부모
커밋
88c156759f
1개의 변경된 파일7개의 추가작업 그리고 18개의 파일을 삭제
  1. 7 18
      .dwm/bar

+ 7 - 18
.dwm/bar

@@ -10,28 +10,18 @@ cpu() {
 }
 
 update_icon() {
-  printf "^c#94af7d^  "
+  printf "^c#94af7d^ "
 }
 
-# only for void users!
-xbps_updates() {
-  updates=$(doas xbps-install -un | wc -l)
+pkg_updates() {
+  updates=$(doas xbps-install -un | wc -l) # void
+  # updates=$(checkupdates | wc -l)   # arch , needs pacman contrib
+  # updates=$(aptitude search '~U' | wc -l)  # apt (ubuntu,debian etc)
 
   if [ -z "$updates" ]; then
     printf "^c#94af7d^ Fully Updated"
   else
-    printf "^c#94af7d^ $updates""s"
-  fi
-}
-
-# only for arch user! it requires pacman-contrib package
-pacman_updates() {
-  updates=$(checkupdates | wc -l)
-
-  if [ -z "$updates" ]; then
-    printf "^c#94af7d^ Fully Updated"
-  else
-    printf "^c#94af7d^ $updates"
+    printf "^c#94af7d^ $updates"" updates"
   fi
 }
 
@@ -71,8 +61,7 @@ clock() {
 
 while true; do
 
-  # remove these 2 lines if u dont use void! or adjust the xbps-updates to get n.o of updates (according your distro ofc)
-  [ $interval == 0 ] || [ $(($interval % 3600)) == 0 ] && updates=$(xbps-updates) # use updates=$(pacman_updates) for arch
+  [ $interval == 0 ] || [ $(($interval % 3600)) == 0 ] && updates=$(pkg_updates)
   interval=$((interval + 1))
 
   sleep 1 && xsetroot -name "$(update_icon) $updates $(batt) $(brightness) $(cpu) $(mem) $(wlan) $(clock)"