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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759390575, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/tools/scripts/personal/battery(77): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78