From 8bde95fdaba4fb866718b071d403e6da606deb29 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 25 Jul 2023 14:05:53 -0400 Subject: [PATCH 1/2] add mac charging watts --- scripts/battery_charging_watts.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 scripts/battery_charging_watts.sh 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 From 3bd411389c44654f8a8160b9f852f1cbbe455368 Mon Sep 17 00:00:00 2001 From: David Gamero Date: Tue, 25 Jul 2023 14:08:21 -0400 Subject: [PATCH 2/2] update readme --- README.md | 1 + battery.tmux | 2 ++ 2 files changed, 3 insertions(+) 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() {