I frequently lose track of which screen is currently focused (especially when there are no open clients). Therefore I want to write a widget which always shows which screen is focused.
My current code looks like this:
-- Focused screen widget
local focused_screen_widget = wibox.widget{
markup = "SCR: " .. tostring(awful.screen.focused().index),
align = 'center',
valign = 'center',
widget = wibox.widget.textbox
}
function update_focused_screen_widget()
focused_screen_widget.text = "SCR: " .. tostring(awful.screen.focused().index)
end
client.connect_signal("focus", update_focused_screen_widget)
client.connect_signal("unfocus", update_focused_screen_widget)
---- hook into awful.screen.focus()
original_screen_focus = awful.screen.focus
function awful.screen.focus(_screen)
original_screen_focus(_screen)
update_focused_screen_widget()
end
This is mostly working but when I have no open clients and move the mouse between screens, no update is triggered. I know the focus changed because new applications always start on the correct screen, but I can't find a way to update my widget on these changes. Can anyone help me with this?
Edit: I'm using awesome v4.2