Customize Wmii - Select View

wmii is a window manager for X11.

By default, the hotkey Mod+1 will switch the desktop to view "1", Mod+2 will switch the desktop to view "2", and this is done similarly for all numbers from 0 to 9.

I am tagging windows using a name with a number prefix, like 0_vi, 1_file, 2_web . The customization is to make the Mod+<number> key switch to the <number> view or the next closest view. In my examples, Mod+0 will switch to view "0_vi", Mod+1 will switch to view "1_file".

I make the customization using the Python script.

In /etc/X11/wmii/python/pygmi/, in method, an additional param tag is used to indicate the <number> tag or the next closest one that should be returned.

 1     class Tags(object):
3 ...
5 def next(self, reverse=False, tag=None):
6 tags = [t for t in wmii.tags if not in self.ignore]
7 tags.append(tags[0])
8 if reverse:
9 tags.reverse()
10 # assume ordered tags?
11 if tag:
12 for i in range(0, len(tags)):
13 if tags[i].id >= tag:
14 return tags[i]
15 else:
16 for i in range(0, len(tags)):
17 if tags[i] == self.sel:
18 return tags[i+1]
19 return self.sel

In /etc/X11/wmii/python/, change the keys binding

 1     def bind_num(i):
2 keys.bind('main', (
3 "Tag actions",
4 # lambda k:,
5 ('%%(mod)s-%d' % i, "Move to view '%d'" % i,
6 lambda k:,
7 ('%%(mod)s-Shift-%d' % i, "Retag selected client with tag '%d'" % i,
8 lambda k: setattr(Client('sel'), 'tags', i)),
9 ))

Ok, we can now test the changes with:

wmii -r python/wmiirc &


blog comments powered by Disqus