diff --git a/1.1.md b/1.1.md index 6da39756..5233ba6e 100644 --- a/1.1.md +++ b/1.1.md @@ -96,6 +96,9 @@ the output of birthday. - Added `battery` which prints the battery usage percentage for each battery
in your system. +- Added `battery_num` which allows you to choose which battery to display,
+it also takes the value `all` which will print all batteries line by line. + - **NOTE:** This currently only works on Linux, support for other platforms is being
worked on. diff --git a/config/config b/config/config index 553b5504..4067b2b0 100644 --- a/config/config +++ b/config/config @@ -115,6 +115,14 @@ gtk2="on" gtk3="on" +# Battery + +# Which battery to display. +# By default we display all batteries. +# --battery_num all, 0, 1, 2, etc +battery_num="all" + + # Birthday # Whether to show a long pretty output diff --git a/fetch b/fetch index 0b3fbe2b..e7ee0323 100755 --- a/fetch +++ b/fetch @@ -135,6 +135,14 @@ gtk2="on" gtk3="on" +# Battery + +# Which battery to display. +# By default we display all batteries. +# --battery_num all, 0, 1, 2, etc +battery_num="all" + + # Birthday # Whether to show a long pretty output @@ -1189,26 +1197,32 @@ getbattery () { case "$os" in "Linux") if [ -d "/sys/class/power_supply/BAT0" ]; then - batteries=($(cat /sys/class/power_supply/BAT*/capacity)) + # Set the index to the battery number. + case "$battery_num" in + "all") battery_num="*" index=0 ;; + *) index="$battery_num" ;; + esac + + # Create an array of battery usage from each battery. + batteries=($(cat /sys/class/power_supply/BAT${battery_num}/capacity)) # Get the subtitle and reassign it so it doesn't change. title="$subtitle" # If there's only a single battery, # don't number the subtitle. - if [ "${#batteries[@]}" == 1 ]; then + if [ "${#batteries[@]}" == 1 ] && [ "$battery_num" == 0 ]; then prin "${title}: ${batteries[0]}%" return fi # Print each battery on a seperate line. - index=0 for bat in ${batteries[@]}; do prin "${title}${index}: ${bat}%" index=$((index + 1)) done else - battery="Unknown" + battery="None" fi ;; esac