1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
echo "{\"version\": 1}"
echo "["
echo "[]"
while true; do
bat_capacity=$(cat /sys/class/power_supply/macsmc-battery/capacity)
bat_status=$(cat /sys/class/power_supply/macsmc-battery/status)
if [ "$bat_status" = "Discharging" ]; then
bat_color="#FA2B00"
else
bat_color="#23C17C"
fi
datestr=$(date +'%Y-%m-%d %H:%M')
drive=$(df -h / --output=avail | tail -n 1 | awk '{$1=$1};1')
wifi_status=$(nmcli -t -f IN-USE,BARS,SSID dev wifi | rg '^\*')
wifi_bars=$(echo ${wifi_status} | cut -d':' -f 2)
wifi_ssid=$(echo ${wifi_status} | cut -d':' -f 3)
vpn_status=$(mullvad status -j | jq -r .state)
if [ "$vpn_status" = "connected" ]; then
vpn_color="#23C17C"
else
vpn_color="#FA2B00"
fi
cat << EOF
,[
{
"full_text": "<span foreground=\"${vpn_color}\">${wifi_bars}</span> ${wifi_ssid}",
"markup": "pango",
},
{
"full_text": "<span font-weight=\"100\">${drive}</span>",
"markup": "pango",
},
{
"full_text": "<span foreground=\"${bat_color}\" font-weight=\"100\">${bat_capacity}%</span>",
"markup": "pango",
},
{
"full_text": "<span font-weight=\"300\">${datestr}</span>",
"color": "#FFFFFF",
"markup": "pango",
}
]
EOF
# Sleep for a second before updating again
sleep 1
done
|