You are not logged in.

#1 2024-12-11 16:05:19

FrancisArcher_60
Member
Registered: 2024-09-05
Posts: 54

Polyabar battery module don't show prefix

I want to the battery module shows this: "BAT 50%" for example, only the percentage, not "charging" or "full" icons.

[module/battery]
type = internal/battery
battery = BAT1
format-prefix = "BAT "
format-prefix-foreground = ${colors.primary}
label = %percentage%%

This configuration only shows the percentage and not the "BAT" prefix.

Offline

#2 2024-12-11 19:59:45

pvtvega
Member
Registered: 2024-11-25
Posts: 91

Re: Polyabar battery module don't show prefix

Can you post your full config?

Offline

#3 2024-12-11 20:09:48

FrancisArcher_60
Member
Registered: 2024-09-05
Posts: 54

Re: Polyabar battery module don't show prefix

;==========================================================
;
;
;   ██████╗  ██████╗ ██╗  ██╗   ██╗██████╗  █████╗ ██████╗
;   ██╔══██╗██╔═══██╗██║  ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗
;   ██████╔╝██║   ██║██║   ╚████╔╝ ██████╔╝███████║██████╔╝
;   ██╔═══╝ ██║   ██║██║    ╚██╔╝  ██╔══██╗██╔══██║██╔══██╗
;   ██║     ╚██████╔╝███████╗██║   ██████╔╝██║  ██║██║  ██║
;   ╚═╝      ╚═════╝ ╚══════╝╚═╝   ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝
;
;
;   To learn more about how to configure Polybar
;   go to https://github.com/polybar/polybar
;
;   The README contains a lot of information
;
;==========================================================

[colors]
background = #000000
background-alt = #D30000
foreground = #C5C8C6
primary = #FF0000
secondary = #8ABEB7;
alert = #A54242
disabled = #707880
line = #780000

[bar/example]
width = 99.2673%
height = 20pt
radius = 0

offset-x = 0.4%
offset-y = 0.7%

; dpi = 96

background = ${colors.background}
foreground = ${colors.foreground}

line-size = 3pt

border-size = 0pt
border-color = #00000000

padding-left = 0
padding-right = 1

module-margin = 1

separator = |
separator-foreground = ${colors.disabled}
 
font-0 = TickingTimebombBB:size=17;4

modules-left = xworkspaces
modules-right = battery pulseaudio memory cpu date

cursor-click = pointer
cursor-scroll = ns-resize

enable-ipc = true

; wm-restack = generic
; wm-restack = bspwm
; wm-restack = i3

; override-redirect = true

; This module is not active by default (to enable it, add it to one of the
; modules-* list above).
; Please note that only a single tray can exist at any time. If you launch
; multiple bars with this module, only a single one will show it, the others
; will produce a warning. Which bar gets the module is timing dependent and can
; be quite random.
; For more information, see the documentation page for this module:
; https://polybar.readthedocs.io/en/stable/user/modules/tray.html
[module/systray]
type = internal/tray

format-margin = 8pt
tray-spacing = 16pt

[module/xworkspaces]
type = internal/xworkspaces



label-active = %name%
label-active-background = ${colors.background-alt}
label-active-underline= ${colors.line}
label-active-padding = 1

label-occupied = %name%
label-occupied-padding = 1

label-urgent = %name%
label-urgent-background = ${colors.alert}
label-urgent-padding = 1

label-empty = %name%
label-empty-foreground = ${colors.disabled}
label-empty-padding = 1

[module/battery]
type = internal/battery
battery = BAT1
format-prefix = "BAT "
format-prefix-foreground = ${colors.primary}
label = %percentage%%

[module/pulseaudio]
type = internal/pulseaudio

format-volume-prefix = "VOL "
format-volume-prefix-foreground = ${colors.primary}
format-volume = <label-volume>

label-volume = %percentage%%

label-muted = muted
label-muted-foreground = ${colors.disabled}

[module/memory]
type = internal/memory
interval = 0.5
format-prefix = "RAM "
format-prefix-foreground = ${colors.primary}
label = %percentage_used:2%%

[module/cpu]
type = internal/cpu
interval = 0.5
format-prefix = "CPU "
format-prefix-foreground = ${colors.primary}
label = %percentage:2%%

[module/date]
type = internal/date
interval = 1

date = %H:%M
date-alt = %Y-%m-%d %H:%M:%S

label = %date%
label-foreground = ${colors.primary}

[settings]
screenchange-reload = true
pseudo-transparency = true

; vim:ft=dosini

Offline

#4 2024-12-11 20:43:33

pvtvega
Member
Registered: 2024-11-25
Posts: 91

Re: Polyabar battery module don't show prefix

The problem is that the label key is overriding the entire text output of the battery module. I think you just need to amend it as follows:

[module/battery]
type = internal/battery
battery = BAT1
format = <label>
format-prefix = "BAT "
format-prefix-foreground = ${colors.primary}
label = %percentage%%

Basically you are specifying formatting but then telling it to just output the percentage, which overrides everything else. This should integrate the prefix into the label. not a polybar user myself though, which is why I wanted to see your full config to see if there were any syntax inconsistencies.

Offline

#5 2024-12-11 20:51:31

FrancisArcher_60
Member
Registered: 2024-09-05
Posts: 54

Re: Polyabar battery module don't show prefix

I added this line but don't wokrs, keeps showing only the percentage.

Offline

#6 2024-12-11 20:54:56

pvtvega
Member
Registered: 2024-11-25
Posts: 91

Re: Polyabar battery module don't show prefix

Did you restart polybar after updating the config?

Offline

#7 2024-12-11 21:02:51

FrancisArcher_60
Member
Registered: 2024-09-05
Posts: 54

Re: Polyabar battery module don't show prefix

Yes, I restarted it. I commented all except the prefix but neither shows nothing

[module/battery]
type = internal/battery
;battery = BAT1
;format = <label>
format-prefix = "BAT "
format-prefix-foreground = ${colors.primary}
;label = %percentage%%

Offline

#8 2024-12-11 21:05:39

pvtvega
Member
Registered: 2024-11-25
Posts: 91

Re: Polyabar battery module don't show prefix

Why did you add those comments? They are not correct.

Offline

#9 2024-12-11 21:12:32

FrancisArcher_60
Member
Registered: 2024-09-05
Posts: 54

Re: Polyabar battery module don't show prefix

I thought try to set only the prefix, are temporally comments to not erase those lines.

Offline

#10 2024-12-11 21:15:54

pvtvega
Member
Registered: 2024-11-25
Posts: 91

Re: Polyabar battery module don't show prefix

It's not clear - did you try to modify the battery module the way I recommended above, and then restart Polybar? Or have you only tried it with the comments?

Offline

#11 2024-12-11 21:18:23

FrancisArcher_60
Member
Registered: 2024-09-05
Posts: 54

Re: Polyabar battery module don't show prefix

Yes, I tried it with comments, doesn't show nothing

Offline

#12 2024-12-11 21:21:59

pvtvega
Member
Registered: 2024-11-25
Posts: 91

Re: Polyabar battery module don't show prefix

Try it without comments.

Offline

#13 2024-12-11 21:25:04

FrancisArcher_60
Member
Registered: 2024-09-05
Posts: 54

Re: Polyabar battery module don't show prefix

Is the same what I tried previously. Without comments are the same code what I tried yet.

Offline

#14 2024-12-11 21:38:19

pvtvega
Member
Registered: 2024-11-25
Posts: 91

Re: Polyabar battery module don't show prefix

Having another look through your config and it seems like other modules share almost identical syntax to the battery module. Are those prefixes displaying correctly? Is it only the battery prefix that isn't?

Does the battery display as "50%" for example? Or does it only show the number without the percentage sign?

Offline

#15 2024-12-11 21:55:44

FrancisArcher_60
Member
Registered: 2024-09-05
Posts: 54

Re: Polyabar battery module don't show prefix

In fact, I based to others modules to write the battery, they works, example "RAM 36%", I want the same for battery. And yes shows the number and the percentage sing "77 %"

Offline

#16 2025-01-02 16:01:23

TypeCoercion
Member
Registered: 2025-01-02
Posts: 1

Re: Polyabar battery module don't show prefix

I just came across this issue because I was setting my polybar up as well. You are sort of correct in your implementation- but not quite there. Firstly, I recommend checking out the wiki entry on the battery module. Secondly, you need to specify charging/discharging/full for your format prefixes. It should look something like this:

[module/battery]
type = internal/battery
full-at = 99
low-at = 5
battery = BAT0
adapter = AC
poll-interval = 5
format-charging-prefix = "BAT "
format-charging-prefix-foreground = ${colors.primary}
format-discharging-prefix = "BAT "
format-discharging-prefix-foreground = ${colors.primary}
format-full-prefix = "BAT "
format-full-prefix-foreground = ${colors.primary}
label-charging = %percentage%%
label-discharging = %percentage%%
label-full = FULL

Offline

Board footer

Powered by FluxBB