You are not logged in.

#1 2012-06-02 02:37:01

azazello_spawn
Member
Registered: 2012-06-02
Posts: 1

Order of Widgets in Awesome Problem

I recently started using awesome, and have been trying to configure my rc.lua.
I added this battery widget:

batmon = awful.widget.progressbar()
batmon:set_width(8)
batmon:set_vertical(true)
batmon:set_border_color("#3f3f3f")
batmon:set_color("#5f5f5f")
batmon_t = awful.tooltip({ objects = { batmon.widget },})
vicious.register(batmon, vicious.widgets.bat, function (widget, args)
                batmon_t:set_text(" State: " .. args[1] .. " | Charge: " .. args[2] .. "% | Remaining: " .. args[3])
                if args[2] <= 5 then
                        naughty.notify({ text="Battery is low! " .. args[2] .. " percent remaining." })
                end
                return args[2]
                end , 60, "BAT0")

It works fine, however it keeps showing up to the left of my task list, regardless of how I arrange my widgets.
Here is my current atempt:

for s = 1, screen.count() do
    -- Create a promptbox for each screen
    mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
    -- Create an imagebox widget which will contains an icon indicating which layout we're using.
    -- We need one layoutbox per screen.
    mylayoutbox[s] = awful.widget.layoutbox(s)
    mylayoutbox[s]:buttons(awful.util.table.join(
                           awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
                           awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
                           awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
                           awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
    -- Create a taglist widget
    mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)

    -- Create a tasklist widget
    mytasklist[s] = awful.widget.tasklist(function(c)
                                              return awful.widget.tasklist.label.currenttags(c, s)
                                          end, mytasklist.buttons)

    -- Create the wibox
    mywibox[s] = awful.wibox({ position = "top", screen = s })
    -- Add widgets to the wibox - order matters
    mywibox[s].widgets = {
        {
            mylauncher,
            mytaglist[s],
            mypromptbox[s],

            layout = awful.widget.layout.horizontal.leftright
        },
        mylayoutbox[s],
        mytextclock,
        --separator,batmon,
for s = 1, screen.count() do
    -- Create a promptbox for each screen
    mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
    -- Create an imagebox widget which will contains an icon indicating which layout we're using.
    -- We need one layoutbox per screen.
    mylayoutbox[s] = awful.widget.layoutbox(s)
    mylayoutbox[s]:buttons(awful.util.table.join(
                           awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
                           awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
                           awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
                           awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
    -- Create a taglist widget
    mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)

    -- Create a tasklist widget
    mytasklist[s] = awful.widget.tasklist(function(c)
                                              return awful.widget.tasklist.label.currenttags(c, s)
                                          end, mytasklist.buttons)

    -- Create the wibox
    mywibox[s] = awful.wibox({ position = "top", screen = s })
    -- Add widgets to the wibox - order matters
    mywibox[s].widgets = {
        {
            mylauncher,
            mytaglist[s],
            mypromptbox[s],

            layout = awful.widget.layout.horizontal.leftright
        },
        mylayoutbox[s],
        mytextclock,
        --separator,batmon,
for s = 1, screen.count() do
    -- Create a promptbox for each screen
    mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
    -- Create an imagebox widget which will contains an icon indicating which layout we're using.
    -- We need one layoutbox per screen.
    mylayoutbox[s] = awful.widget.layoutbox(s)
    mylayoutbox[s]:buttons(awful.util.table.join(
                           awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
                           awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
                           awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
                           awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
    -- Create a taglist widget
    mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)

    -- Create a tasklist widget
    mytasklist[s] = awful.widget.tasklist(function(c)
                                              return awful.widget.tasklist.label.currenttags(c, s)
                                          end, mytasklist.buttons)

    -- Create the wibox
    mywibox[s] = awful.wibox({ position = "top", screen = s })
    -- Add widgets to the wibox - order matters
    mywibox[s].widgets = {
        {
            mylauncher,
            mytaglist[s],
            mypromptbox[s],

            layout = awful.widget.layout.horizontal.leftright
        },
        mylayoutbox[s],
        mytextclock,
        --separator,batmon,
       s == 1 and mysystray or nil,
        --separator,batmon,     
        separator,volwidget, volbar.widget,batmon,
        --separator,batmon,
        mytasklist[s],
        layout = awful.widget.layout.horizontal.rightleft
    }
end

                                                                                                                             
The commented out parts are my other attempts that had the same result. My volume widget displays to the right of the task list, and I would like my battery widget next to it, not on the left side of the task list.
Picture:


-- mod edit: read the Forum Etiquette and only post thumbnails http://wiki.archlinux.org/index.php/For … s_and_Code [jwr] --

Last edited by jasonwryan (2012-06-02 09:31:01)

Offline

#2 2012-06-02 09:24:17

kniren
Member
Registered: 2011-10-12
Posts: 40

Re: Order of Widgets in Awesome Problem

You need to use a layout to set the widgets to the left or to the right, I don't know if it is very orthodox, but I add my widgets using the following code:

    mywibox[s] = awful.wibox({ position = "top", height= "16", screen = s })
    mywibox2[s] = awful.wibox({ position = "bottom", height= "17", screen = s })
    -- Widgets that are aligned to the left
    local left_layout = wibox.layout.fixed.horizontal()
    left_layout:add(mylauncher)
    left_layout:add(mytaglist[s])
    left_layout:add(mypromptbox[s])
    left_layout:add(separator2)

    -- Widgets that are aligned to the right
    local right_layout = wibox.layout.fixed.horizontal()
    if s == 1 then right_layout:add(wibox.widget.systray()) end
    right_layout:add(myclockicon)
    right_layout:add(mytextclock)
    right_layout:add(mylayoutbox[s])

    -- Now bring it all together (with the tasklist in the middle)
    local layout = wibox.layout.align.horizontal()
    layout:set_left(left_layout)
    layout:set_middle(mytasklist[s])
    layout:set_right(right_layout)

    local layoutbat = wibox.layout.fixed.horizontal()
    layoutbat:add(batwidget)
    layoutbat:add(batwidtext)
    layoutbat:add(cpuwidget)
    layoutbat:add(cpuwidtext)
    layoutbat:add(memwidget)
    layoutbat:add(memwidtext)
    layoutbat:add(separator)
    layoutbat:add(uptime)
    layoutbat:add(separator)
    layoutbat:add(network)
    layoutbat:add(separator)
    layoutbat:add(hdspace)
    layoutbat:add(separator)
    layoutbat:add(hdspace2)
    layoutbat:add(separator)
    layoutbat:add(volwidtext)
    layoutbat:add(separator)

    local layoutsys = wibox.layout.fixed.horizontal()
    layoutsys:add(mpdwidget)
    layoutsys:add(music_play)
    layoutsys:add(music_prev)
    layoutsys:add(music_next)
    layoutsys:add(music_stop)
    layoutsys:add(separator)
    layoutsys:add(pacwidget)
    layoutsys:add(separator)
    layoutsys:add(osinfo)
    layoutsys:add(separator)


    local layout2 = wibox.layout.align.horizontal()
    layout2:set_left(layoutbat)
    layout2:set_right(layoutsys)

    mywibox[s]:set_widget(layout)
    mywibox2[s]:set_widget(layout2)

Archlinux :: Xmonad
dotfiles | deviantart

Offline

#3 2012-06-03 02:43:17

anrxc
Member
From: Croatia
Registered: 2008-03-22
Posts: 835
Website

Re: Order of Widgets in Awesome Problem

You made a common mistake. Read this section again, carefully https://awesome.naquadah.org/wiki/Widge … ng_widgets


You need to install an RTFM interface.

Offline

Board footer

Powered by FluxBB