bar 1.6 KB

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