forked from stanipintjuk/i3-wm-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnextmatch
More file actions
executable file
·31 lines (26 loc) · 765 Bytes
/
nextmatch
File metadata and controls
executable file
·31 lines (26 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3.4
import re
import string
import sys
import common
def search_window(windows, expr):
flags = re.I
for x in expr:
if x in string.ascii_uppercase:
flags = 0
break
regex = re.compile(expr, re.I)
matches = []
for (wm_class, name), L in windows.items():
if regex.match("class:" + wm_class) or regex.match(name):
matches.extend(L)
return matches
def main(args):
if len(args) != 1:
return "usage: nextmatch [TEXT]"
current, windows = common.get_named_windows()
matches = search_window(windows, args[0])
if matches:
common.focus_window(common.cycle_selected(current, matches))
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))