简体   繁体   中英

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.

How can I determine in the rc.lua if the file execution is done because of a restart?

Awesome v4.x?
Declare a run_once function.
numlockx on as an example

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. The given code is the one on the former wiki, and it didn't work for me. 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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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