Skip to content

Commit ee37268

Browse files
authored
Merge branch 'main' into bubble-theme
2 parents 0d81cc5 + c217c5c commit ee37268

File tree

3 files changed

+43
-17
lines changed

3 files changed

+43
-17
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ segments/np_mpd
22
segments/xkb_layout
33
*.swp
44

5-
# ignore all themes, except default.sh and bubble.sh
5+
6+
# ignore all themes, except for the built-in ones. User themes should be put in `~/.config/tmux-powerline/themes/
67
themes/*
78
!themes/default.sh
89
!themes/bubble.sh

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ Laptop mode: a battery segment.
7575

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

78+
# :raised_hands: Co-maintainer wanted!
79+
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.
80+
81+
Your profile could look like:
82+
* Use tmux regularly, configured with tmux-powerline.
83+
* Experience in writing maintainable, correct and understandable bash scripts, or willing to become proficient. Some prior knowledge would be needed.
84+
* 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.
85+
* When following the code paths from [powerline.sh](powerline.sh) to [lib/powerline.sh](lib/powerline.sh) understand how the powerline is rendered.
86+
* Understand how the segment's different functions are called and expected to behave.
87+
* Understand how themes and the config file works.
88+
89+
90+
Is this you? Contact me at [erikw.me/contact](https://erikw.me/contact/) if you're interested!
91+
92+
7893
# Requirements
7994
Requirements for the lib to work are:
8095
* `tmux -V` >= 2.1

segments/battery.sh

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# 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.
22

33
TMUX_POWERLINE_SEG_BATTERY_TYPE_DEFAULT="percentage"
4-
TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS_DEFAULT=5
4+
TMUX_POWERLINE_SEG_BATTERY_NUM_BATTERIES_DEFAULT=5
55

6-
HEART_FULL=""
7-
HEART_EMPTY=""
6+
BATTERY_FULL="󱊣"
7+
BATTERY_MED="󱊢"
8+
BATTERY_EMPTY="󱊡"
9+
BATTERY_CHARGE="󰂄"
10+
ADAPTER="󰚥"
811

912
generate_segmentrc() {
1013
read -d '' rccontents << EORC
1114
# How to display battery remaining. Can be {percentage, cute}.
1215
export TMUX_POWERLINE_SEG_BATTERY_TYPE="${TMUX_POWERLINE_SEG_BATTERY_TYPE_DEFAULT}"
1316
# How may hearts to show if cute indicators are used.
14-
export TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS="${TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS_DEFAULT}"
17+
export TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS="${TMUX_POWERLINE_SEG_BATTERY_NUM_BATTERIES_DEFAULT}"
1518
EORC
1619
echo "$rccontents"
1720
}
@@ -23,11 +26,14 @@ run_segment() {
2326
else
2427
battery_status=$(__battery_linux)
2528
fi
26-
[ -z "$battery_status" ] && return
29+
if [ -z "$battery_status" ]; then
30+
echo "$ADAPTER "
31+
return
32+
fi
2733

2834
case "$TMUX_POWERLINE_SEG_BATTERY_TYPE" in
2935
"percentage")
30-
output="${HEART_FULL} ${battery_status}%"
36+
output="${battery_status}%"
3137
;;
3238
"cute")
3339
output=$(__cutinate $battery_status)
@@ -42,7 +48,7 @@ __process_settings() {
4248
export TMUX_POWERLINE_SEG_BATTERY_TYPE="${TMUX_POWERLINE_SEG_BATTERY_TYPE_DEFAULT}"
4349
fi
4450
if [ -z "$TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS" ]; then
45-
export TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS="${TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS_DEFAULT}"
51+
export TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS="${TMUX_POWERLINE_SEG_BATTERY_NUM_BATTERIES_DEFAULT}"
4652
fi
4753
}
4854

@@ -63,17 +69,21 @@ __battery_osx() {
6369
export fully_charged=$value;;
6470
esac
6571
if [[ -n $maxcap && -n $curcap && -n $extconnect ]]; then
66-
if [[ "$curcap" == "$maxcap" || "$fully_charged" == "Yes" && $extconnect == "Yes" ]]; then
72+
charge=`pmset -g batt | grep -o "[0-9][0-9]*\%" | rev | cut -c 2- | rev`
73+
if [[ ("$fully_charged" == "Yes" || $charge -eq 100) && $extconnect == "Yes" ]]; then
6774
return
6875
fi
69-
charge=`pmset -g batt | grep -o "[0-9][0-9]*\%" | rev | cut -c 2- | rev`
7076
if [[ "$extconnect" == "Yes" ]]; then
71-
echo "$charge"
77+
echo "$BATTERY_CHARGE $charge"
7278
else
7379
if [[ $charge -lt 50 ]]; then
74-
echo -n "#[fg=red]"
80+
echo -n "#[fg=#ff0000]"
81+
echo "$BATTERY_EMPTY $charge"
82+
elif [[ $charge -lt 80 ]]; then
83+
echo "$BATTERY_MED $charge"
84+
else
85+
echo "$BATTERY_FULL $charge"
7586
fi
76-
echo "$charge"
7787
fi
7888
break
7989
fi
@@ -129,9 +139,9 @@ __battery_osx() {
129139

130140
for i in `seq $TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS`; do
131141
if [ $perc -lt 99 ]; then
132-
echo -n $HEART_EMPTY
142+
echo -n $BATTERY_EMPTY
133143
else
134-
echo -n $HEART_FULL
144+
echo -n $BATTERY_FULL
135145
fi
136146
echo -n " "
137147
perc=$(( $perc + $inc ))
@@ -144,10 +154,10 @@ __battery_osx() {
144154
if [ $bn -gt $bf ]; then
145155
bn=$bf
146156
fi
147-
echo $(( 100 * $bn / $bf ))
157+
echo "$BATTERY_MED $(( 100 * $bn / $bf ))"
148158
}
149159

150160
__freebsd_get_bat() {
151-
echo "$(sysctl -n hw.acpi.battery.life)"
161+
echo "$BATTER_MED $(sysctl -n hw.acpi.battery.life)"
152162

153163
}

0 commit comments

Comments
 (0)