Search notes:

Script: battery

battery.ps1 and battery are a PowerShell and shell script that print some battery related figures on the command prompt.

battery.ps1 (PowerShell)

$b = get-cimInstance Win32_Battery

$batteryStatus =( @{
    1 = 'Discharging'
    2 = 'Connected to AC' # 'Unknown'
    3 = 'Fully charged'
    4 = 'Low'
    5 = 'Critical'
    6 = 'Charging'
    7 = 'Charging/High'
    8 = 'Charging/Low'
    9 = 'Charging/Critical'
   10 = 'Undefined'
   11 = 'Partially Charged'
}
)[ $b.batteryStatus -as [int] ]


"$($b.caption) $($b.name): $($b.status)"
"  Status:              $batteryStatus ($($b.batteryStatus))"
"  Charged:             $($b.estimatedChargeRemaining) %"

if ($b.timeToFullCharge) {
"  Time to full charge: $($b.timeToFullCharge) Minutes"
}
Github repository scripts-and-utilities, path: /battery.ps1

battery (Linux shell)

#
#  Show how full the battery is, and if it is discharging
#
upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage"
Github repository scripts-and-utilities, path: /battery

See also

Other Scripts

Index