'Switch to the selected group or to the previously active one'

def cmd_toggle_group(self, group_name=None):

    group = self.qtile.groupMap.get(group_name)
    if (group in (self.group, None)):
        group = self.previous_group
    self.setGroup(group)
