bar.sh 2.2 KB

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