Battery tray indicator that takes into account power consumption trends, rather than just instantaneous wattage?
2026-05-19 16:09 UTC
Replies (4)
-
@Wfh@lemmy.zip 2026-05-19 17:23
Most of them are just a frontend for upower anyway.
-
@whatiswrongwithyou@lemmy.ml 2026-05-19 19:55
What is your desktop environment?
-
@Sunsofold@lemmings.world 2026-05-19 22:28
I never thought about it much but how hard would it be to add PID to your power info?
-
@MonkderVierte@lemmy.zip 2026-05-20 16:41
I mean, you can take x samples in y time abd average them, but else? About that, maybe script it nad then display the data in Verve plugin? I’ve created one a few years back but currently don’t use the laptop much, so a bug with calculating the remaining time remains. #!/bin/sh # # pretty-print battery-info and time on shell # Author: Daniel Frei # last change: 09.01.2025 battery_path=/sys/class/power_supply/BAT0 timeout1=10 timeout2=5 error() { printf '%s:\t%s\n' "error" "$1" >&2; [ -n "$2" ] && exit "$2"; } # complain to STDERR and exit if given code # while true; do # 🔌🔌 # reading uevent line for line, because f** idiots and whitespaces in int while read line; do IFS='=' set -- $line case "$1" in "POWER_SUPPLY_NAME") bat_name="$2" ;; "POWER_SUPPLY_STATUS") bat_state="$2" ;; "POWER_SUPPLY_TYPE") bat_type="$2" # = Battery ;; "POWER_SUPPLY_CAPACITY_LEVEL") bat_warn="$2" ;; "POWER_SUPPLY_CAPACITY") bat_perc="$2" ;; "POWER_SUPPLY_ENERGY_NOW") bat_chrg=$(($2 / 1000)) ;; "POWER_SUPPLY_ENERGY_FULL") bat_full=$(($2 / 1000)) ;; "POWER_SUPPLY_ENERGY_FULL_DESIGN") bat_chrg_des=$(($2 / 1000)) ;; "POWER_SUPPLY_VOLTAGE_NOW") bat_volt=$(($2 / 1000)) ;; esac done < "$battery_path"/uevent tt_empty=$(((bat_full - bat_now) / bat_volt)) # TODO tt_full=$(((bat_full + bat_now) / bat_volt)) # TODO bat_ttef="${tt_empty:-"$tt_full"}h" # printf 'tt_empty: %s\n' "$tt_empty" [ -n "$bat_state" ] || [ "$bat_type" = "battery" ] || error "Device has no battery" fgcol="$(tput setaf 2)" # green reset="$(tput sgr0)" symbol="🔋" # conditionals if [ "$bat_state" = "Discharging" ]; then fgcol="$(tput setaf 1)" # red symbol="🪫" fi if [ "$bat_warn" != "Normal" ]; then fgcol="$(tput setaf 1)" # red symbol="⚠" envwarn "Battery ${bat_name}: ${bat_warn}" fi # override bat_ttef only every 2nd time # if $flipflop; then string="${fgcol}${bat_perc}%${reset}/${bat_ttef}" # sleep $timeout1 # flipflop=false # else # symbol="🕑" # string=" $(date +%R)" # sleep $timeout2 # flipflop=true # fi _time="$(date +%R)" tput sc # save cursor position tput cup 0 $(($(tput cols)-20)) # set cursor position printf "%s %s / %s 🕑\n" "$string" "$symbol" "$_time" tput rc # reset cursor position # done