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_skip_taskbar(data
, add
=StateAdd
):
40 """Toggles, adds or removes the 'skip_taskbar' state on a window.
41 The second paramater should one of: StateRemove, StateAdd, or
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_taskbar
)
48 def state_skip_pager(data
, add
=StateAdd
):
49 """Toggles, adds or removes the 'skip_pager' state on a window.
50 The second paramater should one of: StateRemove, StateAdd, or
52 if not data
.client
: return
53 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
54 otk
.Property_atoms().net_wm_state
, data
.client
.window(),
55 add
, otk
.Property_atoms().net_wm_state_skip_pager
)
58 """Iconifies the window on which the event occured"""
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(), 3) # IconicState
65 """Un-iconifies the window on which the event occured, but does not focus
66 if. If you want to focus the window too, it is recommended that you
67 use the activate() function."""
68 if not data
.client
: return
69 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
70 otk
.Property_atoms().wm_change_state
,
71 data
.client
.window(), 1) # NormalState
74 """Closes the window on which the event occured"""
75 if not data
.client
: return
76 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
77 otk
.Property_atoms().net_close_window
,
78 data
.client
.window(), 0)
81 """Focuses the window on which the event occured"""
82 if not data
.client
: return
83 # !normal windows dont get focus from window enter events
84 if data
.action
== ob
.EventAction
.EnterWindow
and not data
.client
.normal():
88 def restart(data
, other
= ""):
89 """Restarts openbox, optionally starting another window manager."""
90 ob
.openbox
.restart(other
)
93 """Raises the window on which the event occured"""
94 if not data
.client
: return
95 ob
.openbox
.screen(data
.screen
).raiseWindow(data
.client
)
98 """Lowers the window on which the event occured"""
99 if not data
.client
: return
100 ob
.openbox
.screen(data
.screen
).lowerWindow(data
.client
)
102 def toggle_shade(data
):
103 """Toggles the shade status of the window on which the event occured"""
104 state_shaded(data
, StateToggle
)
107 """Shades the window on which the event occured"""
108 state_shaded(data
, StateAdd
)
111 """Unshades the window on which the event occured"""
112 state_shaded(data
, StateRemove
)
114 def change_desktop(data
, num
):
115 """Switches to a specified desktop"""
116 root
= otk
.display
.screenInfo(data
.screen
).rootWindow()
117 ob
.send_client_msg(root
, otk
.Property_atoms().net_current_desktop
,
120 def next_desktop(data
, no_wrap
=0):
121 """Switches to the next desktop, optionally (by default) cycling around to
122 the first when going past the last."""
123 screen
= ob
.openbox
.screen(data
.screen
)
125 n
= screen
.numDesktops()
130 change_desktop(data
, d
)
132 def prev_desktop(data
, no_wrap
=0):
133 """Switches to the previous desktop, optionally (by default) cycling around
134 to the last when going past the first."""
135 screen
= ob
.openbox
.screen(data
.screen
)
137 n
= screen
.numDesktops()
142 change_desktop(data
, d
)
144 def send_to_desktop(data
, num
):
145 """Sends a client to a specified desktop"""
146 if not data
.client
: return
147 ob
.send_client_msg(otk
.display
.screenInfo(data
.screen
).rootWindow(),
148 otk
.Property_atoms().net_wm_desktop
,
149 data
.client
.window(),num
)
151 def toggle_all_desktops(data
):
152 """Toggles between sending a client to all desktops and to the current
154 if not data
.client
: return
155 if not data
.client
.desktop() == 0xffffffff:
156 send_to_desktop(data
, 0xffffffff)
158 send_to_desktop(data
, ob
.openbox
.screen(data
.screen
).desktop())
160 def send_to_all_desktops(data
):
161 """Sends a client to all desktops"""
162 if not data
.client
: return
163 send_to_desktop(data
, 0xffffffff)
165 def send_to_next_desktop(data
, no_wrap
=0, follow
=1):
166 """Sends a window to the next desktop, optionally (by default) cycling
167 around to the first when going past the last. Also optionally moving to
168 the new desktop after sending the window."""
169 if not data
.client
: return
170 screen
= ob
.openbox
.screen(data
.screen
)
172 n
= screen
.numDesktops()
177 send_to_desktop(data
, d
)
179 change_desktop(data
, d
)
181 def send_to_prev_desktop(data
, no_wrap
=0, follow
=1):
182 """Sends a window to the previous desktop, optionally (by default) cycling
183 around to the last when going past the first. Also optionally moving to
184 the new desktop after sending the window."""
185 if not data
.client
: return
186 screen
= ob
.openbox
.screen(data
.screen
)
188 n
= screen
.numDesktops()
193 send_to_desktop(data
, d
)
195 change_desktop(data
, d
)
197 print "Loaded callbacks.py"