简体   繁体   English

很棒的 WM 重启标志

[英]Awesome WM restart flag

Does awesome window manager set some kind of flag during restart.很棒的窗口管理器在重启期间是否设置了某种标志。 I've some autostart commands in rc.lua and they are executed every time I restart the window manager.我在rc.lua有一些自动启动命令,每次我重新启动窗口管理器时都会执行它们。

How can I determine in the rc.lua if the file execution is done because of a restart?如何在rc.lua确定文件执行是否由于重新启动而完成?

Awesome v4.x?很棒的 v4.x?
Declare a run_once function.声明一个run_once函数。
numlockx on as an example 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")

Sorry, just want to comment @ploth 's answer...but not enough reputation.抱歉,只想评论@ploth 的答案……但声誉不够。 The given code is the one on the former wiki, and it didn't work for me.给定的代码是以前的 wiki 上的代码,它对我不起作用。 I use this one :我用这个:

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    

Use the included spawn.once function, eg使用包含的spawn.once函数,例如

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM