#!/bin/bash
div="%{F#ff9966}<>%{F-}"
# Define the clock
Clock() {
DATETIME=$(date "+%a %b %d, %T")
echo -n "$DATETIME"
}
cpuTemp() {
TEMP=$(sensors | grep CPU: | awk '{print $2}' );
nakedTemp=$(echo $TEMP | grep -o [0-9][0-9])
if [[ $nakedTemp -gt 60 ]]; then
TEMP="%{F#A54242}$TEMP%{F-}%{B-}"
fi
FREQ=$(lscpu | grep "CPU MHz" | awk '{print $3}')
echo -n "Temp: $TEMP >> Freq: $FREQ"
}
batteryInfo() {
capacityRemaining=$(cat /sys/class/power_supply/BAT0/capacity)
batteryStatus=$(cat /sys/class/power_supply/BAT0/status)
if [[ $capacityRemaining -lt 25 ]]; then
capacityRemaining="%{F#A54242}$capacityRemaining %{F-}%{B-}"
fi
if [[ "$batteryStatus" == "Charging" ]]; then
batteryStatus="%{F#5E9440}$batteryStatus%{F-}%{B-}"
fi
capacityRemaining=$capacityRemaining%
echo -n "Battery: $capacityRemaining $batteryStatus"
}
wifiInfo() {
connectionName=$(nmcli -f GENERAL,WIFI-PROPERTIES dev show wlp60s0 | grep GENERAL.CONNECTION: | awk '{print $2}')
connectionStrength=$(cat /proc/net/wireless | grep wlp60s0 | awk '{print $3}' | sed s/.$//g)
echo -n "Wifi: $connectionName $connectionStrength%"
}
ethPort() {
linkDetected=$(cat /sys/class/net/enp59s0/carrier)
if [[ $linkDetected -eq 0 ]]; then
connected="eth0: down"
elif [[ $linkDetected -eq 1 ]]; then
connected="eth0: up"
fi
echo -n "$connected"
}
diskFree() {
freeSSD=$(df -h /dev/mapper/ubuntu--vg-root | awk '{print $4}' | tail -n1)
#freeHDD=$(df -h /dev/sdb1 | awk '{print $4}' | tail -n1)
echo -n "SSD Free: $freeSSD >> HDD Free: $freeHDD"
}
loadAvg() {
la=$(uptime | grep -o :\ [0-9].* | sed s/://g | awk '{print $1}' | sed s/,//g)
echo -n "Load: $la"
}
soundState() {
muted=$(pactl list sinks | grep Mute: | awk '{print $2}')
if [[ "$muted" == yes ]]; then
state="Volume: 0%"
else
level=$(pactl list sinks | grep Volume: | awk '{print $5}' | head -n1)
state="Volume: $level"
fi
echo -n $state
}
expressVpn() {
expressValue=$(expressvpn status | grep Connected 2>&1 > /dev/null; echo $?)
if [[ "$expressValue" -ne 0 ]]; then
echo -n "ExpressVPN not connected"
elif [[ "$expressValue" -eq 0 ]]; then
echo -n "ExpressVPN connected"
else
echo -n "Could not determine ExpressVPN status"
fi
}
while true; do
sleep 1
echo "%{l} $(Clock) $div $(cpuTemp) $div $(loadAvg) $div $(batteryInfo) $div $(wifiInfo) $div $(ethPort) $div $(diskFree) $div $(soundState) $div $(expressVpn) "
sleep 0.5
done