#!/bin/sh

while true; do
  BATTERY="$(cat /sys/class/power_supply/BAT1/capacity)%"
  MEMORY_USED="$(free -m | awk 'NR==2 {print $3}')"
  VOLUME=$(wpctl get-volume @DEFAULT_SINK@)
  DATE_TIME=$(date +%m-%d-%Y" "%R:%S)
  if [ "$MEMORY_USED" -gt 4096 ]; then
    MEMORY_USED="$((MEMORY_USED/1024)) GiB"
  else 
    MEMORY_USED="$MEMORY_USED MiB"
  fi
  xsetroot -name "$BATTERY $MEMORY_USED $VOLUME $DATE_TIME"
  sleep 1
done
