【问题标题】:Awesome WM: Placing tiled clients in specific order on startupAwesome WM:在启动时按特定顺序放置平铺客户端
【发布时间】:2021-08-13 04:06:33
【问题描述】:

我大约一周前安装了 Awesome WM。从那时起,我一直试图在启动时按特定顺序放置终端客户端(裸终端和 vim、vim、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" })

我遇到问题的标签布局是“平铺”。我正在使用 Awesome v4.3。我应该添加什么客户端属性来获得所需的行为?

【问题讨论】:

    标签: lua awesome-wm


    【解决方案1】:

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

        1 local awful = require("awful")                                                   
        1                                                                                  
        2 local function spawn_vifm ()                                                     
        3     awful.spawn(terminal.." -e vifm", {                                          
        4         tag = "edit",                                                            
        5         placement = awful.placement.bottom_right                                 
        6     })                                                                           
        7 end                                                                              
        8                                                                                  
        9 local function spawn_term ()                                                     
       10     awful.spawn(terminal, {                                                      
       11         tag = "edit",                                                            
       12         placement = awful.placement.right,                                       
       13         callback = function(c) spawn_vifm() end                                  
       14 })                                                                               
       15 end                                                                              
       16                                                                                  
       17 local function spawn_htop ()                                                     
       18     awful.spawn(terminal.." -e htop", {                                          
       19         tag = "edit",                                                            
       20         placement = awful.placement.top_right,                                   
       21         callback = function(c) spawn_term() end                                  
       22     })                                                                           
       23 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 })
    

    在前一个客户端的回调函数中生成下一个客户端可确保为它们两者保留放置属性。

    【讨论】:

    • 用这个解决方案对我来说回调没有被执行,我正在尝试按顺序启动 3 个 alacritty 窗口...
    【解决方案2】:

    我不知道你的意思是什么:“我有问题的标签的布局是向左平铺的。”我假设你的意思是你的终端没有正确平铺?几年前我使用 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 中编写脚本。

    【讨论】:

    • 感谢您的回答和建议。 我遇到问题的标签布局是向左平铺我的意思是,我遇到问题的布局在 Awesome 术语中是“向左平铺”(实际上,它只是“平铺” )。在对 Awesome API 进行了更多研究之后,我设法获得了所需的行为。关键是使用 callback 选项并仅在前一个客户端准备好时才生成下一个客户端。这样可以确保客户端以正确的顺序生成。顺便说一句,我还没有弄清楚如何设置“htop”宽度,但我想我可以接受。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多