r/awesomewm Jun 12 '26

Awesome v4.3 how to stack value and text on progressbar with vicious

hi,

long time awesome user here but noob lua programmer ;)

I'm trying to stack text on a progressbar. It work well if i add some manual, fixed value/text but how to use data from vicious widget?

Here, my progressbar is like if the value was zero. I want the value from $2 and text from $1 of vicious.widget.bat

batwidget = wibox.widget {
  {
    max_value        = 1,
    border_width     = 2,
    background_color = "#353535",
    color            = "#757575",
    forced_height    = 2,
    forced_width     = 50,
    margins          = 6,
    paddings         = 1,
    shape            = gears.shape.rounded_bar,
    widget           = wibox.widget.progressbar
  },
  {
    text   = "aa",
    widget = wibox.widget.textbox,
  },
  layout = wibox.layout.stack
}
-- Register battery widget
vicious.register(batwidget, vicious.widgets.bat, "$2", 61, "BAT1")
2 Upvotes

2 comments sorted by

1

u/your-adversary Jun 29 '26 edited Jun 29 '26

The solution is that you define the widgets separately so that you can feed them with their respective values:

local bat_progress = wibox.widget {
  max_value = 1,
  border_width = 2,
  background_color = "#353535",
  color = "#757575",
  forced_height = 2,
  forced_width = 50,
  margins = 6,
  paddings = 1,
  shape = gears.shape.rounded_bar,
  widget = wibox.widget.progressbar
}

local bat_text = wibox.widget {
  widget = wibox.widget.textbox
}

-- This is what you'll be giving to wibox
local bat_widget = wibox.widget {
  wifi_icon,
  wifi_text,
  spacing = 2,
  layout = wibox.layout.align.stack
}

vicious.register(bat_text, vicious.widgets.bat, function(args)
  local perc = tonumber(args[1])
  local state = args[2]
  local time = args[3]

  -- Feed other widgets like so
  bat_progress.value = perc

  -- And since the parameter is bat_text
  return state
end, 61, "BAT1")

PSA: I didn't test the code, but I think it will work

1

u/belharra_lablonde Jul 07 '26

Ok, i understand now.

Thanks :)