bar 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. interval=0
  3. update_icon() {
  4. icon=""
  5. printf "^c#94af7d^ $icon ^d^%s"
  6. printf "^c#94af7d^"
  7. }
  8. # only for void users!
  9. xbps_updates() {
  10. updates=$(xbps-install -un | cut -d' ' -f2 | sort | uniq -c | xargs)
  11. if [ -z "$updates" ]; then
  12. echo "Fully Updated"
  13. else
  14. echo "$updates""s"
  15. fi
  16. }
  17. # battery
  18. batt() {
  19. printf "^c#81A1C1^  ^d^%s" "$(acpi | sed "s/,//g" | awk '{if ($3 == "Discharging"){print $4; exit} else {print $4""}}' | tr -d "\n")"
  20. }
  21. brightness() {
  22. backlight() {
  23. backlight="$(xbacklight -get)"
  24. echo -e "$backlight" #| cut -c 1-2
  25. }
  26. icon="  "
  27. printf "^c#BF616A^$icon"
  28. printf "^c#BF616A^%.0f\n" $(backlight)
  29. }
  30. mem() {
  31. printf "^c#7797b7^^b#363c48^  ^d^%s" "^c#7797b7^^b#414753^ $(free -h | awk '/^Mem/ { print $3 }' | sed s/i//g)"
  32. }
  33. wlan() {
  34. case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in
  35. up) printf "^c#3b414d^ ^b#7681c5^ 󰤨 ^d^%s" " ^c#828dd1^Connected" ;;
  36. down) printf "^c#3b414d^ ^b#7681c5^ 󰤨 ^d^%s" " ^c#828dd1^Disconnected" ;;
  37. esac
  38. }
  39. clock() {
  40. printf "^c#2E3440^ ^b#828dd1^ 󱑆 ^d^%s %s\n" "^c#2E3440^^b#6c77bb^ $(date '+%a, %I:%M %p')" "$()"
  41. }
  42. while true; do
  43. # remove these 2 lines if u dont use void! or adjust the xbps-updates to get n.o of updates (according your distro ofc)
  44. [ $interval == 0 ] || [ $(($interval % 3600)) == 0 ] && updates=$(xbps-updates)
  45. interval=$((interval + 1))
  46. sleep 1 && xsetroot -name "$(update_icon) $(xbps-updates) $(batt) $(brightness) $(mem) $(wlan) $(clock)"
  47. done