diff --git a/herbstluftwm/panel.sh b/herbstluftwm/panel.sh index d1dd1e1..4d563d4 100755 --- a/herbstluftwm/panel.sh +++ b/herbstluftwm/panel.sh @@ -118,6 +118,33 @@ append_percent_icon() { segment_text="$segment_text$bgend%{O5}" } +append_battery_icon() { + local pct=$1 + segment_text="$segment_text$bglight" + if (( pct < 10 )); then + segment_text="$segment_text" + elif (( pct < 20 )); then + segment_text="$segment_text" + elif (( pct < 30 )); then + segment_text="$segment_text" + elif (( pct < 40 )); then + segment_text="$segment_text" + elif (( pct < 50 )); then + segment_text="$segment_text" + elif (( pct < 60 )); then + segment_text="$segment_text" + elif (( pct < 70 )); then + segment_text="$segment_text" + elif (( pct < 80 )); then + segment_text="$segment_text" + elif (( pct < 90 )); then + segment_text="$segment_text" + else + segment_text="$segment_text" + fi + segment_text="$segment_text$bgend%{O5}" +} + segment_tags() { local monitor=$1 local tags @@ -340,8 +367,6 @@ segment_battery() { # battery status (charging/charged/etc) batstat="$(upower --show-info $(upower --enumerate | grep -i 'BAT') | grep -E "state" | awk '{print $2}')" - baticon='B' - if (( battpct > 80 )); then batclass=$fggreen elif (( battpct < 20 )); then @@ -350,17 +375,17 @@ segment_battery() { batclass=$fgblue fi - if [ "$batstat" = "fully-charged" ]; then - baticon="${baticon}%{O3}⇈" - elif [ "$batstat" = "discharging" ]; then - baticon="${baticon}%{O3}↓"; + segment_text="$batclass" + + if [ "$batstat" = "charging" ]; then + segment_text="${segment_text}" + elif [ "$batstat" = "fully-charged" ]; then + segment_text="${segment_text}" else - baticon="${baticon}%{O3}↑"; + append_battery_icon "$battpct" fi - segment_text="$batclass" - append_percent_icon "$battpct" - segment_text="$segment_text$baticon$fgend" + segment_text="$segment_text$fgend" else segment_text="$fggreenﮣ$fgend" fi