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