code: def focus_change(self, i3conn, event):
          
          has_focus_now = (event.container.window_class == self.class_name)
          if self.had_focus ^ has_focus_now:
              # The monitored application changed focus state
              self.had_focus = has_focus_now
              self.stop_cont(has_focus_now)
docs: Detect focus change on a process with class class_name.
          On change, stop/continue the process called process_name