From aa0cbe77656de36ce4bcc813b653d15f486d9012 Mon Sep 17 00:00:00 2001 From: Ethan <96821054+Ethanol48@users.noreply.github.com> Date: Wed, 18 Jan 2023 21:42:03 +0100 Subject: [PATCH 01/10] implementation of "live" icon Implementation of an icon displaying the battery depending on the status, (if is charging) and battery level --- scripts/battery_icon_plus_status.sh | 130 ++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 scripts/battery_icon_plus_status.sh diff --git a/scripts/battery_icon_plus_status.sh b/scripts/battery_icon_plus_status.sh new file mode 100644 index 0000000..ee7da37 --- /dev/null +++ b/scripts/battery_icon_plus_status.sh @@ -0,0 +1,130 @@ +#!/usr/bin/env bash + +CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source "$CURRENT_DIR/helpers.sh" + +# icons charging  ,  ,  ,  ,  , ,  +# icons 100, 90, 80, 60, 40, 30, 20 % + +# icons normal  , , , , , , , ,  +# icons 100, 90, 80, 70, 60, 50, 40, 20, 10 % + + + + + +# script global variables +icon_charge_tier8='' +icon_charge_tier7='' +icon_charge_tier6='' +icon_charge_tier5='' +icon_charge_tier4='' +icon_charge_tier3='' +icon_charge_tier2='' +icon_charge_tier1='' + +# script default variables +icon_charge_tier8_default='' +icon_charge_tier7_default='' +icon_charge_tier6_default='' +icon_charge_tier5_default='' +icon_charge_tier4_default='' +icon_charge_tier3_default='' +icon_charge_tier2_default='' +icon_charge_tier1_default='' + +icon_charge_tier8_charging='' +icon_charge_tier7_charging='' +icon_charge_tier6_charging='' +icon_charge_tier5_charging='' +icon_charge_tier4_charging='' +icon_charge_tier3_charging='' +icon_charge_tier2_charging='' +icon_charge_tier1_charging='' + + + +# icons are set as script global variables +get_icon_charge_settings() { + icon_charge_tier8=$(get_tmux_option "@batt_icon_charge_tier8" "$icon_charge_tier8_default") + icon_charge_tier7=$(get_tmux_option "@batt_icon_charge_tier7" "$icon_charge_tier7_default") + icon_charge_tier6=$(get_tmux_option "@batt_icon_charge_tier6" "$icon_charge_tier6_default") + icon_charge_tier5=$(get_tmux_option "@batt_icon_charge_tier5" "$icon_charge_tier5_default") + icon_charge_tier4=$(get_tmux_option "@batt_icon_charge_tier4" "$icon_charge_tier4_default") + icon_charge_tier3=$(get_tmux_option "@batt_icon_charge_tier3" "$icon_charge_tier3_default") + icon_charge_tier2=$(get_tmux_option "@batt_icon_charge_tier2" "$icon_charge_tier2_default") + icon_charge_tier1=$(get_tmux_option "@batt_icon_charge_tier1" "$icon_charge_tier1_default") +} + + +print_icon_charge_plus_status() { + percentage=$($CURRENT_DIR/battery_percentage.sh | sed -e 's/%//') + status=$(battery_status | awk '{print $1;}') + if [ $status == 'charging' ]; then + + if [ $percentage -ge 95 -o "$percentage" == "" ]; then + # if percentage is empty, assume it's a desktop # maximum + printf "$icon_charge_tier8_charging" + + elif [ $percentage -ge 80 ]; then + printf "$icon_charge_tier7_charging" + + elif [ $percentage -ge 65 ]; then + printf "$icon_charge_tier6_charging" + + elif [ $percentage -ge 50 ]; then + printf "$icon_charge_tier5_charging" + + elif [ $percentage -ge 35 ]; then + printf "$icon_charge_tier4_charging" + + elif [ $percentage -ge 20 ]; then + printf "$icon_charge_tier3_charging" + + elif [ $percentage -gt 5 ]; then + printf "$icon_charge_tier2_charging" + + else + printf "$icon_charge_tier1_charging" # minimun + fi + + else + + if [ $percentage -ge 95 -o "$percentage" == "" ]; then + # if percentage is empty, assume it's a desktop # maximum + printf "$icon_charge_tier8" + + elif [ $percentage -ge 80 ]; then + printf "$icon_charge_tier7" + + elif [ $percentage -ge 65 ]; then + printf "$icon_charge_tier6" + + elif [ $percentage -ge 50 ]; then + printf "$icon_charge_tier5" + + elif [ $percentage -ge 35 ]; then + printf "$icon_charge_tier4" + + elif [ $percentage -ge 20 ]; then + printf "$icon_charge_tier3" + + elif [ $percentage -gt 5 ]; then + printf "$icon_charge_tier2" + + else + printf "$icon_charge_tier1" # minimun + fi + fi +} + + + + +main() { + get_icon_charge_settings + print_icon_charge_plus_status +} + +main From 2e5fb99c62d47e08134f35b27513d12813355e0d Mon Sep 17 00:00:00 2001 From: Ethan <96821054+Ethanol48@users.noreply.github.com> Date: Wed, 18 Jan 2023 21:55:33 +0100 Subject: [PATCH 02/10] Update comments --- scripts/battery_icon_plus_status.sh | 105 ++++++++++++++-------------- 1 file changed, 51 insertions(+), 54 deletions(-) diff --git a/scripts/battery_icon_plus_status.sh b/scripts/battery_icon_plus_status.sh index ee7da37..39ba13a 100644 --- a/scripts/battery_icon_plus_status.sh +++ b/scripts/battery_icon_plus_status.sh @@ -5,14 +5,12 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source "$CURRENT_DIR/helpers.sh" # icons charging  ,  ,  ,  ,  , ,  -# icons 100, 90, 80, 60, 40, 30, 20 % +# 100, 90, 80, 60, 40, 30, 20 % # icons normal  , , , , , , , ,  -# icons 100, 90, 80, 70, 60, 50, 40, 20, 10 % - - - +# 100, 90, 80, 70, 60, 50, 40, 20, 10 % +# unfortunately there's a mismatch there are no more available charging icons, there are two that are duplicated in the variables # script global variables icon_charge_tier8='' @@ -61,65 +59,64 @@ get_icon_charge_settings() { print_icon_charge_plus_status() { percentage=$($CURRENT_DIR/battery_percentage.sh | sed -e 's/%//') status=$(battery_status | awk '{print $1;}') - if [ $status == 'charging' ]; then - - if [ $percentage -ge 95 -o "$percentage" == "" ]; then - # if percentage is empty, assume it's a desktop # maximum - printf "$icon_charge_tier8_charging" - - elif [ $percentage -ge 80 ]; then - printf "$icon_charge_tier7_charging" - - elif [ $percentage -ge 65 ]; then - printf "$icon_charge_tier6_charging" - - elif [ $percentage -ge 50 ]; then - printf "$icon_charge_tier5_charging" - - elif [ $percentage -ge 35 ]; then - printf "$icon_charge_tier4_charging" - - elif [ $percentage -ge 20 ]; then - printf "$icon_charge_tier3_charging" - - elif [ $percentage -gt 5 ]; then - printf "$icon_charge_tier2_charging" - - else - printf "$icon_charge_tier1_charging" # minimun - fi - - else + + if [ $status == 'charging' ]; then - if [ $percentage -ge 95 -o "$percentage" == "" ]; then - # if percentage is empty, assume it's a desktop # maximum - printf "$icon_charge_tier8" + if [ $percentage -ge 95 -o "$percentage" == "" ]; then + # if percentage is empty, assume it's a desktop + printf "$icon_charge_tier8_charging" - elif [ $percentage -ge 80 ]; then - printf "$icon_charge_tier7" + elif [ $percentage -ge 80 ]; then + printf "$icon_charge_tier7_charging" - elif [ $percentage -ge 65 ]; then - printf "$icon_charge_tier6" + elif [ $percentage -ge 65 ]; then + printf "$icon_charge_tier6_charging" - elif [ $percentage -ge 50 ]; then - printf "$icon_charge_tier5" + elif [ $percentage -ge 50 ]; then + printf "$icon_charge_tier5_charging" - elif [ $percentage -ge 35 ]; then - printf "$icon_charge_tier4" + elif [ $percentage -ge 35 ]; then + printf "$icon_charge_tier4_charging" - elif [ $percentage -ge 20 ]; then - printf "$icon_charge_tier3" + elif [ $percentage -ge 20 ]; then + printf "$icon_charge_tier3_charging" - elif [ $percentage -gt 5 ]; then - printf "$icon_charge_tier2" + elif [ $percentage -gt 5 ]; then + printf "$icon_charge_tier2_charging" - else - printf "$icon_charge_tier1" # minimun - fi - fi -} + else + printf "$icon_charge_tier1_charging" + fi + + else + + if [ $percentage -ge 95 -o "$percentage" == "" ]; then + # if percentage is empty, assume it's a desktop + printf "$icon_charge_tier8" + elif [ $percentage -ge 80 ]; then + printf "$icon_charge_tier7" + elif [ $percentage -ge 65 ]; then + printf "$icon_charge_tier6" + + elif [ $percentage -ge 50 ]; then + printf "$icon_charge_tier5" + + elif [ $percentage -ge 35 ]; then + printf "$icon_charge_tier4" + + elif [ $percentage -ge 20 ]; then + printf "$icon_charge_tier3" + + elif [ $percentage -gt 5 ]; then + printf "$icon_charge_tier2" + + else + printf "$icon_charge_tier1" + fi + fi +} main() { From 19fe6dac35dd06664484b44693e78877252ba144 Mon Sep 17 00:00:00 2001 From: Ethan <96821054+Ethanol48@users.noreply.github.com> Date: Wed, 18 Jan 2023 22:12:31 +0100 Subject: [PATCH 03/10] implementation of icon_live --- battery.tmux | 2 ++ 1 file changed, 2 insertions(+) diff --git a/battery.tmux b/battery.tmux index 0c666b8..a264c6f 100755 --- a/battery.tmux +++ b/battery.tmux @@ -17,6 +17,7 @@ battery_interpolation=( "\#{battery_icon_status}" "\#{battery_percentage}" "\#{battery_remain}" + "\#{battery_icon_live}" ) 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_icon_live.sh)" ) set_tmux_option() { From 59ff941bce5c35b2e14087cdd2d1d92c01559ece Mon Sep 17 00:00:00 2001 From: Ethan <96821054+Ethanol48@users.noreply.github.com> Date: Wed, 18 Jan 2023 22:13:11 +0100 Subject: [PATCH 04/10] renaming to icon_live --- scripts/{battery_icon_plus_status.sh => battery_icon_live.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{battery_icon_plus_status.sh => battery_icon_live.sh} (100%) diff --git a/scripts/battery_icon_plus_status.sh b/scripts/battery_icon_live.sh similarity index 100% rename from scripts/battery_icon_plus_status.sh rename to scripts/battery_icon_live.sh From c03a9e4adf9be5a7c431c06f15882a97f45bc7b8 Mon Sep 17 00:00:00 2001 From: Ethan <96821054+Ethanol48@users.noreply.github.com> Date: Wed, 18 Jan 2023 22:19:44 +0100 Subject: [PATCH 05/10] Updating README updating for icon_live --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5bf4775..82a1e94 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,8 @@ set -g status-right '#{battery_status_bg} Batt: #{battery_icon} #{battery_percen - `#{battery_icon_charge}` - will display a battery charge icon - `#{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_remain}` - will show remaining time of battery charge + - `#{battery_icon_live}` - will show the batery icon depending if the device is charging\* \* These format strings can be further customized via options as described below. From 4945072e6240afe177e59a93d1c53d9e70791fbb Mon Sep 17 00:00:00 2001 From: Ethan <96821054+Ethanol48@users.noreply.github.com> Date: Wed, 18 Jan 2023 22:20:17 +0100 Subject: [PATCH 06/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 82a1e94..3fc9ddc 100644 --- a/README.md +++ b/README.md @@ -69,7 +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_icon_live}` - will show the batery icon depending if the device is charging\* + - `#{battery_icon_live}` - will show the batery icon depending if the device is charging\ \* These format strings can be further customized via options as described below. From 8549da66ea4c389a5fd538c7168d397550e3f5f1 Mon Sep 17 00:00:00 2001 From: Ethan <96821054+Ethanol48@users.noreply.github.com> Date: Wed, 18 Jan 2023 22:24:16 +0100 Subject: [PATCH 07/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3fc9ddc..b2a87d2 100644 --- a/README.md +++ b/README.md @@ -69,7 +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_icon_live}` - will show the batery icon depending if the device is charging\ + - `#{battery_icon_live}` - will show the a charging battery icon or a normal one depending if the device is charging\ \* These format strings can be further customized via options as described below. From 61cab1dcb81cdadac58ea994206ddca48ab00fc9 Mon Sep 17 00:00:00 2001 From: Ethan <96821054+Ethanol48@users.noreply.github.com> Date: Wed, 18 Jan 2023 22:31:45 +0100 Subject: [PATCH 08/10] renaming variables --- scripts/battery_icon_live.sh | 98 ++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/scripts/battery_icon_live.sh b/scripts/battery_icon_live.sh index 39ba13a..614dbcc 100644 --- a/scripts/battery_icon_live.sh +++ b/scripts/battery_icon_live.sh @@ -13,46 +13,46 @@ source "$CURRENT_DIR/helpers.sh" # unfortunately there's a mismatch there are no more available charging icons, there are two that are duplicated in the variables # script global variables -icon_charge_tier8='' -icon_charge_tier7='' -icon_charge_tier6='' -icon_charge_tier5='' -icon_charge_tier4='' -icon_charge_tier3='' -icon_charge_tier2='' -icon_charge_tier1='' +icon_live_charge_tier8='' +icon_live_charge_tier7='' +icon_live_charge_tier6='' +icon_live_charge_tier5='' +icon_live_charge_tier4='' +icon_live_charge_tier3='' +icon_live_charge_tier2='' +icon_live_charge_tier1='' # script default variables -icon_charge_tier8_default='' -icon_charge_tier7_default='' -icon_charge_tier6_default='' -icon_charge_tier5_default='' -icon_charge_tier4_default='' -icon_charge_tier3_default='' -icon_charge_tier2_default='' -icon_charge_tier1_default='' - -icon_charge_tier8_charging='' -icon_charge_tier7_charging='' -icon_charge_tier6_charging='' -icon_charge_tier5_charging='' -icon_charge_tier4_charging='' -icon_charge_tier3_charging='' -icon_charge_tier2_charging='' -icon_charge_tier1_charging='' +icon_live_charge_tier8_default='' +icon_live_charge_tier7_default='' +icon_live_charge_tier6_default='' +icon_live_charge_tier5_default='' +icon_live_charge_tier4_default='' +icon_live_charge_tier3_default='' +icon_live_charge_tier2_default='' +icon_live_charge_tier1_default='' + +icon_live_charge_tier8_charging='' +icon_live_charge_tier7_charging='' +icon_live_charge_tier6_charging='' +icon_live_charge_tier5_charging='' +icon_live_charge_tier4_charging='' +icon_live_charge_tier3_charging='' +icon_live_charge_tier2_charging='' +icon_live_charge_tier1_charging='' # icons are set as script global variables get_icon_charge_settings() { - icon_charge_tier8=$(get_tmux_option "@batt_icon_charge_tier8" "$icon_charge_tier8_default") - icon_charge_tier7=$(get_tmux_option "@batt_icon_charge_tier7" "$icon_charge_tier7_default") - icon_charge_tier6=$(get_tmux_option "@batt_icon_charge_tier6" "$icon_charge_tier6_default") - icon_charge_tier5=$(get_tmux_option "@batt_icon_charge_tier5" "$icon_charge_tier5_default") - icon_charge_tier4=$(get_tmux_option "@batt_icon_charge_tier4" "$icon_charge_tier4_default") - icon_charge_tier3=$(get_tmux_option "@batt_icon_charge_tier3" "$icon_charge_tier3_default") - icon_charge_tier2=$(get_tmux_option "@batt_icon_charge_tier2" "$icon_charge_tier2_default") - icon_charge_tier1=$(get_tmux_option "@batt_icon_charge_tier1" "$icon_charge_tier1_default") + icon_live_charge_tier8=$(get_tmux_option "@batt_icon_live_charge_tier8" "$icon_live_charge_tier8_default") + icon_live_charge_tier7=$(get_tmux_option "@batt_icon_live_charge_tier7" "$icon_live_charge_tier7_default") + icon_live_charge_tier6=$(get_tmux_option "@batt_icon_live_charge_tier6" "$icon_live_charge_tier6_default") + icon_live_charge_tier5=$(get_tmux_option "@batt_icon_live_charge_tier5" "$icon_live_charge_tier5_default") + icon_live_charge_tier4=$(get_tmux_option "@batt_icon_live_charge_tier4" "$icon_live_charge_tier4_default") + icon_live_charge_tier3=$(get_tmux_option "@batt_icon_live_charge_tier3" "$icon_live_charge_tier3_default") + icon_live_charge_tier2=$(get_tmux_option "@batt_icon_live_charge_tier2" "$icon_live_charge_tier2_default") + icon_live_charge_tier1=$(get_tmux_option "@batt_icon_live_charge_tier1" "$icon_live_charge_tier1_default") } @@ -64,56 +64,56 @@ print_icon_charge_plus_status() { if [ $percentage -ge 95 -o "$percentage" == "" ]; then # if percentage is empty, assume it's a desktop - printf "$icon_charge_tier8_charging" + printf "$icon_live_charge_tier8_charging" elif [ $percentage -ge 80 ]; then - printf "$icon_charge_tier7_charging" + printf "$icon_live_charge_tier7_charging" elif [ $percentage -ge 65 ]; then - printf "$icon_charge_tier6_charging" + printf "$icon_live_charge_tier6_charging" elif [ $percentage -ge 50 ]; then - printf "$icon_charge_tier5_charging" + printf "$icon_live_charge_tier5_charging" elif [ $percentage -ge 35 ]; then - printf "$icon_charge_tier4_charging" + printf "$icon_live_charge_tier4_charging" elif [ $percentage -ge 20 ]; then - printf "$icon_charge_tier3_charging" + printf "$icon_live_charge_tier3_charging" elif [ $percentage -gt 5 ]; then - printf "$icon_charge_tier2_charging" + printf "$icon_live_charge_tier2_charging" else - printf "$icon_charge_tier1_charging" + printf "$icon_live_charge_tier1_charging" fi else if [ $percentage -ge 95 -o "$percentage" == "" ]; then # if percentage is empty, assume it's a desktop - printf "$icon_charge_tier8" + printf "$icon_live_charge_tier8" elif [ $percentage -ge 80 ]; then - printf "$icon_charge_tier7" + printf "$icon_live_charge_tier7" elif [ $percentage -ge 65 ]; then - printf "$icon_charge_tier6" + printf "$icon_live_charge_tier6" elif [ $percentage -ge 50 ]; then - printf "$icon_charge_tier5" + printf "$icon_live_charge_tier5" elif [ $percentage -ge 35 ]; then - printf "$icon_charge_tier4" + printf "$icon_live_charge_tier4" elif [ $percentage -ge 20 ]; then - printf "$icon_charge_tier3" + printf "$icon_live_charge_tier3" elif [ $percentage -gt 5 ]; then - printf "$icon_charge_tier2" + printf "$icon_live_charge_tier2" else - printf "$icon_charge_tier1" + printf "$icon_live_charge_tier1" fi fi } From 2093ee0499953fc4588323cf028ce524e6f5e420 Mon Sep 17 00:00:00 2001 From: Ethan <96821054+Ethanol48@users.noreply.github.com> Date: Wed, 18 Jan 2023 22:40:50 +0100 Subject: [PATCH 09/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2a87d2..5c08892 100644 --- a/README.md +++ b/README.md @@ -69,7 +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_icon_live}` - will show the a charging battery icon or a normal one depending if the device is charging\ + - `#{battery_icon_live}` - will show the a charging battery icon or a normal one depending if the device is charging \* These format strings can be further customized via options as described below. From 9b6d3a18b53c8450c9217c5c121d84b33257e32a Mon Sep 17 00:00:00 2001 From: Ethan <96821054+Ethanol48@users.noreply.github.com> Date: Wed, 18 Jan 2023 22:45:17 +0100 Subject: [PATCH 10/10] Update battery_icon_live.sh --- scripts/battery_icon_live.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/battery_icon_live.sh b/scripts/battery_icon_live.sh index 614dbcc..afa1b03 100644 --- a/scripts/battery_icon_live.sh +++ b/scripts/battery_icon_live.sh @@ -11,6 +11,7 @@ source "$CURRENT_DIR/helpers.sh" # 100, 90, 80, 70, 60, 50, 40, 20, 10 % # unfortunately there's a mismatch there are no more available charging icons, there are two that are duplicated in the variables +# this requires a patched font (nerdfont) # script global variables icon_live_charge_tier8=''