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