1 ############################################################################
2 ### Functions that can be used as callbacks for mouse/keyboard bindings ###
3 ############################################################################
5 #############################################################################
6 ### Options that can be modified to change the default hooks' behaviors. ###
8 #############################################################################
13 def state_above(data
, add
=2):
14 """Toggles, adds or removes the 'above' state on a window."""
15 if not data
.client
: return
16 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
17 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
18 add
, otk
.Property_atoms().net_wm_state_above
)
20 def state_below(data
, add
=2):
21 """Toggles, adds or removes the 'below' state on a window."""
22 if not data
.client
: return
23 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
24 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
25 add
, otk
.Property_atoms().net_wm_state_below
)
27 def state_shaded(data
, add
=2):
28 """Toggles, adds or removes the 'shaded' state on a window."""
29 if not data
.client
: return
30 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
31 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
32 add
, otk
.Property_atoms().net_wm_state_shaded
)
34 def state_skip_taskbar(data
, add
=2):
35 """Toggles, adds or removes the 'skip_taskbar' state on a window."""
36 if not data
.client
: return
37 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
38 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
39 add
, otk
.Property_atoms().net_wm_state_skip_taskbar
)
41 def state_skip_pager(data
, add
=2):
42 """Toggles, adds or removes the 'skip_pager' state on a window."""
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_skip_pager
)
49 """Iconifies the window on which the event occured"""
50 if not data
.client
: return
51 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
52 otk
.Property_atoms().wm_change_state
,
53 data
.client
.window(), 3) # IconicState
56 """Un-iconifies the window on which the event occured, but does not focus
57 if. If you want to focus the window too, it is recommended that you
58 use the activate() function."""
59 if not data
.client
: return
60 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
61 otk
.Property_atoms().wm_change_state
,
62 data
.client
.window(), 1) # NormalState
65 """Closes the window on which the event occured"""
66 if not data
.client
: return
67 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
68 otk
.Property_atoms().net_close_window
,
69 data
.client
.window(), 0)
72 """Focuses the window on which the event occured"""
73 if not data
.client
: return
74 # !normal windows dont get focus from window enter events
75 if data
.action
== ob
.EventAction
.EnterWindow
and not data
.client
.normal():
79 def restart(data
, other
= ""):
80 """Restarts openbox, optionally starting another window manager."""
81 ob
.openbox
.restart(other
)
84 """Raises the window on which the event occured"""
85 if not data
.client
: return
86 ob
.openbox
.screen(data
.screen
).raiseWindow(data
.client
)
89 """Lowers the window on which the event occured"""
90 if not data
.client
: return
91 ob
.openbox
.screen(data
.screen
).lowerWindow(data
.client
)
93 def toggle_shade(data
):
94 """Toggles the shade status of the window on which the event occured"""
98 """Shades the window on which the event occured"""
102 """Unshades the window on which the event occured"""
103 state_shaded(data
, 0)
105 def change_desktop(data
, num
):
106 """Switches to a specified desktop"""
107 root
= otk
.display
.screenInfo(data
.screen
).rootWindow()
108 ob
.send_client_msg(root
, otk
.Property_atoms().net_current_desktop
,
111 def next_desktop(data
, no_wrap
=0):
112 """Switches to the next desktop, optionally (by default) cycling around to
113 the first when going past the last."""
114 screen
= ob
.openbox
.screen(data
.screen
)
116 n
= screen
.numDesktops()
121 change_desktop(data
, d
)
123 def prev_desktop(data
, no_wrap
=0):
124 """Switches to the previous desktop, optionally (by default) cycling around
125 to the last when going past the first."""
126 screen
= ob
.openbox
.screen(data
.screen
)
128 n
= screen
.numDesktops()
133 change_desktop(data
, d
)
135 def send_to_desktop(data
, num
):
136 """Sends a client to a specified desktop"""
137 if not data
.client
: return
138 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
139 otk
.Property_atoms().net_wm_desktop
,
140 data
.client
.window(),num
)
142 def toggle_all_desktops(data
):
143 """Toggles between sending a client to all desktops and to the current
145 if not data
.client
: return
146 if not data
.client
.desktop() == 0xffffffff:
147 send_to_desktop(data
, 0xffffffff)
149 send_to_desktop(data
, openbox
.screen(data
.screen
).desktop())
151 def send_to_all_desktops(data
):
152 """Sends a client to all desktops"""
153 if not data
.client
: return
154 send_to_desktop(data
, 0xffffffff)
156 def send_to_next_desktop(data
, no_wrap
=0, follow
=1):
157 """Sends a window to the next desktop, optionally (by default) cycling
158 around to the first when going past the last. Also optionally moving to
159 the new desktop after sending the window."""
160 if not data
.client
: return
161 screen
= ob
.openbox
.screen(data
.screen
)
163 n
= screen
.numDesktops()
168 send_to_desktop(data
, d
)
170 change_desktop(data
, d
)
172 def send_to_prev_desktop(data
, no_wrap
=0, follow
=1):
173 """Sends a window to the previous desktop, optionally (by default) cycling
174 around to the last when going past the first. Also optionally moving to
175 the new desktop after sending the window."""
176 if not data
.client
: return
177 screen
= ob
.openbox
.screen(data
.screen
)
179 n
= screen
.numDesktops()
184 send_to_desktop(data
, d
)
186 change_desktop(data
, d
)
188 print "Loaded callbacks.py"