new swig build system. much better. yay.
[dana/openbox.git] / scripts / defaults.py
1 import ob         # base module
2 import focus      # add some default focus handling and cycling functions
3 import focusmodel # default focus models
4 import behavior   # defines default behaviors for interaction with windows
5 import callbacks  # a lib of functions that can be used as binding callbacks
6 import windowplacement # use a routine in here to place windows
7 import historyplacement # history window placement
8
9 # try focus something when nothing is focused
10 focus.FALLBACK = 1
11
12 # choose a default focus model
13 focusmodel.setup_click_focus() # use focusmodel.setup_sloppy_focus() instead to
14                                # make focus follow the cursor, or bind things
15                                # in some way like these functions do to make
16                                # your own custom focus model.
17 # set up the mouse buttons
18 behavior.setup_window_clicks()
19 behavior.setup_window_buttons()
20 behavior.setup_scroll()
21
22 # my window placement algorithm
23 #ob.ebind(ob.EventAction.PlaceWindow, windowplacement.random)
24 ob.ebind(ob.EventAction.PlaceWindow, historyplacement.place)
25 # don't place terminals by history placement (xterm,aterm,rxvt)
26 def histplace(data):
27     if data.client.appClass() == "XTerm": return 0
28     return 1
29 historyplacement.CONFIRM_CALLBACK = histplace
30
31
32 # run xterm from root clicks
33 ob.mbind("Left", ob.MouseContext.Root, ob.MouseAction.Click,
34          lambda(d): ob.execute("xterm", d.screen))
35
36 ob.kbind(["A-F4"], ob.KeyContext.All, callbacks.close)
37
38 # focus bindings
39 import stackedcycle # functions for doing stacked 'kde-style' cycling
40 ob.kbind(["A-Tab"], ob.KeyContext.All, stackedcycle.next)
41 ob.kbind(["A-S-Tab"], ob.KeyContext.All, stackedcycle.previous)
42
43 # if you want linear cycling instead of stacked cycling, comment out the focus
44 # bindings above, and use these instead.
45 #import focuscycle # functions for doing linear cycling
46 #focuscycle.RAISE_WINDOW = 0 # don't raise windows when they're activated
47 #ob.kbind(["A-Tab"], ob.KeyContext.All, focuscycle.next)
48 #ob.kbind(["A-S-Tab"], ob.KeyContext.All, focuscycle.previous)
49
50 # desktop changing bindings
51 ob.kbind(["C-1"], ob.KeyContext.All, lambda(d): callbacks.change_desktop(d, 0))
52 ob.kbind(["C-2"], ob.KeyContext.All, lambda(d): callbacks.change_desktop(d, 1))
53 ob.kbind(["C-3"], ob.KeyContext.All, lambda(d): callbacks.change_desktop(d, 2))
54 ob.kbind(["C-4"], ob.KeyContext.All, lambda(d): callbacks.change_desktop(d, 3))
55 ob.kbind(["C-A-Right"], ob.KeyContext.All,
56          lambda(d): callbacks.next_desktop(d))
57 ob.kbind(["C-A-Left"], ob.KeyContext.All,
58          lambda(d): callbacks.prev_desktop(d))
59
60 ob.kbind(["C-S-A-Right"], ob.KeyContext.All,
61          lambda(d): callbacks.send_to_next_desktop(d))
62 ob.kbind(["C-S-A-Left"], ob.KeyContext.All,
63          lambda(d): callbacks.send_to_prev_desktop(d))
64
65 # focus new windows
66 ob.ebind(ob.EventAction.NewWindow, callbacks.focus)
67
68 print "Loaded defaults.py"