Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ set -g status-right '#{battery_status_bg} Batt: #{battery_icon} #{battery_percen
- `#{battery_icon_status}` - will display a battery status icon
- `#{battery_percentage}` - will show battery percentage
- `#{battery_remain}` - will show remaining time of battery charge\*
= `#{battery_charging_watts}` - will display the current watts supplied (currently supported only on OSX)

\* These format strings can be further customized via options as described below.

Expand Down
2 changes: 2 additions & 0 deletions battery.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ battery_interpolation=(
"\#{battery_icon_status}"
"\#{battery_percentage}"
"\#{battery_remain}"
"\#{battery_charging_watts}"
)

battery_commands=(
Expand All @@ -32,6 +33,7 @@ battery_commands=(
"#($CURRENT_DIR/scripts/battery_icon_status.sh)"
"#($CURRENT_DIR/scripts/battery_percentage.sh)"
"#($CURRENT_DIR/scripts/battery_remain.sh)"
"#($CURRENT_DIR/scripts/battery_charging_watts.sh)"
)

set_tmux_option() {
Expand Down
23 changes: 23 additions & 0 deletions scripts/battery_charging_watts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "$CURRENT_DIR/helpers.sh"

print_battery_percentage() {
if is_osx; then
watts=$(system_profiler SPPowerDataType | grep Wattage | awk '{print $3}')
if [ -z $watts];
then
watts="0"
fi
echo "$watts"
else
echo "??"
fi
}

main() {
print_battery_percentage
}
main