Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Provide context when using the addgroup and delgroup hooks.

- before

def main(qtile):
    @hook.subscribe.addgroup
    def goto_group():
	if hasattr(qtile, 'currentScreen'):
	    qtile.groups[-1].cmd_toscreen() @hook.subscribe.addgroup

- after

@hook.subscribe.addgroup
def goto_group(qtile, name):
    if hasattr(qtile, 'currentScreen'):
	qtile.groupMap[name].cmd_toscreen()

Closes #248
  • Loading branch information...
commit ac2346a26b39ccff69af13b80def7e94857f9e8f 1 parent bd79d10
@cjbarnes18 cjbarnes18 authored tych0 committed
View
3  libqtile/bar.py
@@ -182,8 +182,7 @@ def _configure(self, qtile, screen):
# FIXME: These should be targeted better.
hook.subscribe.setgroup(self.draw)
- hook.subscribe.delgroup(self.draw)
- hook.subscribe.addgroup(self.draw)
+ hook.subscribe.changegroup(self.draw)
def _resize(self, width, widgets):
stretches = [i for i in widgets if i.width_type == STRETCH]
View
4 libqtile/dgroups.py
@@ -96,9 +96,7 @@ def _setup_hooks(self):
if self.key_binder:
libqtile.hook.subscribe.setgroup(
lambda: self.key_binder(self))
- libqtile.hook.subscribe.addgroup(
- lambda: self.key_binder(self))
- libqtile.hook.subscribe.delgroup(
+ libqtile.hook.subscribe.changegroup(
lambda: self.key_binder(self))
def shuffle_groups(self, lst, match):
View
6 libqtile/hook.py
@@ -51,6 +51,12 @@ def delgroup(self, func):
"""
return self._subscribe("delgroup", func)
+ def changegroup(self, func):
+ """
+ Called whenever a group change occurs.
+ """
+ return self._subscribe("changegroup", func)
+
def focus_change(self, func):
"""
Called when focus is changed.
View
6 libqtile/manager.py
@@ -295,7 +295,8 @@ def addGroup(self, name):
g._configure(
self.config.layouts, self.config.floating_layout, self)
self.groupMap[name] = g
- hook.fire("addgroup")
+ hook.fire("addgroup", self, name)
+ hook.fire("changegroup")
self.update_net_desktops()
return True
@@ -313,7 +314,8 @@ def delGroup(self, name):
self.currentGroup.cmd_prevgroup()
self.groups.remove(group)
del(self.groupMap[name])
- hook.fire("delgroup")
+ hook.fire("delgroup", self, name)
+ hook.fire("changegroup")
self.update_net_desktops()
Please sign in to comment.
Something went wrong with that request. Please try again.