From 5ca3666055a6445397be5cadf2ed330a6daeda6d Mon Sep 17 00:00:00 2001 From: Dylan Date: Wed, 3 Feb 2016 09:26:47 +1100 Subject: [PATCH] Fixes gpu count and added battery support to Mac OS X and Windows --- config/config | 2 ++ fetch | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/config/config b/config/config index 92591c20..ba825bb5 100644 --- a/config/config +++ b/config/config @@ -119,11 +119,13 @@ gtk3="on" # Which battery to display. # By default we display all batteries. +# NOTE: Only works on Linux. # --battery_num all, 0, 1, 2, etc battery_num="all" # Whether or not to print each battery on the same line. # By default each battery gets its own line and title. +# NOTE: Only works on Linux. # --battery_shorthand on/off battery_shorthand="off" diff --git a/fetch b/fetch index 3fbc6fbd..1bd6af15 100755 --- a/fetch +++ b/fetch @@ -139,11 +139,13 @@ gtk3="on" # Which battery to display. # By default we display all batteries. +# NOTE: Only works on Linux. # --battery_num all, 0, 1, 2, etc battery_num="all" # Whether or not to print each battery on the same line. # By default each battery gets its own line and title. +# NOTE: Only works on Linux. # --battery_shorthand on/off battery_shorthand="off" @@ -835,11 +837,12 @@ getgpu () { case "$os" in "Linux") # Get the GPUs - gpu="$(lspci | grep -F "VGA" | uniq -c)" - gpu=${gpu/??':'??'.'?} + gpu="$(lspci | grep -F "VGA")" + gpu=${gpu//??':'??'.'?} # Count the number of GPUs - count=${gpu/ VGA*} + count="$(printf "%s" "$gpu" | uniq -c)" + count=${count/ VGA*} count=${count//[[:space:]]} # If there's more than one gpu @@ -1238,6 +1241,18 @@ getbattery () { battery="None" fi ;; + + "Mac OS X") + battery="$(pmset -g batt | grep -o '[0-9]*%')" + ;; + + "Windows") + battery="$(wmic path Win32_Battery Get EstimatedChargeRemaining /value)" + battery=${battery/EstimatedChargeRemaining'='} + battery=${battery//[[:space:]]/ } + battery=${battery// } + battery+="%" + ;; esac }