bar 1.6 KB

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