Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Added option to print each battery on the same line, check 1.1.md for…
Browse files Browse the repository at this point in the history
… more info
  • Loading branch information
Dylan committed Feb 2, 2016
1 parent bb48cae commit 6cd2881
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 11 deletions.
16 changes: 16 additions & 0 deletions 1.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions config/config
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
39 changes: 28 additions & 11 deletions fetch
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
# If shorthand is on, print each value on the same line
if [ "$battery_shorthand" == "on" ]; then
battery=${batteries[@]}
battery=${battery// /%, }
battery="${battery}%"

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

# Print each battery on a seperate line.
for bat in ${batteries[@]}; do
prin "${title}${index}: ${bat}%"
index=$((index + 1))
done
else
battery="None"
fi
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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" ;;

Expand Down

0 comments on commit 6cd2881

Please sign in to comment.