17

How to config awesome so it would start new application with two windows aligned like this:

----------------
|xxxxxxxxxx####|
|xxxxxxxxxx####|
|xxxxxxxxxx####|
|xxxxxxxxxx####|
----------------

where "x" is for example conversation window in pidgin and '#' is buddy list window.

In general I would like to specify width of right window and put it on the right side (maximized vertically) and the other window should take the remaining space.

I already have some almost-working code, but it behaves strangely (it setups everything correct for pidgin, but it doesn't for gimp and v_sim, and occasionally without any known to me reason it changes geometry of the left window. Or when I start application (v_sim) it isn't placed in correct positions and it isn't maximized vertically, but when I then restart awesome, it places it correctly. So I guess that this application changes something when it starts.

Here is code which I use now:

awful.rules.rules = {
  ...
  { rule = { class = "Pidgin", role = "buddy_list" },
    properties = {
      floating = true
    },
    callback = function( c )
      local w_area = screen[ c.screen ].workarea
      local winwidth = 340
      c:struts( { right = winwidth } )
      c:geometry( { x = w_area.width - winwidth, width = winwidth, y = w_area.y, height = w_area.height } )
    end
  },
  { rule = { class = "Pidgin", role = "conversation" },
    properties = {
      floating = true,
      x = 0,
      maximized_vertical = true,
      maximized_horizontal = true
    },
    callback = awful.client.setslave
  },
  ...
}
klew
  • 14,837
  • 7
  • 47
  • 59
  • Can you post your code? It might be more useful than asking people to write it from scratch. – Olli Feb 25 '11 at 10:28
  • I haven't post it because it doesn't work well, but I'll update my question. – klew Feb 25 '11 at 10:43
  • I think this may be a bettter question for StackOverflow. – techie007 Feb 25 '11 at 15:40
  • 1
    why would you even want to make those windows float? just use a proper layout manager, and add a callback to one of those windows to set it as master. – Łukasz Gruner Feb 27 '11 at 14:51
  • @Łukasz: I prefer working with maximized windows, but there are some cases where application has at least two windows, so I just want to have them arranged like in my question. And if any other window is opened in this tag, I want it to be maximized, and those previously opened two windows to stay in the same position and size. BTW what does setting window as master do? And could you write it in lua? – klew Feb 27 '11 at 23:05
  • 1
    Setting window as master would just put it into 'master' part of the layout (default shortcut for this is 'mod+enter'), if you use, for example tiling layout, you coud have the master part take 30% of the space, put your roster there, and all the chat windows would go to the 'slave' part. If you than add a rule for that 'tag' that says 'give all windows except pidgin float attribute' it would behave like you want it to. – Łukasz Gruner Feb 28 '11 at 08:55

2 Answers2

12

I had this exact same problem, but I wanted a large Firefox window on the left with a small terminal on the right. To get it to work I dedicated a tag for this purpose with a tile-left layout and adjusted the width factor (i.e. the operation normally performed by CTRL-L).

Add the following to the end of rc.lua where yourtag is the tag in which you would like to place these windows. The 0.15 value can be adjusted to your taste.

awful.tag.viewonly(yourtag)
awful.tag.incmwfact(0.15, yourtage)

Also, using the awful.client.setslave for the window that you want on the right ensures that they don't get switched.

{
    rule = { class = "URxvt" },
    callback = awful.client.setslave
},

You may also direct certain applications to a tag using the tag property.

{
    rule = { class = "Firefox" },
    properties = { tag = browse }
},
{
    rule = { class = "URxvt", instance = "browse" },
    properties = { tag = browse },
},

I then created a binding to open these applications as follows.

-- Custom programs
awful.key({ modkey, "Shift" }, "b", function()
    awful.tag.viewonly(browse)
    awful.util.spawn_with_shell("urxvt -name browse -e newsbeuter")
    awful.util.spawn("firefox")
end)

This is the final result:

This is the final result.

Judge Maygarden
  • 26,961
  • 9
  • 82
  • 99
  • If you have pidgin-extprefs installed, you should make sure, to enable the option "Allow buddy list to shrink below normal constraints". Otherwise you must define `size_hints_honor=false` in the properties (or pidgin behaves really weird). Also, using `setmwfact(..)` is probably a better choice than `incmwfact(..)` – coldfix May 29 '12 at 09:48
5

Alternatively, you can use a floating contact list window with struts. This prevents the contact list window from being maximized when no message-window is present. Also, it allows the CL-window to be placed next to arbitrary (tiling) windows.

Check out: http://www.bramschoenmakers.nl/en/node/738

Although his implementation is a bit buggy for my version of awesome. The problem is that it does not adjust for struts that have already been set.

My implementation:

{ rule = { class = "Pidgin", role = "buddy_list" },
    properties = {floating=true,
                  maximized_vertical=true, maximized_horizontal=false },
    callback = function (c)
        local cl_width = 250    -- width of buddy list window

        local scr_area = screen[c.screen].workarea
        local cl_strut = c:struts()

        -- scr_area is affected by this client's struts, so we have to adjust for that
        if c:isvisible() and cl_strut ~= nil and cl_strut.left > 0 then
            c:geometry({x=scr_area.x-cl_strut.left, y=scr_area.y, width=cl_strut.left})
        -- scr_area is unaffected, so we can use the naive coordinates
        else
            c:struts({left=cl_width, right=0})
            c:geometry({x=scr_area.x, y=scr_area.y, width=cl_width})
        end
    end },

This puts the CL window on the left and allocating a fixed space for it.

(You don't need any rule for the conversation-window)

coldfix
  • 6,604
  • 3
  • 40
  • 50