Restore Tag When Plug/Unplug Screen in Awesome WM

tag.connect_signal("request::screen", function(t)
    clients = t:clients()
    for s in screen do
        if s ~= t.screen and clients and next(clients) then
            t.screen = s
            t.original_tag_name = t.original_tag_name or t.name
            t.name = t.name .. "'"
            t.volatile = true
            return
        end
    end
end)

screen.connect_signal("added", function(s)
    for k,t in pairs(root.tags()) do
        if t.original_tag_name then
          -- find the new tag on the new screen
            new_tag = awful.tag.find_by_name(s, t.original_tag_name)
            if new_tag then
                t.name = t.original_tag_name
                t.original_tag_name = nil
                new_tag:swap(t)
                new_tag:delete(t, true)
            end
        end
    end
end)

Reference: https://www.reddit.com/r/awesomewm/comments/5r9mgu/client_layout_not_preserved_when_switching/dd8nngy