在Awesome-WM中为特定应用程序设置Windows布局 [英] Setting windows layout for a specific application in awesome-wm

查看:121
本文介绍了在Awesome-WM中为特定应用程序设置Windows布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何进行出色的配置,这样它将以两个对齐的窗口启动新应用程序:

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

解决方案

我遇到了完全相同的问题,但是我希望左侧有一个较大的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)

这是最终结果:

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

解决方案

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:

这篇关于在Awesome-WM中为特定应用程序设置Windows布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆