saga
saga

Reputation: 2113

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?

Upvotes: 1

Views: 1301

Answers (3)

Horus
Horus

Reputation: 625

Use the included spawn.once function, e.g.

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

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

Upvotes: 0

david
david

Reputation: 1501

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    

Upvotes: 1

ploth
ploth

Reputation: 455

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")

Upvotes: 2

Related Questions