Application autostart under certain tag in awesome-wm

winoi picture winoi · Feb 22, 2013 · Viewed 8.7k times · Source

I have read Setting windows layout for a specific application in awesome-wm.Now I want to do this under certain tag during autostart. For example:

I turn on my pc.Apps like "firefox","terminal" will automatically run under tag 1." "mplayer" will run under tag 2. "xchat" will run under tag 3. They all autostart.

I don't want "firefox" always under tag 1. I could run firefox under any tags I want.I just need it run under tag 1 when computer is first turned on.So code below couldn't be used.

awful.rules.rules = {
-- All clients will match this rule.
{ rule = { class = "Firefox" },
 properties = { tag = tags[1][2]}}, --,switchtotag=true} },
 ...

Answer

Nyquist picture Nyquist · May 18, 2013

Have you looked on the awesome wiki pages? I think this is what you are lookin for:

   function run_once(prg,arg_string,pname,screen)
    if not prg then
        do return nil end
    end

    if not pname then
       pname = prg
    end

    if not arg_string then 
        awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. "' || (" .. prg .. ")",screen)
    else
        awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. " ".. arg_string .."' || (" .. prg .. " " .. arg_string .. ")",screen)
    end
end

run_once("xscreensaver","-no-splash")
run_once("pidgin",nil,nil,2)
run_once("wicd-client",nil,"/usr/bin/python2 -O /usr/share/wicd/gtk/wicd-client.py")

This code is from the awesome wiki. You can pass the screen as an argument to this function. For more details look at the link above. If you want to open the window in a special tag on a screen you could give the window a special name (exp. "startup") and then create a rule to launch only the instances named "startup" on the screen.

Example:

run_once("firefox","startup, nil, 1)

...
 rule = { class = "Firefox", instance = "startup" }, properties = {tag = tags[2]}},
...