From: Stefan Huber Date: Wed, 13 Nov 2024 07:55:35 +0000 (+0100) Subject: systemd: Adding days to battery log X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=shutils.git systemd: Adding days to battery log --- 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