From d56aea2398fee968b8b466482da859f5b795c43b Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 19 Aug 2024 16:29:37 +0100 Subject: (Scripts)+script for getting time left in battery using acpi -b Customisable and has an exact hour + minute timer. --- Scripts/.local/scripts/status/battery | 2 +- Scripts/.local/scripts/status/battery_time_left | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100755 Scripts/.local/scripts/status/battery_time_left diff --git a/Scripts/.local/scripts/status/battery b/Scripts/.local/scripts/status/battery index 6cf5b52..f89d123 100755 --- a/Scripts/.local/scripts/status/battery +++ b/Scripts/.local/scripts/status/battery @@ -1,7 +1,7 @@ #!/usr/bin/env bash capacity=$(cat /sys/class/power_supply/BAT0/capacity) || break status=$(cat /sys/class/power_supply/BAT0/status) -time_left=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "time" | sed 's/.*://' | xargs echo $1) +time_left=$($HOME/.local/scripts/status/battery_time_left); if [[ $status == "Charging" ]] then diff --git a/Scripts/.local/scripts/status/battery_time_left b/Scripts/.local/scripts/status/battery_time_left new file mode 100755 index 0000000..8dfadf2 --- /dev/null +++ b/Scripts/.local/scripts/status/battery_time_left @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +capture="" +if [[ $# -eq 1 ]] +then + capture="\1H,\2M,\3s" +else + capture="\1H,\2M" +fi + +acpi -b | sed "s/.*\([0-9][0-9]\):\([0-9][0-9]\):\([0-9][0-9]\).*/$capture/g" | xargs echo -- cgit v1.2.3-13-gbd6f