This page looks best with JavaScript enabled

Auto-start applications in specific screen/tags with Awesome

 ·  🎃 kr0m

Awesome is an extremely configurable window manager. To be honest, I don’t think there is anything that can’t be done with it, since Awesome is not configured based on configuration options but rather functions are programmed in the configuration file. With this system, the only limit is our imagination and our skills as a Lua programmer.

We edit the current configuration and add the following code at the end, just before the last – }}}.

vi .config/awesome/rc.lua

-- Kr0m autostart
local function autoStart(command, class, tag)
  --naughty.notify({ title = "autoStart", text = "Dentro autoStart", timeout = 0 })
  if tag ~= nil then
    --naughty.notify({ title = "autoStart", text = "Dentro != nil", timeout = 0 })
    local callback
    callback = function(c)
      if c.class == class then
        --naughty.notify({ title = "autoStart", text = "App moved: "..c.class, timeout = 0 })
        client.disconnect_signal("manage", callback)
        --naughty.notify({ title = "autoStart", text = "Signal disconnected: "..c.class, timeout = 0 })
    -- Cada vez que se cree un cliente ejecuta la funcion callback
    client.connect_signal("manage", callback)
  -- Creamos un cliente nuevo

autoStart("chrome", "Chromium-browser", awful.screen.focused().tags[1])
autoStart("telegram-desktop", "TelegramDesktop", awful.screen.focused().tags[2])
autoStart("sublime", "Sublime_text", awful.screen.focused().tags[2])
autoStart("barrier", "Barrier", awful.screen.focused().tags[9])

In summary, what we do is create a callback function that will be executed every time a new client is created. When the callback is executed, the client is moved to the corresponding tag and then the callback function is disconnected so that subsequent clients of the same class are not affected. If we didn’t disconnect, after the auto-start all the Chromes we started manually would go to tag 1, the Telegrams to tag 2… it would behave like a rule.

We can get the wm-classnames using the xprop tool.

pkg install xprop
emerge -av x11-apps/xprop

According to the documentation of the awful library, we can indicate the tag where to launch the application, but this option uses a protocol called startup notification protocol and very few applications implement it.

If you liked the article, you can treat me to a RedBull here