bar.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. div="%{F#0092ff}<>%{F-}%{B-}"
  3. Clock() {
  4. DATETIME=$(date "+%a %b %d, %T")
  5. echo -n "$DATETIME"
  6. }
  7. cpuTemp() {
  8. CPUTEMP=$(sensors | grep CPU | awk '{print $2}')
  9. echo -n "CPU Temp: $CPUTEMP"
  10. }
  11. batteryInfo() {
  12. capacityRemaining=$(cat /sys/class/power_supply/BAT0/capacity)
  13. batteryStatus=$(cat /sys/class/power_supply/BAT0/status)
  14. if [[ $capacityRemaining -lt 25 ]]; then
  15. capacityRemaining="%{F#ff5b00}$capacityRemaining %{F-}%{B-}"
  16. fi
  17. if [[ "$batteryStatus" == "Charging" ]]; then
  18. batteryStatus="%{F#ff9966}$batteryStatus%{F-}%{B-}"
  19. fi
  20. capacityRemaining=$capacityRemaining%
  21. echo -n "Battery: $capacityRemaining $batteryStatus"
  22. }
  23. wifiInfo() {
  24. connectionName=$(wpa_cli status | egrep "^ssid" | sed s/ssid=//g)
  25. ipAddr=$(wpa_cli status | egrep "^ip" | sed s/ip_address=//g)
  26. echo -n "Wifi: $connectionName $div IP: $ipAddr"
  27. }
  28. ethPort() {
  29. linkDetected=$(cat /sys/class/net/enp0s31f6/carrier)
  30. if [[ $linkDetected -eq 0 ]]; then
  31. connected="eth0: down"
  32. elif [[ $linkDetected -eq 1 ]]; then
  33. connected="eth0: up"
  34. fi
  35. echo -n "$connected"
  36. }
  37. diskFree() {
  38. freeNVME=$(df -h /dev/mapper/decryptedRoot-root | awk '{print $4}' | tail -n1)
  39. echo -n "NVMe Free: $freeNVME"
  40. }
  41. loadAvg() {
  42. la=$(uptime | grep -o :\ [0-9].* | sed s/://g | awk '{print $1}' | sed s/,//g)
  43. if (( $(echo "$la > 8" |bc -l) )); then
  44. la="%{F#ff5b00}$la%{F-}%{B-}"
  45. else
  46. la="%{F#ff9966}$la%{F-}%{B-}"
  47. fi
  48. echo -n "Load: $la"
  49. }
  50. soundState() {
  51. muted=$(pactl list sinks | grep Mute: | awk '{print $2}')
  52. if [[ "$muted" == yes ]]; then
  53. state="Volume: 0%"
  54. else
  55. level=$(pactl list sinks | grep Volume: | awk '{print $5}' | head -n1)
  56. state="Volume: $level"
  57. fi
  58. echo -n $state
  59. }
  60. while true; do
  61. sleep 1
  62. echo "%{l} $(Clock) $div $(cpuTemp) $div $(loadAvg) $div $(wifiInfo) $div $(ethPort) $div $(diskFree) $div $(soundState) $div $(batteryInfo)"
  63. sleep 0.5
  64. done