简体   繁体   English

在awesome-wm中为特定应用程序设置窗口布局

[英]Setting windows layout for a specific application in awesome-wm

How to config awesome so it would start new application with two windows aligned like this: 如何配置awesome所以它将启动新的应用程序与两个窗口对齐如下:

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

where "x" is for example conversation window in pidgin and '#' is buddy list window. 其中“x”是例如pidgin中的对话窗口,而'#'是好友列表窗口。

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. 我已经有了一些几乎工作的代码,但它的行为很奇怪(它设置了一切正确的pidgin,但它不适用于gimp和v_sim,偶尔也没有任何我知道的原因它会改变左窗口的几何形状。或者当我启动应用程序(v_sim)它没有放在正确的位置,并没有垂直最大化,但当我重新启动awesome时,它正确放置。所以我猜这个应用程序在启动时会改变一些东西。

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
  },
  ...
}

I had this exact same problem, but I wanted a large Firefox window on the left with a small terminal on the right. 我有同样的问题,但我想在左边有一个大的Firefox窗口,右边有一个小终端。 To get it to work I dedicated a tag for this purpose with a tile-left layout and adjusted the width factor (ie the operation normally performed by CTRL-L). 为了使其工作,我专门为此目的使用标签左侧布局并调整宽度系数(即通常由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. 将以下内容添加到rc.lua的末尾,其中yourtag是您要放置这些窗口的标记。 The 0.15 value can be adjusted to your taste. 0.15值可根据您的口味进行调整。

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. 此外,将awful.client.setslave用于awful.client.setslave所需的窗口可确保它们不会被切换。

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

You may also direct certain applications to a tag using the tag property. 您还可以使用tag属性将某些应用程序定向到tag

{
    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: 这是最终结果:

这是最终结果。

Alternatively, you can use a floating contact list window with struts. 或者,您可以使用带有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. 此外,它允许CL窗口放置在任意(平铺)窗口旁边。

Check out: http://www.bramschoenmakers.nl/en/node/738 查看: 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. 问题是它不能调整已经设置的struts。

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. 这将CL窗口放在左侧并为其分配固定空间。

(You don't need any rule for the conversation-window) (对话窗口不需要任何规则)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM