]> git.sthu.org Git - shutils.git/commitdiff
systemd: Adding days to battery log master
authorStefan Huber <shuber@sthu.org>
Wed, 13 Nov 2024 07:55:35 +0000 (08:55 +0100)
committerStefan Huber <shuber@sthu.org>
Wed, 13 Nov 2024 07:55:35 +0000 (08:55 +0100)
systemd/usr/lib/systemd/system-sleep/battery

index 17cdf3e20f4127e7371bfc001e8a6ae67d967d54..778bbd61866a1f3c074473197ef1a25ecec3b1e5 100755 (executable)
@@ -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