From fc5a75071a7b593f4e68165ecca4f03a52ae06c3 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Fri, 17 Apr 2020 01:43:07 -0700 Subject: [PATCH] battery level check thingy --- bat | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 bat diff --git a/bat b/bat new file mode 100755 index 0000000..f911b83 --- /dev/null +++ b/bat @@ -0,0 +1,10 @@ +#!/bin/bash + +# Shows current battery level from BAT0 +# also a script to show off some tricks(hopefully) + +raw=`echo -n ' / ' | cat /sys/class/power_supply/BAT0/energy_now - /sys/class/power_supply/BAT0/energy_full | tr -d '\n'` + +digits=$(echo $raw | bc -l) +digits=${digits##.} +echo Battery %${digits:0:2}.${digits:3:2}