From 1b7c4b431d42495323c9c3a140f4a314de72de9e Mon Sep 17 00:00:00 2001 From: Josh Willox <39120423+jcwillox@users.noreply.github.com> Date: Wed, 23 Dec 2020 20:28:51 +1100 Subject: [PATCH] Add battery info --- src/posh-winfetch.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/posh-winfetch.ps1 b/src/posh-winfetch.ps1 index 09dcd6e..e1175b4 100644 --- a/src/posh-winfetch.ps1 +++ b/src/posh-winfetch.ps1 @@ -411,6 +411,23 @@ function info_pkgs { } +# ===== BATTERY ===== +function info_battery { + $battery = (Get-CimInstance Win32_Battery -CimSession $cimSession -Property EstimatedChargeRemaining).EstimatedChargeRemaining + + $content = if ($battery) { + "$battery %" + } else { + "(none)" + } + + return @{ + title = "Battery" + content = $content + } +} + + # reset terminal sequences and display a newline Write-Host "$e[0m"