bar 1.8 KB

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