#!/bin/sh

get_bat() {
    bat="$(cat /sys/class/power_supply/BAT1/capacity)"
    if [ "$bat" -lt 10 ]; then
        printf '<span foreground="red">%s%%</span>' "$bat"
    else
        printf '%s%%' "$bat"
    fi
}

while true
do
    time=$(date +"%A %Y-%m-%d %I:%M %p")
    time="$time $(date -u +"(%H:%M UTC)")"
    bat="$(get_bat)"
    wifi="$(nmcli -t dev show wlp170s0 | grep GENERAL.CONNECTION | cut -d ':' -f 2)"
    printf "wifi: %s | bat: %s | %s\n" "$wifi" "$bat" "$time"
    sleep 10
done
