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

发布于 2024-10-19 14:08:17 字数 1124 浏览 2 评论 0原文

如何配置很棒,以便它可以启动两个窗口对齐的新应用程序,如下所示:

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

其中“x”是 pidgin 中的对话窗口,“#”是好友列表窗口。

一般来说,我想指定右窗口的宽度并将其放在右侧(垂直最大化),另一个窗口应该占用剩余空间。

我已经有了一些几乎可以工作的代码,但它的行为很奇怪(它为 pidgin 设置了所有正确的内容,但对于 gimp 和 v_sim 则不然,有时在没有任何我所知的原因的情况下它会改变左窗口的几何形状。或者当我启动应用程序(v_sim)它没有放置在正确的位置,并且没有垂直最大化,但是当我重新启动时,它会正确放置它,所以我猜这个应用程序在启动时会改变一些东西,

这是我的代码。现在使用:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

╰つ倒转 2024-10-26 14:08:17

我遇到了完全相同的问题,但我想要左侧有一个大的 Firefox 窗口,右侧有一个小终端。为了让它工作,我专门为此目的使用了一个带有平铺左侧布局的标签,并调整了宽度系数(即通常由 CTRL-L 执行的操作)。

将以下内容添加到 rc.lua 的末尾,其中 yourtag 是您要在其中放置这些窗口的标签。 0.15 值可以根据您的喜好进行调整。

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

此外,对右侧所需的窗口使用 awful.client.setslave 可确保它们不会被切换。

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

您还可以使用 tag 属性将某些应用程序定向到标记。

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

然后,我创建了一个绑定来打开这些应用程序,如下所示。

-- 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)

这是最终结果:

这是最终结果。

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.

许你一世情深 2024-10-26 14:08:17

或者,您可以使用带有 struts 的浮动联系人列表窗口。
这可以防止在不存在消息窗口时联系人列表窗口最大化。
此外,它还允许将 CL 窗口放置在任意(平铺)窗口旁边。

查看:http://www.bramschoenmakers.nl/en/node/738

对于我的版本来说,他的实现有点错误。
问题是它不会针对已经设置的支柱进行调整。

我的实现:

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

这将 CL 窗口放在左侧并为其分配固定空间。

(对话窗口不需要任何规则)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文