1 ############################################################################
2 ### Functions that can be used as callbacks for mouse/keyboard bindings ###
3 ############################################################################
12 def state_above(data
, add
=StateAdd
):
13 """Toggles, adds or removes the 'above' state on a window.
14 The second paramater should one of: StateRemove, StateAdd, or
16 if not data
.client
: return
17 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
18 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
19 add
, otk
.Property_atoms().net_wm_state_above
)
21 def state_below(data
, add
=StateAdd
):
22 """Toggles, adds or removes the 'below' state on a window.
23 The second paramater should one of: StateRemove, StateAdd, or
25 if not data
.client
: return
26 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
27 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
28 add
, otk
.Property_atoms().net_wm_state_below
)
30 def state_shaded(data
, add
=StateAdd
):
31 """Toggles, adds or removes the 'shaded' state on a window.
32 The second paramater should one of: StateRemove, StateAdd, or
34 if not data
.client
: return
35 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
36 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
37 add
, otk
.Property_atoms().net_wm_state_shaded
)
39 def state_maximize(data
, add
=StateAdd
):
40 """Toggles, adds or removes the horizontal and vertical 'maximized' state
41 on a window. The second paramater should one of: StateRemove, StateAdd,
43 if not data
.client
: return
44 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
45 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
46 add
, otk
.Property_atoms().net_wm_state_maximized_horz
,
47 otk
.Property_atoms().net_wm_state_maximized_vert
)
49 def state_maximize_horz(data
, add
=StateAdd
):
50 """Toggles, adds or removes the horizontal 'maximized' state on a window.
51 The second paramater should one of: StateRemove, StateAdd, or
53 if not data
.client
: return
54 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
55 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
56 add
, otk
.Property_atoms().net_wm_state_maximized_horz
)
58 def state_maximize_vert(data
, add
=StateAdd
):
59 """Toggles, adds or removes the vertical 'maximized' state on a window.
60 The second paramater should one of: StateRemove, StateAdd, or
62 if not data
.client
: return
63 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
64 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
65 add
, otk
.Property_atoms().net_wm_state_maximized_vert
)
67 def state_skip_taskbar(data
, add
=StateAdd
):
68 """Toggles, adds or removes the 'skip_taskbar' state on a window.
69 The second paramater should one of: StateRemove, StateAdd, or
71 if not data
.client
: return
72 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
73 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
74 add
, otk
.Property_atoms().net_wm_state_skip_taskbar
)
76 def state_skip_pager(data
, add
=StateAdd
):
77 """Toggles, adds or removes the 'skip_pager' state on a window.
78 The second paramater should one of: StateRemove, StateAdd, or
80 if not data
.client
: return
81 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
82 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
83 add
, otk
.Property_atoms().net_wm_state_skip_pager
)
86 """Iconifies the window on which the event occured"""
87 if not data
.client
: return
88 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
89 otk
.Property_atoms().wm_change_state
,
90 data
.client
.window(), 3) # IconicState
93 """Un-iconifies the window on which the event occured, but does not focus
94 if. If you want to focus the window too, it is recommended that you
95 use the activate() function."""
96 if not data
.client
: return
97 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
98 otk
.Property_atoms().wm_change_state
,
99 data
.client
.window(), 1) # NormalState
102 """Closes the window on which the event occured"""
103 if not data
.client
: return
104 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
105 otk
.Property_atoms().net_close_window
,
106 data
.client
.window(), 0)
109 """Focuses the window on which the event occured"""
110 if not data
.client
: return
111 # !normal windows dont get focus from window enter events
112 if data
.action
== ob
.EventAction
.EnterWindow
and not data
.client
.normal():
116 def restart(data
, other
= ""):
117 """Restarts openbox, optionally starting another window manager."""
118 ob
.openbox
.restart(other
)
121 """Raises the window on which the event occured"""
122 if not data
.client
: return
123 ob
.openbox
.screen(data
.screen
).raiseWindow(data
.client
)
126 """Lowers the window on which the event occured"""
127 if not data
.client
: return
128 ob
.openbox
.screen(data
.screen
).lowerWindow(data
.client
)
130 def toggle_maximize(data
):
131 """Toggles the maximized status of the window on which the event occured"""
132 state_maximize(data
, StateToggle
)
135 """Maximizes the window on which the event occured"""
136 state_maximize(data
, StateAdd
)
138 def unmaximize(data
):
139 """Unmaximizes the window on which the event occured"""
140 state_maximize(data
, StateRemove
)
142 def toggle_shade(data
):
143 """Toggles the shade status of the window on which the event occured"""
144 state_shaded(data
, StateToggle
)
147 """Shades the window on which the event occured"""
148 state_shaded(data
, StateAdd
)
151 """Unshades the window on which the event occured"""
152 state_shaded(data
, StateRemove
)
154 def change_desktop(data
, num
):
155 """Switches to a specified desktop"""
156 root
= otk
.display
.screenInfo(data
.screen
).rootWindow()
157 ob
.send_client_msg(root
, otk
.Property_atoms().net_current_desktop
,
160 def next_desktop(data
, no_wrap
=0):
161 """Switches to the next desktop, optionally (by default) cycling around to
162 the first when going past the last."""
163 screen
= ob
.openbox
.screen(data
.screen
)
165 n
= screen
.numDesktops()
170 change_desktop(data
, d
)
172 def prev_desktop(data
, no_wrap
=0):
173 """Switches to the previous desktop, optionally (by default) cycling around
174 to the last when going past the first."""
175 screen
= ob
.openbox
.screen(data
.screen
)
177 n
= screen
.numDesktops()
182 change_desktop(data
, d
)
184 def send_to_desktop(data
, num
):
185 """Sends a client to a specified desktop"""
186 if not data
.client
: return
187 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
188 otk
.Property_atoms().net_wm_desktop
,
189 data
.client
.window(),num
)
191 def toggle_all_desktops(data
):
192 """Toggles between sending a client to all desktops and to the current
194 if not data
.client
: return
195 if not data
.client
.desktop() == 0xffffffff:
196 send_to_desktop(data
, 0xffffffff)
198 send_to_desktop(data
, ob
.openbox
.screen(data
.screen
).desktop())
200 def send_to_all_desktops(data
):
201 """Sends a client to all desktops"""
202 if not data
.client
: return
203 send_to_desktop(data
, 0xffffffff)
205 def send_to_next_desktop(data
, no_wrap
=0, follow
=1):
206 """Sends a window to the next desktop, optionally (by default) cycling
207 around to the first when going past the last. Also optionally moving to
208 the new desktop after sending the window."""
209 if not data
.client
: return
210 screen
= ob
.openbox
.screen(data
.screen
)
212 n
= screen
.numDesktops()
217 send_to_desktop(data
, d
)
219 change_desktop(data
, d
)
221 def send_to_prev_desktop(data
, no_wrap
=0, follow
=1):
222 """Sends a window to the previous desktop, optionally (by default) cycling
223 around to the last when going past the first. Also optionally moving to
224 the new desktop after sending the window."""
225 if not data
.client
: return
226 screen
= ob
.openbox
.screen(data
.screen
)
228 n
= screen
.numDesktops()
233 send_to_desktop(data
, d
)
235 change_desktop(data
, d
)
237 print "Loaded callbacks.py"