diff --git a/README.md b/README.md index 5bf4775..322b1f2 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/battery.tmux b/battery.tmux index 0c666b8..55480e0 100755 --- a/battery.tmux +++ b/battery.tmux @@ -17,6 +17,7 @@ battery_interpolation=( "\#{battery_icon_status}" "\#{battery_percentage}" "\#{battery_remain}" + "\#{battery_charging_watts}" ) battery_commands=( @@ -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() { diff --git a/scripts/battery_charging_watts.sh b/scripts/battery_charging_watts.sh new file mode 100755 index 0000000..b8522f0 --- /dev/null +++ b/scripts/battery_charging_watts.sh @@ -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