Added option to print each battery on the same line, check 1.1.md for more info

This commit is contained in:
Dylan 2016-02-02 12:01:50 +11:00
parent bb48caec70
commit 6cd2881962
4 changed files with 51 additions and 11 deletions

16
1.1.md
View file

@ -98,6 +98,22 @@ in your system.
- Added `battery_num` which allows you to choose which battery to display, <br \>
it also takes the value `all` which will print all batteries line by line.
- Added `battery_shorthand` which when set to `on` prints each battery on the<br \>
same line like so:
```sh
# battery_shorthand="on"
Battery: 10%, 5%, 67%
# battery_shorthand="off"
Battery0: 10%
Battery1: 5%
Battery2: 67%
# If there's only a single battery in the system
# we ommit the numbered title.
Battery: 10%
```
- **NOTE:** This currently only works on Linux, support for other platforms is being<br \>
worked on.

View file

@ -231,6 +231,8 @@ alias fetch2="fetch \
--gtk3 on/off Enable/Disable gtk3 theme/icons output
--shell_path on/off Enable/Disable showing \$SHELL path
--shell_version on/off Enable/Disable showing \$SHELL version
--battery_num Which battery to display, default value is 'all'
--battery_shorthand Whether or not each battery gets its own line and title
--birthday_shorthand Shorten the output of birthday
--birthday_time Enable/Disable showing the time in birthday output

View file

@ -122,6 +122,11 @@ gtk3="on"
# --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.
# --battery_shorthand on/off
battery_shorthand="off"
# Birthday

39
fetch
View file

@ -142,6 +142,11 @@ gtk3="on"
# --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.
# --battery_shorthand on/off
battery_shorthand="off"
# Birthday
@ -1209,18 +1214,26 @@ getbattery () {
# 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 ] && [ "$battery_num" == 0 ]; then
prin "${title}: ${batteries[0]}%"
return
fi
# If shorthand is on, print each value on the same line
if [ "$battery_shorthand" == "on" ]; then
battery=${batteries[@]}
battery=${battery// /%, }
battery="${battery}%"
# Print each battery on a seperate line.
for bat in ${batteries[@]}; do
prin "${title}${index}: ${bat}%"
index=$((index + 1))
done
else
# If there's only a single battery and it's battery 0,
# don't number the subtitle.
if [ "${#batteries[@]}" == 1 ] && [ "$battery_num" == 0 ]; then
prin "${title}: ${batteries[0]}%"
return
fi
# Print each battery on a seperate line.
for bat in ${batteries[@]}; do
prin "${title}${index}: ${bat}%"
index=$((index + 1))
done
fi
else
battery="None"
fi
@ -1974,6 +1987,8 @@ usage () { cat << EOF
--gtk3 on/off Enable/Disable gtk3 theme/icons output
--shell_path on/off Enable/Disable showing \$SHELL path
--shell_version on/off Enable/Disable showing \$SHELL version
--battery_num Which battery to display, default value is 'all'
--battery_shorthand Whether or not each battery gets its own line and title
--birthday_shorthand Shorten the output of birthday
--birthday_time Enable/Disable showing the time in birthday output
@ -2072,6 +2087,8 @@ while [ "$1" ]; do
--gtk3) gtk3="$2" ;;
--shell_path) shell_path="$2" ;;
--shell_version) shell_version="$2" ;;
--battery_num) battery_num="$2" ;;
--battery_shorthand) battery_shorthand="$2" ;;
--birthday_shorthand) birthday_shorthand="$2" ;;
--birthday_time) birthday_time="$2" ;;