Awesome WM: 将平铺客户端按特定顺序放置在启动时

我大约一周前安装了 Awesome WM。自那时以来,我一直试图在启动时以特定顺序放置终端客户端(裸终端和 vim、vifm、htop)。下面是我尝试实现的可视化表示形式:

########################
#            #   htop  #
#            ###########
#    vim     #   bare  #
#            ###########
#            #   vifm  #
########################

我已经成功将 vim 放置在正确的位置,但其他窗口被放置在似乎是任意的顺序,每次重新启动都会改变。以下是我的 autostart.lua 配置的内容:

    1 local awful = require("awful")
    1
    2 awful.spawn.single_instance(terminal.."-e xmodmap ~/.Xmodmap; exit")
    3 awful.spawn.single_instance("brave-browser", {
    4     fullscreen = true,
    5     focus = true
    6 })
    7
    8 awful.spawn(terminal.." -e vim", {
    9     tag = "edit",
   10     placement = awful.placement.left,
   11     callback = function(c) awful.client.setmaster(c) end})
   12 awful.spawn(terminal.." -e htop", {
   13     tag = "edit",
   14     height = 80,
   15     placement = awful.placement.top_right})
   16 awful.spawn(terminal, {
   17     tag = "edit",
   18     placement = awful.placement.right})
   19 awful.spawn(terminal.." -e vifm", {
   20     tag = "edit",
   21     placement = awful.placement.bottom_right})
   22
   23 awful.spawn(terminal.." -e neomutt", {
   24     tag = "communication",
   25     fullscreen = true })
   26
   27 awful.spawn("Spotify", { tag = "read" })

我有问题的标签布局是 “tile”。我正在使用 Awesome v4.3。我应该添加哪个客户端属性才能实现所需的行为?

点赞
用户3342050
用户3342050

我不知道你指的是什么:“我有问题的标签布局是向左平铺的”。我猜你的终端没有正确平铺?我在几年前使用了一周的 AwesomeWM,但很快意识到需要进行许多微调才能完全符合你的要求。你遇到的情况正是我遇到的。

我发现更容易使用 LXDE 和 Devilspie2。你可以使用 Lua 脚本无装饰地最大化窗口、跳转到其他桌面或任何你想要的操作,方法相当容易。这“可能会帮助你实现你的目标”,但如果你没有明确你的问题,很难说。

local screenwidth = awful.screen.geometry.width
local screenheight = awful.screen.geometry.height

local halfwidth = math.floor(screenwidth / 2)
local thirdheight = math.floor(screenheight / 3)

awful.spawn(terminal .. " -e vim", {
    tag = "edit",
    width = halfwidth,
    height = screenheight,
    placement = awful.placement.left,
    callback = function(c) awful.client.setmaster(c) end }  )

awful.spawn(terminal.." -e htop", {
    tag = "edit",
    width = halfwidth,
    height = thirdheight,
    placement = awful.placement.top_right }  )

awful.spawn(terminal, {  -- bare
    tag = "edit",
    width = halfwidth,
    height = thirdheight,
    placement = awful.placement.right }  )

awful.spawn(terminal .. " -e vifm", {
    tag = "edit",
    width = halfwidth,
    height = thirdheight,
    placement = awful.placement.bottom_right }  )

此外,如果你只是想在桌面上查看终端输出的话,可能Conky是一个可行的解决方案,同时还可以使用 Lua 进行脚本编写。

2020-11-04 07:10:18
用户14573348
用户14573348

为了在启动时将客户端生成在所需位置上,应该使用“回调”选项。这是我autostart.lua文件中与此问题相关的一部分代码:

1 local awful = require("awful")

2 local function spawn_vifm ()
3     awful.spawn(terminal.." -e vifm", {
4         tag = "edit",
5         placement = awful.placement.bottom_right
6     })
7 end

8 local function spawn_term ()
9     awful.spawn(terminal, {
10         tag = "edit",
11         placement = awful.placement.right,
12         callback = function(c) spawn_vifm() end
13     })
14 end

15 local function spawn_htop ()
16     awful.spawn(terminal.." -e htop", {
17         tag = "edit",
18         placement = awful.placement.top_right,
19         callback = function(c) spawn_term() end
20     })
21 end
.......
38 awful.spawn(terminal.." -e vim", {
39     tag = "edit",
40     placement = awful.placement.left,
41     callback = function(c)
42         awful.client.setmaster(c)
43         store_active_client(awful.tag.find_by_name(awful.screen.focused(), "edit"), c)
44         spawn_htop()
45     end
46 })

在上一个函数的回调函数中生成下一个客户端,可以确保将其放置属性保存在两者中间。

2020-11-04 11:23:11