Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Signal function to execute when a client is started
- client.connect_signal("manage", function(c)
- c.last_focus_date = unixtime()
- end)
- -- Signal function to execute when a client is terminated
- client.connect_signal("unmanage", function (c)
- focus_recent_client(awful.tag.selected(awful.screen.focused()))
- end)
- -- Signal function to execute when a client gains focus
- client.connect_signal("focus", function (c)
- c.last_focus_date = unixtime()
- end)
- -- Unix timestamp
- function unixtime()
- return os.time(os.date("!*t"))
- end
- function focus_recent_client(t)
- local clientz = t:clients()
- if #clientz > 0 then
- local topc = clientz[1]
- for k,c in pairs(clientz) do
- if c.last_focus_date > topc.last_focus_date then
- topc = c
- end
- end
- client.focus = topc
- client.focus:raise()
- end
- end
- -- Attach this to every screen
- for k,t in pairs(awful.tag.gettags(s)) do
- t:connect_signal("property::selected", function(t)
- focus_recent_client(t)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement