Search code examples
awesome-wm

Is it possible to send back a client to its opening tag(s) in AwesomeWM?


I have rules to open specific applications (clients, for AwesomeWM) on certain tag(s). Sometimes, during my workflow, I may move a client, for instance from one screen to another (Mod+o), which changes the tags associated with the client. After working with this client, most of the time, it would be convenient to send it back to its initial (or previous) tag(s).

I can restart AwesomeWM, which would make the client re-read the rules in rc.lua, but it may break other tag associations and I would use a per-client function/shortcut.

Is it possible? With a specific module?


Solution

  • Everything is possible in AwesomeWM ;)

    In this case, you can use the default rc.lua "manage" client signal handler to add something like this:

    c.original_tags = c:tags()
    

    then in a client keybindings (not the global keybindings), do:

    awful.key({ modkey }, "b", function (c) c:tags(c.original_tags) end,
              {description = "restore the tags", group = "client"}),
    

    Please note that this will only work if your tags never change. If you add and delete tags, this will misbehave.

    An alternative is to call awful.rules.apply(c) directly from the keybinding and let the rules be applied again. This potentially has side effects beyond the tags, so it isn't my first choice for the answer.