mirror of
https://github.com/avinal/dotfiles.git
synced 2026-07-03 23:20:07 +05:30
c2786c7f96
- move older config to archive Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
20 lines
608 B
Bash
Executable File
20 lines
608 B
Bash
Executable File
#!/bin/bash
|
|
|
|
output=$(wakatime --today)
|
|
|
|
# Extract hours and minutes using awk and sum the total
|
|
total_minutes=$(echo "$output" | awk -F' ' '
|
|
{
|
|
for (i=1; i<=NF; i++) {
|
|
if ($i == "hrs" || $i == "hr") total += $(i-1) * 60;
|
|
if ($i == "mins" || $i == "min") total += $(i-1);
|
|
}
|
|
} END {print total}')
|
|
|
|
# Calculate total hours and remaining minutes
|
|
total_hours=$((total_minutes / 60))
|
|
remaining_minutes=$((total_minutes % 60))
|
|
|
|
# Print the results
|
|
printf '{"text":"%02dh %02dm","tooltip":"%s","class":"wakatime"}' $total_hours $remaining_minutes "$output" | jq --unbuffered --compact-output
|