bar.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/bash
  2. div="%{F#ff9966}<>%{F-}"
  3. # Define the clock
  4. Clock() {
  5. DATETIME=$(date "+%a %b %d, %T")
  6. echo -n "$DATETIME"
  7. }
  8. cpuTemp() {
  9. TEMP=$(sensors | grep CPU: | awk '{print $2}' );
  10. nakedTemp=$(echo $TEMP | grep -o [0-9][0-9])
  11. if [[ $nakedTemp -gt 60 ]]; then
  12. TEMP="%{F#A54242}$TEMP%{F-}%{B-}"
  13. fi
  14. FREQ=$(lscpu | grep "CPU MHz" | awk '{print $3}')
  15. echo -n "Temp: $TEMP >> Freq: $FREQ"
  16. }
  17. batteryInfo() {
  18. capacityRemaining=$(cat /sys/class/power_supply/BAT0/capacity)
  19. batteryStatus=$(cat /sys/class/power_supply/BAT0/status)
  20. if [[ $capacityRemaining -lt 25 ]]; then
  21. capacityRemaining="%{F#A54242}$capacityRemaining %{F-}%{B-}"
  22. fi
  23. if [[ "$batteryStatus" == "Charging" ]]; then
  24. batteryStatus="%{F#5E9440}$batteryStatus%{F-}%{B-}"
  25. fi
  26. capacityRemaining=$capacityRemaining%
  27. echo -n "Battery: $capacityRemaining $batteryStatus"
  28. }
  29. wifiInfo() {
  30. connectionName=$(nmcli -f GENERAL,WIFI-PROPERTIES dev show wlp60s0 | grep GENERAL.CONNECTION: | awk '{print $2}')
  31. connectionStrength=$(cat /proc/net/wireless | grep wlp60s0 | awk '{print $3}' | sed s/.$//g)
  32. echo -n "Wifi: $connectionName $connectionStrength%"
  33. }
  34. ethPort() {
  35. linkDetected=$(cat /sys/class/net/enp59s0/carrier)
  36. if [[ $linkDetected -eq 0 ]]; then
  37. connected="eth0: down"
  38. elif [[ $linkDetected -eq 1 ]]; then
  39. connected="eth0: up"
  40. fi
  41. echo -n "$connected"
  42. }
  43. diskFree() {
  44. freeSSD=$(df -h /dev/mapper/ubuntu--vg-root | awk '{print $4}' | tail -n1)
  45. #freeHDD=$(df -h /dev/sdb1 | awk '{print $4}' | tail -n1)
  46. echo -n "SSD Free: $freeSSD >> HDD Free: $freeHDD"
  47. }
  48. loadAvg() {
  49. la=$(uptime | grep -o :\ [0-9].* | sed s/://g | awk '{print $1}' | sed s/,//g)
  50. echo -n "Load: $la"
  51. }
  52. soundState() {
  53. muted=$(pactl list sinks | grep Mute: | awk '{print $2}')
  54. if [[ "$muted" == yes ]]; then
  55. state="Volume: 0%"
  56. else
  57. level=$(pactl list sinks | grep Volume: | awk '{print $5}' | head -n1)
  58. state="Volume: $level"
  59. fi
  60. echo -n $state
  61. }
  62. expressVpn() {
  63. expressValue=$(expressvpn status | grep Connected 2>&1 > /dev/null; echo $?)
  64. if [[ "$expressValue" -ne 0 ]]; then
  65. echo -n "ExpressVPN not connected"
  66. elif [[ "$expressValue" -eq 0 ]]; then
  67. echo -n "ExpressVPN connected"
  68. else
  69. echo -n "Could not determine ExpressVPN status"
  70. fi
  71. }
  72. while true; do
  73. sleep 1
  74. echo "%{l} $(Clock) $div $(cpuTemp) $div $(loadAvg) $div $(batteryInfo) $div $(wifiInfo) $div $(ethPort) $div $(diskFree) $div $(soundState) $div $(expressVpn) "
  75. sleep 0.5
  76. done