Awesome WM 重新启动标志

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

如何在rc.lua中确定文件执行是否是由于重新启动而完成的?

点赞
用户6942816
用户6942816

Awesome 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")
2018-03-29 16:32:20
用户5539707
用户5539707

很抱歉,我只是想评论@ploth的答案...但是没有足够的声望。

给出的代码是以前的 Wiki 上的代码,对我来说不起作用。我使用了这个:

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
2018-03-30 12:12:07
用户3585934
用户3585934

使用内置的 spawn.once 函数,示例如下。

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

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

2020-06-22 10:14:14