bar.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 k10temp-pci-00c3 | grep Tdie | awk '{print $2}' | grep -o [0-9][0-9]||[0-9][0-9][0-9])
  9. GPUTEMP=$(sensors amdgpu-pci-1d00 | grep temp1 | awk '{print $2}' | grep -o [0-9][0-9]||[0-9][0-9][0-9])
  10. GPUFAN=$(sensors amdgpu-pci-1d00 | grep fan1 | awk '{print $2}')
  11. if [[ $CPUTEMP -gt 70 ]]; then
  12. CPUTEMP="%{F#ff5b00}$CPUTEMP%{F-}%{B-}"
  13. else
  14. CPUTEMP="%{F#ff9966}$CPUTEMP%{F-}%{B-}"
  15. fi
  16. if [[ $GPUTEMP -gt 70 ]]; then
  17. GPUTEMP="%{F#ff5b00}$GPUTEMP%{F-}%{B-}"
  18. else
  19. GPUTEMP="%{F#ff9966}$GPUTEMP%{F-}%{B-}"
  20. fi
  21. CPUFREQ=$(lscpu | grep MHz | head -n1 | awk '{print $3}')
  22. echo -n "CPU Temp: $CPUTEMP° CPU Freq: $CPUFREQ $div GPU Temp: $GPUTEMP° $div GPU FAN: $GPUFAN RPM"
  23. }
  24. batteryInfo() {
  25. capacityRemaining=$(cat /sys/class/power_supply/BAT0/capacity)
  26. batteryStatus=$(cat /sys/class/power_supply/BAT0/status)
  27. if [[ $capacityRemaining -lt 25 ]]; then
  28. capacityRemaining="%{F#ff5b00}$capacityRemaining %{F-}%{B-}"
  29. fi
  30. if [[ "$batteryStatus" == "Charging" ]]; then
  31. batteryStatus="%{F#ff9966}$batteryStatus%{F-}%{B-}"
  32. fi
  33. capacityRemaining=$capacityRemaining%
  34. echo -n "Battery: $capacityRemaining $batteryStatus"
  35. }
  36. wifiInfo() {
  37. connectionName=$(nmcli -f GENERAL,WIFI-PROPERTIES dev show wlp26s0 | grep GENERAL.CONNECTION: | awk '{print $2}')
  38. connectionStrength=$(nmcli dev wifi | tail -n1 | awk '{print $7}')
  39. echo -n "Wifi: $connectionName $connectionStrength%"
  40. }
  41. ethPort() {
  42. linkDetected=$(cat /sys/class/net/enp24s0/carrier)
  43. if [[ $linkDetected -eq 0 ]]; then
  44. connected="eth0: down"
  45. elif [[ $linkDetected -eq 1 ]]; then
  46. connected="eth0: up"
  47. fi
  48. echo -n "$connected"
  49. }
  50. diskFree() {
  51. freeNVME=$(df -h /dev/mapper/ubuntu--vg-root | awk '{print $4}' | tail -n1)
  52. freeHDD=$(df -h /dev/mapper/hddVolume | awk '{print $4}' | tail -n1)
  53. echo -n "NVMe Free: $freeNVME $div HDD Free: $freeHDD"
  54. }
  55. loadAvg() {
  56. la=$(uptime | grep -o :\ [0-9].* | sed s/://g | awk '{print $1}' | sed s/,//g)
  57. if (( $(echo "$la > 8" |bc -l) )); then
  58. la="%{F#ff5b00}$la%{F-}%{B-}"
  59. else
  60. la="%{F#ff9966}$la%{F-}%{B-}"
  61. fi
  62. echo -n "Load: $la"
  63. }
  64. soundState() {
  65. muted=$(pactl list sinks | grep Mute: | awk '{print $2}')
  66. if [[ "$muted" == yes ]]; then
  67. state="Volume: 0%"
  68. else
  69. level=$(pactl list sinks | grep Volume: | awk '{print $5}' | head -n1)
  70. state="Volume: $level"
  71. fi
  72. echo -n $state
  73. }
  74. expressVpn() {
  75. expressValue=$(expressvpn status | grep Connected 2>&1 > /dev/null; echo $?)
  76. if [[ "$expressValue" -ne 0 ]]; then
  77. echo -n "%{F#ff5b00}EVPN Down%{F-}%{B-}"
  78. elif [[ "$expressValue" -eq 0 ]]; then
  79. echo -n "%{F#ff9966}EVPN Up%{F-}%{B-}"
  80. else
  81. echo -n "Could not determine ExpressVPN status"
  82. fi
  83. }
  84. now_playing() {
  85. artist=$(cmus-remote -Q | grep "tag artist " | sed s/^tag\ artist\ //g)
  86. title=$(cmus-remote -Q | grep "tag title " | sed s/^tag\ title\ //g)
  87. album=$(cmus-remote -Q | grep "tag album " | sed s/^tag\ album\ //g)
  88. echo -n "Now Playing: $artist - $album - %{F#ff9966}$title%{F-}%{B-}"
  89. }
  90. while true; do
  91. sleep 1
  92. echo "%{l} $(Clock) $div $(cpuTemp) $div $(loadAvg) $div $(wifiInfo) $div $(ethPort) $div $(diskFree) $div $(soundState) $div $(expressVpn) $div $(now_playing)"
  93. sleep 0.5
  94. done