Expose XWarpPointer to lua as rootwin:warp_pointer, for region_do_warp_alt
[notion.git] / contrib / scripts / goto_by_tag.lua
blob9d1a62f3ef040470436a0d6b02e49bb8ab8d218a
1 -- Authors: Philipp Hartwig <ph@phhart.de>
2 -- License: MIT, see http://opensource.org/licenses/mit-license.php
3 -- Last Changed: 2012-09-29
4 --
5 --[[
7 Description: This function sets focus to the first client with the given
8 tag.
10 Usage:
12 1) Define a tag for a client, using a winprop.
13 For example:
14 defwinprop{
15 class = "Firefox-bin",
16 instance = "Navigator",
17 tag = "b",
20 2) Add suitable bindings to the "WMPlex.toplevel" section of cfg_notioncore.
21 For example:
22 submap(META.."U", {
23 kpress("A", "goto_by_tag('a')"),
24 kpress("B", "goto_by_tag('b')"),
25 kpress("C", "goto_by_tag('c')"),
26 kpress("D", "goto_by_tag('d')"),
27 kpress("E", "goto_by_tag('e')"),
28 kpress("F", "goto_by_tag('f')"),
29 kpress("G", "goto_by_tag('g')"),
30 kpress("H", "goto_by_tag('h')"),
31 kpress("I", "goto_by_tag('i')"),
32 kpress("J", "goto_by_tag('j')"),
33 kpress("K", "goto_by_tag('k')"),
34 kpress("L", "goto_by_tag('l')"),
35 kpress("M", "goto_by_tag('m')"),
36 kpress("N", "goto_by_tag('n')"),
37 kpress("O", "goto_by_tag('o')"),
38 kpress("P", "goto_by_tag('p')"),
39 kpress("Q", "goto_by_tag('q')"),
40 kpress("R", "goto_by_tag('r')"),
41 kpress("S", "goto_by_tag('s')"),
42 kpress("T", "goto_by_tag('t')"),
43 kpress("U", "goto_by_tag('u')"),
44 kpress("V", "goto_by_tag('v')"),
45 kpress("W", "goto_by_tag('w')"),
46 kpress("X", "goto_by_tag('x')"),
47 kpress("Y", "goto_by_tag('y')"),
48 kpress("Z", "goto_by_tag('z')"),
49 }),
51 3) In the example above, you can directly jump to the first instance of Firefox
52 by hitting META+U B.
54 --]]
56 goto_by_tag = function(tag)
57 local s
58 ioncore.clientwin_i(function(cwin)
59 local winprop = ioncore.getwinprop(cwin)
60 if winprop and winprop.tag == tag then
61 s=cwin
62 return false
63 else
64 return true
65 end
66 end)
67 if s then
68 s:goto()
69 end
70 end