forked from tmux-plugins/tmux-battery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Patch for Live Battery Status from tmux-plugins/pull/106
- Loading branch information
Showing
3 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!/usr/bin/env bash | ||
|
||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
source "$CURRENT_DIR/helpers.sh" | ||
|
||
# icons charging , , , , , , | ||
# 100, 90, 80, 60, 40, 30, 20 % | ||
|
||
# icons normal , , , , , , , , | ||
# 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='' | ||
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_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_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") | ||
} | ||
|
||
|
||
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 | ||
printf "$icon_live_charge_tier8_charging" | ||
|
||
elif [ $percentage -ge 80 ]; then | ||
printf "$icon_live_charge_tier7_charging" | ||
|
||
elif [ $percentage -ge 65 ]; then | ||
printf "$icon_live_charge_tier6_charging" | ||
|
||
elif [ $percentage -ge 50 ]; then | ||
printf "$icon_live_charge_tier5_charging" | ||
|
||
elif [ $percentage -ge 35 ]; then | ||
printf "$icon_live_charge_tier4_charging" | ||
|
||
elif [ $percentage -ge 20 ]; then | ||
printf "$icon_live_charge_tier3_charging" | ||
|
||
elif [ $percentage -gt 5 ]; then | ||
printf "$icon_live_charge_tier2_charging" | ||
|
||
else | ||
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_live_charge_tier8" | ||
|
||
elif [ $percentage -ge 80 ]; then | ||
printf "$icon_live_charge_tier7" | ||
|
||
elif [ $percentage -ge 65 ]; then | ||
printf "$icon_live_charge_tier6" | ||
|
||
elif [ $percentage -ge 50 ]; then | ||
printf "$icon_live_charge_tier5" | ||
|
||
elif [ $percentage -ge 35 ]; then | ||
printf "$icon_live_charge_tier4" | ||
|
||
elif [ $percentage -ge 20 ]; then | ||
printf "$icon_live_charge_tier3" | ||
|
||
elif [ $percentage -gt 5 ]; then | ||
printf "$icon_live_charge_tier2" | ||
|
||
else | ||
printf "$icon_live_charge_tier1" | ||
fi | ||
fi | ||
} | ||
|
||
|
||
main() { | ||
get_icon_charge_settings | ||
print_icon_charge_plus_status | ||
} | ||
|
||
main |