令人敬畏的WM重启标志

时间:2018-03-29 16:02:28

标签: lua startup configuration-files awesome-wm

真棒窗口管理器是否在重启期间设置了某种标志。我在rc.lua中有一些自动启动命令,每次重新启动窗口管理器时都会执行它们。

如何在rc.lua中确定文件执行是否因重启而完成?

3 个答案:

答案 0 :(得分:2)

很棒的v4.x?
声明run_once函数。
numlockx on为例

function run_once(cmd)                                                                                                               
  findme = cmd 
  firstspace = cmd:find(" ")
  if firstspace then
    findme = cmd:sub(0, firstspace-1)
  end        
  awful.spawn.with_shell("pgrep -u $USER -x " .. findme .. " > /dev/null || (" .. cmd .. ")")
end          

run_once("numlockx on")

答案 1 :(得分:1)

很抱歉,只想评论一下@ploth的答案......但声誉不够。 给定的代码是前维基上的代码,它对我不起作用。我用这个:

function run_once(cmd)                 
 local findme = "ps x U $USER |grep '" .. cmd .. "' |wc -l"              
 awful.spawn.easy_async_with_shell( findme ,
   function(stdout,stderr,reason,exit_code) 
     if tonumber(stdout) <= 2 then
       awful.spawn( cmd )
     end
   end)
end    

答案 2 :(得分:0)

使用随附的spawn.once函数,例如

awful.spawn.once("dex --autostart --environment awesome")

https://awesomewm.org/doc/api/libraries/awful.spawn.html#once