Skip to content

Commit

Permalink
Merge branch 'main' into bubble-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
embe221ed authored Nov 8, 2023
2 parents 0d81cc5 + c217c5c commit ee37268
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ segments/np_mpd
segments/xkb_layout
*.swp

# ignore all themes, except default.sh and bubble.sh

# ignore all themes, except for the built-in ones. User themes should be put in `~/.config/tmux-powerline/themes/
themes/*
!themes/default.sh
!themes/bubble.sh
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ Laptop mode: a battery segment.

![right-status, weather and battery](img/right-status_weather_battery.png)

# :raised_hands: Co-maintainer wanted!
Do you enjoy hacking tmux and your shell? As less time is becoming available for me to keep up with the incoming PRs and maintainace, I would be happy to add someone as a co-maintainer.

Your profile could look like:
* Use tmux regularly, configured with tmux-powerline.
* Experience in writing maintainable, correct and understandable bash scripts, or willing to become proficient. Some prior knowledge would be needed.
* Understanding of portability of shell scripting (POSIX) e.g. that some command line swithces to common tools might differ on Linux to BSD or macOS.
* When following the code paths from [powerline.sh](powerline.sh) to [lib/powerline.sh](lib/powerline.sh) understand how the powerline is rendered.
* Understand how the segment's different functions are called and expected to behave.
* Understand how themes and the config file works.


Is this you? Contact me at [erikw.me/contact](https://erikw.me/contact/) if you're interested!


# Requirements
Requirements for the lib to work are:
* `tmux -V` >= 2.1
Expand Down
42 changes: 26 additions & 16 deletions segments/battery.sh
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="󰚥"

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"
}
Expand All @@ -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)
Expand All @@ -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
}

Expand All @@ -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
Expand Down Expand Up @@ -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 ))
Expand All @@ -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)"

}

0 comments on commit ee37268

Please sign in to comment.