# Looking for the battery bar I used to have



## museur (May 15, 2020)

I've used to use a simple bar for status of battery on my laptop. It was a simple monitor wide bar, buttom of the screen indicating percentage with colors that displayed information when you hover your pointer on it.

I do not remember what the package was named. I tried the ones I thought may be... Does anyone know what was it called?

Thank you!


----------



## SirDice (May 15, 2020)

Can you remember the windows manager or desktop environment you were running? It may have been part of those. Or at least it might provide some clues.


----------



## T-Daemon (May 15, 2020)

museur said:


> I tried the ones I thought may be...


Which ones? So they can be excluded.

Try following keywords and _site_ modifier in a search engine: _battery monitor site:freshports.org_


----------



## George (May 15, 2020)

Vermaden used dzen2 as a status bar. It would display the battery life.








						FreeBSD Desktop – Part 13 – Configuration – Dzen2
					

Time for real configuration of the status bar. In today’s article of the FreeBSD Desktop series I will describe how to configure the Dzen2. You may want to check other articles in the FreeBSD…




					vermaden.wordpress.com
				




`pkg search bat` returns a couple of packages, e.g. batmon, battmond, battray, dsbbatmon, xbatt, xfce4-battery-plugin


----------



## museur (May 15, 2020)

I was using bspwm and i still do. I've tried those returning from searching bat and battery, it may be xbattbar but I couldn't install it.


----------



## bookwormep (May 15, 2020)

There is a battery monitor on 'tint2', but you have to manually configure the default settings.
(Especially if you want color text to appear.)


----------



## museur (May 15, 2020)

I don't really see the point of using a bar except battery status. I'll check it out, thanks.


----------



## memreflect (May 15, 2020)

If I remember correctly, x11/polybar also comes with a battery status monitor.  If you've used the x11-wm/i3 window manager before, i3bar comes with it, and it has a battery monitor.  Whether they work in FreeBSD or not, I have no idea, but those were the two I used when I used Linux.


----------



## T-Daemon (May 15, 2020)

museur said:


> I was using bspwm and i still do.


That might interest you:








						GitHub - odknt/bspwmbar: A lightweight status bar for bspwm.
					

A lightweight status bar for bspwm. Contribute to odknt/bspwmbar development by creating an account on GitHub.




					github.com
				






museur said:


> it may be xbattbar but I couldn't install it.


That port expired, before that, it was marked _BROKEN: unfetchable_.


----------



## aragats (May 15, 2020)

You can write your own script to display a battery bar using x11/dzen2.
I'm using a simple one, but you can easily extend it by adding extra info and processing mouse clicks:
	
	



```
#!/bin/sh

BG=midnightblue  # dzen backgrounad
FG=white         # dzen foreground
W=72             # width of the dzen bar
SW=100           # width of slave window - not used yet
H=22             # height of the dzen bar
GW=24            # gauge width
GH=8             # gauge height
GBG='#9999dd'    # gauge background color
Y=0              # y position
X=1000           # x position
FN="dejaVu sans mono:pixelsize=12"

STAT_CMD='acpiconf -i 0'
TMP_FILE=/tmp/battery.stat

CRT_BAT=15        # critical percentage of battery
LOW_BAT=25        # low percentage of battery
LOW_COL='#ff4747' # color when battery is low
NOR_COL='#22aa22' # normal gauge color
CHG_COL='#007eff' # color when battery is charging
TIME_INT=2        # time intervall in seconds

while true; do
        $STAT_CMD > $TMP_FILE
        STATE=`sed -n 's/State:[^a-z]*\(.*\)/\1/p' $TMP_FILE `
        RCAP=`sed -n 's/Remaining\ capacity:[^0-9]*\([0-9]*\)[^0-9]*/\1/p' $TMP_FILE `

        if [ $STATE != "discharging" ] ; then
                GFG=$CHG_COL
        elif [ $RCAP -le $LOW_BAT ] ; then
                GFG=$LOW_COL
                # suspend if very low:
                if [ $RCAP -le $CRIT_BAT ] ; then
                        sudo acpiconf -s 3
                fi
        else
                GFG=$NOR_COL
        fi

        echo -n \ $RCAP\%
        eval echo -n $RCAP | gdbar -s o -h $GH -w $GW -fg $GFG -bg $GBG | sed 's/^\ */\ /'

        sleep $TIME_INT;
done | dzen2 -x $X -y $Y -tw $W -h $H -fg $FG -bg $BG -fn "$FN" -e ''
```


----------

