From d07da7106c44babb0eeeff00057fb9ccc113d986 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Wed, 13 Nov 2024 08:55:35 +0100 Subject: [PATCH] systemd: Adding days to battery log --- systemd/usr/lib/systemd/system-sleep/battery | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/systemd/usr/lib/systemd/system-sleep/battery b/systemd/usr/lib/systemd/system-sleep/battery index 17cdf3e..778bbd6 100755 --- a/systemd/usr/lib/systemd/system-sleep/battery +++ b/systemd/usr/lib/systemd/system-sleep/battery @@ -14,10 +14,13 @@ if [ "$1" = "post" ]; then postpercent=$(echo "${acpi}" | grep -o "[0-9]*%" | cut -f1 -d%) - let diffmin=($(date +%s -d ${date})-$(date +%s -d ${predate}))/60 + let diffsecs=($(date +%s -d ${date})-$(date +%s -d ${predate})) let diffperc=(prepercent-postpercent) - addendum="${addendum} Discharged ${diffperc}% (${prepercent}% -> ${postpercent}%) in ${diffmin} minutes." + days=$(date -u -d @${diffsecs} +'%j') + let days=($days-1) + + addendum="${addendum} Discharged ${diffperc}% (${prepercent}% -> ${postpercent}%) in time ${days} days $(date -u -d @${diffsecs} +'%T')." fi fi -- 2.39.5