Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting windows layout for a specific application in awesome-wm

Tags:

lua

awesome-wm

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
  },
  ...
}
like image 953
klew Avatar asked Feb 25 '11 10:02

klew


1 Answers

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.

like image 78
Judge Maygarden Avatar answered Nov 03 '22 23:11

Judge Maygarden