-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
# LICENSE This code is not under the same license as the rest of the project as it's "stolen". It's cloned from https://github.com/richoH/dotfiles/blob/master/bin/battery and just some modifications are done so it works for my laptop. Check that URL for more recent versions. | ||
|
||
TMUX_POWERLINE_SEG_BATTERY_TYPE_DEFAULT="percentage" | ||
TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS_DEFAULT=5 | ||
TMUX_POWERLINE_SEG_BATTERY_NUM_BATTERIES_DEFAULT=5 | ||
|
||
HEART_FULL="♥" | ||
HEART_EMPTY="♡" | ||
BATTERY_FULL="" | ||
BATTERY_MED="" | ||
BATTERY_EMPTY="" | ||
BATTERY_CHARGE="" | ||
ADAPTER="" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
xx4h
Collaborator
|
||
|
||
generate_segmentrc() { | ||
read -d '' rccontents << EORC | ||
# How to display battery remaining. Can be {percentage, cute}. | ||
export TMUX_POWERLINE_SEG_BATTERY_TYPE="${TMUX_POWERLINE_SEG_BATTERY_TYPE_DEFAULT}" | ||
# How may hearts to show if cute indicators are used. | ||
export TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS="${TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS_DEFAULT}" | ||
export TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS="${TMUX_POWERLINE_SEG_BATTERY_NUM_BATTERIES_DEFAULT}" | ||
EORC | ||
echo "$rccontents" | ||
} | ||
|
@@ -23,11 +26,14 @@ run_segment() { | |
else | ||
battery_status=$(__battery_linux) | ||
fi | ||
[ -z "$battery_status" ] && return | ||
if [ -z "$battery_status" ]; then | ||
echo "$ADAPTER " | ||
return | ||
fi | ||
|
||
case "$TMUX_POWERLINE_SEG_BATTERY_TYPE" in | ||
"percentage") | ||
output="${HEART_FULL} ${battery_status}%" | ||
output="${battery_status}%" | ||
;; | ||
"cute") | ||
output=$(__cutinate $battery_status) | ||
|
@@ -42,7 +48,7 @@ __process_settings() { | |
export TMUX_POWERLINE_SEG_BATTERY_TYPE="${TMUX_POWERLINE_SEG_BATTERY_TYPE_DEFAULT}" | ||
fi | ||
if [ -z "$TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS" ]; then | ||
export TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS="${TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS_DEFAULT}" | ||
export TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS="${TMUX_POWERLINE_SEG_BATTERY_NUM_BATTERIES_DEFAULT}" | ||
fi | ||
} | ||
|
||
|
@@ -63,17 +69,21 @@ __battery_osx() { | |
export fully_charged=$value;; | ||
esac | ||
if [[ -n $maxcap && -n $curcap && -n $extconnect ]]; then | ||
if [[ "$curcap" == "$maxcap" || "$fully_charged" == "Yes" && $extconnect == "Yes" ]]; then | ||
charge=`pmset -g batt | grep -o "[0-9][0-9]*\%" | rev | cut -c 2- | rev` | ||
if [[ ("$fully_charged" == "Yes" || $charge -eq 100) && $extconnect == "Yes" ]]; then | ||
return | ||
fi | ||
charge=`pmset -g batt | grep -o "[0-9][0-9]*\%" | rev | cut -c 2- | rev` | ||
if [[ "$extconnect" == "Yes" ]]; then | ||
echo "$charge" | ||
echo "$BATTERY_CHARGE $charge" | ||
else | ||
if [[ $charge -lt 50 ]]; then | ||
echo -n "#[fg=red]" | ||
echo -n "#[fg=#ff0000]" | ||
echo "$BATTERY_EMPTY $charge" | ||
elif [[ $charge -lt 80 ]]; then | ||
echo "$BATTERY_MED $charge" | ||
else | ||
echo "$BATTERY_FULL $charge" | ||
fi | ||
echo "$charge" | ||
fi | ||
break | ||
fi | ||
|
@@ -129,9 +139,9 @@ __battery_osx() { | |
|
||
for i in `seq $TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS`; do | ||
if [ $perc -lt 99 ]; then | ||
echo -n $HEART_EMPTY | ||
echo -n $BATTERY_EMPTY | ||
else | ||
echo -n $HEART_FULL | ||
echo -n $BATTERY_FULL | ||
fi | ||
echo -n " " | ||
perc=$(( $perc + $inc )) | ||
|
@@ -144,10 +154,10 @@ __battery_osx() { | |
if [ $bn -gt $bf ]; then | ||
bn=$bf | ||
fi | ||
echo $(( 100 * $bn / $bf )) | ||
echo "$BATTERY_MED $(( 100 * $bn / $bf ))" | ||
} | ||
|
||
__freebsd_get_bat() { | ||
echo "$(sysctl -n hw.acpi.battery.life)" | ||
echo "$BATTER_MED $(sysctl -n hw.acpi.battery.life)" | ||
|
||
} |
2 comments
on commit cab0747
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit broke cute
because of the $BATTERY_MED
in the _get_bat
functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you open an Issue for that?
What are these characters? My computer shows
?
boxes for all of them :/