#!/bin/bash

# http://crn.hopto.org Enjoy!

# Get current time in seconds since epoch
now=$(date +%s)
start_of_day=$(date -d "$(date +%Y-%m-%d)" +%s)
seconds_passed=$(( now - start_of_day ))

# Calculate percentage
percentage_int=$(( (seconds_passed * 100) / 86400 ))
percentage_float=$(awk -v passed="$seconds_passed" 'BEGIN { printf "%.2f", (passed / 86400) * 100 }')

# Shorter bar configuration
bar_width=30
filled=$(( (percentage_int * bar_width) / 100 ))
empty=$(( bar_width - filled ))

# Generate bar
bar_filled=$(printf '█%.0s' $(seq 1 $filled))
bar_empty=$(printf '░%.0s' $(seq 1 $empty))

# Display: Percent in front of bar
echo -e "${percentage_float}% [${bar_filled}${bar_empty}]"   
