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