0

I need to help to port my 3.5 rc.lua to 4.0. I try to set one progressbar.

It used to be :

mybacklight = awful.widget.progressbar()
mybacklight:set_width(12)
mybacklight:set_height(10)
mybacklight:set_vertical(true)
mybacklight:set_background_color("#131211")
mybacklight:set_border_color(nil)

The new version should be :

mybacklight = wibox.widget.progressbar {
   max_value        = 1,
   value = brightness_new,
   forced_width = 12,
   forced_height = 10,
   background_color = "#131211",
   border_color = nil,
   color = {type="linear", from = {0, 0}, to = {0, 20},
            stops = { {0, "#F6F6F6"}, {0.5, 
            "#bdbdbd"}, {1.0, "#3b3b3b"} } },
   widget           = wibox.widget.progressbar,
   direction        = 'east',
   layout           = wibox.container.rotate
}

The 3.5 version works (no errors) but does no more give the expected result, it should be a vertical progressbar, it is, but the progression itself is horizontal.

The 4.0 version makes no error, except that it takes all the place with red (default ?) colors.

deb2014
  • 89
  • 7

1 Answers1

0

First of all, the imperative syntax isn't gone, you can still do it "the old way". It is fully supported and the declarative one is "compiled to" the old one.

Now, to answer the question, the code should look like (untested):

mybacklight = wibox.widget {
   {
       max_value        = 1,
       value            = brightness_new,
       background_color = "#131211",
       color            = {type="linear", from = {0, 0}, to = {0, 20},
            stops = { {0, "#F6F6F6"}, {0.5, 
            "#bdbdbd"}, {1.0, "#3b3b3b"} }
       },
       widget           = wibox.widget.progressbar,
   },
   forced_width     = 12,
   forced_height    = 10,
   direction        = 'east',
   layout           = wibox.container.rotate
}

Changes:

  • The composite widget constructor is wibox.widget. You used the progressbar constructor to contruct a rotate container
  • Indentation to make the code more readable
  • You had 2 widget in the same block, this isn't supported.

Reference https://awesomewm.org/apidoc/classes/wibox.widget.progressbar.html#

  • It works, but the call `mybacklight:set_value(0.5)` returns an error : set_value() : **nil value**, which is strange as this method does exist for progress bar in the provided link. – deb2014 Feb 07 '17 at 19:42
  • Got it ! It is better with `mybacklight.widget:set_value(0.5)`. However, the color setting `color =` does not work correctly. It is necessary to change it to `color = {type = "linear", from = {20, 0}, to = {0, 0}, stops = { {0, "#F6F6F6"}, {0.5, "#bdbdbd"}, {1.0, "#3b3b3b"} }` to make it appear as before. – deb2014 Feb 07 '17 at 21:08