├── COPYING
├── ChangeLog
├── Makefile
├── README
├── doc
└── lxctrl.html
└── src
├── Makefile
├── lxctrl.c
├── xctrl.c
└── xctrl.h
/COPYING:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Library General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
28 | The functions described below are intended to be used in object-oriented style, for example:
36 | Note that only one instance of the xctrl object at a time is allowed to be in use.
37 | If for some reason you need to re-initialize a new object, you should set the old one
38 | to nil and call collectgarbage() twice before trying to create
39 | another new object. This will help insure that the first instance is properly cleaned up.
40 |
136 | Returns a new xctrl object. The default display is used if none was specified.
137 | If the optional as_utf8 argument is true,
138 | xctrl will attempt to use UTF-8 encoding for all strings passed to and from X11.
139 | If the optional charset string argument is present, it will try to use that value
140 | for character set conversions, otherwise it will use the $CHARSET environment variable if
141 | present, or fall back to a default of ISO_8859-1 .
142 |
143 |
146 | Returns an indexed list of all top-level window id numbers on the current display.
147 |
150 | Returns the title bar text of the specified window id.
151 |
154 | Sets the title bar text of the specified window id.
155 |
158 | Returns the X11 class name (WM_CLASS property) of the specified window id.
159 |
162 | Raises the specified window and gives it the focus. If the window is not on the current desktop,
163 | the desktop containing the window will also be activated, unless the optional switch
164 | argument is false.
165 |
168 | Changes the specified window's state to iconic or "minimized".
169 |
172 | Modify up to two of the window's properties simultaneously.
173 | The property change is achived by using the _NET_WM_STATE request.
174 | The mode string argument must be one of:
175 | "add", "remove" or "toggle"
176 | The supported property names (for p1 and p2) are:
189 |
190 |
191 |
194 | Adjust the location and/or size of the window.
195 |
196 | The x, y, w, h arguments
197 | are usually integers, but any of them may be nil, in which case that value
198 | will be ignored (i.e. unchanged.)
199 |
200 | For the alternate form, t is a table in the same format as returned
201 | by get_win_geom().
202 | Thus the following two calls are equivalent:
206 | The final argument g is optional and specifies the "gravity" (direction) of
207 | a resize operation.
223 | If successful, returns a table containing the x, y,
224 | w and h values of the specified window.
225 | On failure, returns nil plus an error message.
226 |
229 | If successful, returns a table containing the keys l, r,
230 | t, b which represent (respectively) the left, right, top,
231 | and bottom extents of the frame for the specified window.
232 | On failure, returns nil plus an error message.
233 |
236 | Returns a string representing the functional type of the specified window.
237 | The returned string will be one of:
238 |
248 | Note: Not all windows set this property, even if the window manager supports it. If a window's
249 | _NET_WM_WINDOW_TYPE property is not set, the type is assumed to be
250 | "dialog" if it has a WM_TRANSIENT_FOR property, or "normal" otherwise.
251 | Attempts to set the window manager decorations for the specified window.
254 | The decor argument is a table containing a list of strings, the following strings
255 | are valid elements for the table:
256 |
264 | Note: When the "none" or "all" string is used,
265 | it must be the only item in the list.
266 |
269 | Returns the window id number of the currently active window.
270 |
273 | Displays a "crosshair" mouse cursor allowing the user to select a window by mouse click.
274 | By default any button click selects the window, but the optional button argument
275 | allows you to specify which mouse button (1,2,3) will trigger the selection event.
276 | For example, you might want to ignore a left-click to minimize some other windows,
277 | and instead use a right-click (the third button) to pick the window you want.
278 | Caution: Don't specify button number three if you only have a two-button mouse!
279 |
280 | Returns the window id number of the clicked window.
281 |
284 | Returns the window id of the window manager's root window.
285 |
288 | Moves the window to the desktop at the specified desk index.
289 | (Note that the desktop indexes in Lua begin at one, not zero.)
290 |
293 | Returns the index of the desktop that contains the specified window.
294 |
297 | Returns the process id (PID) of the specified window, provided the application exports
298 | the _NET_WM_PID property.
299 |
303 |
304 |
307 | Returns the client machine's name, provided the application exports
308 | the WM_CLIENT_MACHINE property.
309 |
312 | Returns the configured number of desktops for the window manager.
313 |
316 | Changes the configured number of desktops for the window manager. (Not all window managers allow this.)
318 |
321 | Returns the index number of the active desktop.
322 | (Note that the desktop indexes in Lua begin at one, not zero.)
323 |
326 | Switch to the desktop at index desk.
327 |
330 | Returns the name of the current display.
331 |
334 | Returns the window id of the window manager's SUPPORTING_WM_CHECK window.
335 | This value is of little use, but unless it returns non-zero the
336 | get_wm_name,
337 | get_wm_class and
338 | get_wm_pid
339 | functions will also fail.
340 |
343 | Returns the window manager's name property (if supported).
344 |
347 | Returns the window manager's class property (if supported).
348 |
351 | Returns the window manager's process id (if supported).
352 |
355 | Returns the name of the desktop at index desk.
356 |
359 | Returns a table containing the x, y,
360 | w and h values of the effective working area
361 | for the desktop at index desk. This may be smaller than the
362 | actual desktop dimensions since it should exclude "reserved" areas like struts and taskbars.
363 |
366 | Returns a table containing the x, y,
367 | w and h values of the overall dimensions
368 | for the desktop at index desk.
369 |
372 | Sets the top left coordinates of the desktop (if supported).
373 |
376 | Sets the width and height of the desktop (if supported).
377 |
380 | Sets the window manager's _NET_SHOWING_DESKTOP property (if supported).
381 |
384 | Returns the window manager's _NET_SHOWING_DESKTOP property (if supported).
385 |
389 | Pushes the text into the X selection, clipboard, or cut buffer.
390 | The mode argument determines where the text is sent, and can be one of:
391 |
397 | If the optional utf8 argument is true, the text
398 | is considered to be in UTF-8 format.
399 |
400 | Note: For all modes except "b" this function is blocking,
401 | and will not return until another application requests the text or steals the selection.
402 |
407 | Retreives text from X selection, clipboard, or cut buffer.
408 | The mode argument determines which item is requested,
409 | as described in the set_selection() function.
410 | If the optional utf8 argument is true, the text
411 | is requested to be in UTF-8 format.
412 | Sends a series of keystrokes to the specified window, as if they were typed on the keyboard.
417 | Most printable characters are passed verbatim, but the following sequences are special: Hint: Key sequences for the delete, insert and navigation keys correspond to the alternate
443 | functions of the numeric keypad on a standard U.S. keyboard.
445 | Since this function only sends keystrokes to the application's top-level window, complex
446 | applications with nested widgets and cascading menus might not exhibit consistent results.
447 |
450 | Causes the library to sleep for approximately one-tenth of a second, and then sends an XSync()
451 | message to the display, which flushes the event queue and waits until all requests have been
452 | received and processed by the X server. This process is performed count
453 | number of times (default: once).
454 |
459 | Continuously "listens" for window manager events, and runs the function handler
460 | each time an event occurs.
461 | The event handler function should be in the form of:
462 |
468 | Note that the handler must return true to continue listening,
469 | or false to stop listening.
470 |
471 | The value of the string ev will be one of:
481 | Unless noted above, the value of the integer id is the ID of the window
482 | that triggered the event.
483 | Note: Rather than using expensive string comparisons on the value of ev, it may be
484 | more efficient to set up a table of functions as illustrated below:
485 | Window Manager Control Module
20 |
21 | The window manager control module (xctrl) is a Lua module which allows you to query and
22 | manipulate various aspects of an X11 window manager and the windows it manages. It is based
23 | largely on Tomas Styblo's wmctrl command line tool, but has been transformed
24 | into a C library with a Lua binding. It is intended to work with any EWMH / NetWM compatible
25 | window manager. Because support for these standards varies with different window managers
26 | and clients, some features might not work in all situations.
27 |
30 | require "xctrl" -- load the module
31 | local xc=xctrl.new() -- create a new xctrl object
32 | local win=xc:get_active_win() -- find the currently active window
33 | xc:close_win(win) -- close the window
34 |
35 |
41 |
43 | xctrl functions
45 |
46 |
133 |
48 | new (display [,as_utf8 [,charset]])
47 | -- Create a new xctrl object.
50 | get_win_list ()
49 | -- Return a list of all top-level windows.
52 | get_win_title (win)
51 | -- Get the title of a window.
54 | set_win_title (win,title)
53 | -- Set the title of a window.
56 | get_win_class ()
55 | -- Get the class name of a window.
58 | activate_win (win [,switch])
57 | -- Raise and focus a window.
60 | iconify_win(win)
59 | -- Change a window's state to iconic.
62 | set_win_state (win,mode,p1 [,p2])
61 | -- Change a window's state properties.
64 | set_win_geom (win,[x,y,w,h]|[t][,g])
63 | -- Move and/or resize a window
66 | get_win_geom (win)
65 | -- Get a window's size and position
68 | get_win_frame (win)
67 | -- Get the extents of a window's frame
70 | get_win_type (win)
69 | -- Get the functional type of a window
72 | set_win_decor (win, decor)
71 | -- Set the window manager decorations for a window
74 | get_active_win ()
73 | -- Get the id of the currently active window.
76 | pick_win ( [button] )
75 | -- Get the id of a window by clicking it with the mouse.
78 | root_win ()
77 | -- Get the id of the display's root window.
80 | set_desk_of_win (win,desk)
79 | -- Move a window onto another desktop.
82 | get_desk_of_win (win)
81 | -- Get the index of a window's desktop.
84 | get_pid_of_win (win)
83 | -- Get the process id of a window.
86 | close_win (win)
85 | -- Try to close a window gracefully.
88 | get_win_client (win)
87 | -- Get a window's client machine name.
90 | get_num_desks ()
89 | -- Get the total number of desktops.
92 | set_num_desks ()
91 | -- Set the total number of desktops.
94 | get_curr_desk ()
93 | -- Get the index of the current active desktop.
96 | set_curr_desk (desk)
95 | -- Switch to another desktop
98 | get_display ()
97 | -- Return the the X11 display name.
100 | get_wm_win ()
99 | -- Get the window manager's information window.
102 | get_wm_name ()
101 | -- Get the window manager's name.
104 | get_wm_class ()
103 | -- Get the window manager's class name.
106 | get_wm_pid ()
105 | -- Get the window manager's process id.
108 | get_desk_name (desk)
107 | -- Get the name of a desktop.
110 | get_workarea (desk)
109 | -- Get the effective working dimensions of a desktop.
112 | get_desk_geom (desk)
111 | -- Get the overall dimensions of a desktop.
114 | set_desk_vport (desk,x,y)
113 | -- Set a desktop's viewport x-y coordinates.
116 | set_desk_geom (desk,w,h)
115 | -- Set a desktop's dimensions.
118 | set_showing_desk (showing)
117 | -- Set window manager's "showing desktop" mode.
120 | get_showing_desk ()
119 | -- Get window manager's "showing desktop" mode.
122 | set_selection(text[,mode[,utf8]])
121 | -- Push text into X selection, clipboard, or cut buffer.
124 | get_selection ( [mode [,utf8] )
123 | -- Retreive text from X selection, clipboard, or cut buffer.
126 | send_keys (win,keys)
125 | -- Send simulated keyboard actions to a window.
128 | do_events( [count] )
127 | -- Flush the X server's event queue.
130 | listen (event_handler)
129 | -- Monitor the window manager for events.
132 | convert_locale (str,from,to)
131 | -- Convert string between locales.
134 | new ([display [,as_utf8 [,charset]]])
135 | get_win_list ()
145 | get_win_title (win)
149 | set_win_title (win,title)
153 | get_win_class ()
157 | activate_win (win [,switch])
161 | iconify_win (win)
167 | set_win_state (win,mode,p1 [,p2])
171 |
177 | "modal",
178 | "sticky",
179 | "maximized_vert",
180 | "maximized_horz",
181 | "shaded",
182 | "skip_taskbar",
183 | "skip_pager",
184 | "hidden",
185 | "fullscreen",
186 | "above"
187 | and
188 | "below" .set_win_geom (win,[x,y,w,h]|[t][,g])
193 |
203 | set_win_geom(win, 32, 64, 640, 480)
204 | set_win_geom(win, {x=32,y=64,w=640,h=480})
205 |
208 | If present, it must be one of the following strings:
209 | "default",
210 | "northwest",
211 | "north",
212 | "northeast",
213 | "west",
214 | "center",
215 | "east",
216 | "southwest",
217 | "south",
218 | "southeast",
219 | "static"
220 | get_win_geom (win)
222 | get_win_frame (win)
228 | get_win_type (win)
235 |
"desktop" -- A sreen-sized window containing desktop icons, usually kept below other windows.
239 |
"dock" -- A dock or panel, usually kept on top of all other windows.
240 |
"toolbar" -- An undocked or "torn off" toolbar window.
241 |
"menu" -- A "torn off" menu panel.
242 |
"utility" -- A small persistent window, such as a palette or toolbox.
243 |
"splash" -- A splash screen, temporarily displayed on application start-up.
244 |
"dialog" -- A dialog box or "transient" window.
245 |
"normal" -- A normal, top-level window.
246 |
"unsupported" -- The window manager does not support this property.
247 | set_win_decor (win, decor)
253 |
"none" -- The window will have no decorations.
257 |
"all" -- The window will have all decorations.
258 |
"border" -- The window will have a border.
259 |
"resize" -- The window will be resizable.
260 |
"title" -- The window will have a title bar.
261 |
"maximize" -- The title bar will have a maximize button.
262 |
"close" -- The title bar will have a close button.
263 | get_active_win ()
268 | pick_win ( [button] )
272 | root_win ()
283 | set_desk_of_win (win,desk)
287 | get_desk_of_win (win)
292 | get_pid_of_win (win)
296 | close_win (win)
301 | Attempts to gracefully close the specified window.
302 | get_win_client (win)
306 | get_num_desks ()
311 | set_num_desks ()
315 | get_curr_desk ()
320 | set_curr_desk (desk)
325 | get_display ()
329 | get_wm_win ()
333 | get_wm_name ()
342 | get_wm_class ()
346 | get_wm_pid ()
350 | get_desk_name (desk)
354 | get_workarea (desk)
358 | get_desk_geom (desk)
365 | set_desk_vport (desk,x,y)
371 | set_desk_geom (desk,w,h)
375 | set_showing_desk (showing)
379 | get_showing_desk ()
383 | set_selection (text [,mode [,utf8]] )
388 |
392 | "p" : The primary selection (default).
393 | "s" : The secondary selection.
394 | "c" : The clipboard.
395 | "b" : The cut buffer.
396 | get_selection ( [mode [,utf8]] )
406 | send_keys (win,keys)
416 |
418 |
419 |
442 |
420 | \n The Enter key.
421 | \t The Tab key.
422 | \27 The Esc key.
423 | \b The Backspace key.
424 | ^ The next key is passed with the Ctrl key pressed.
425 | ~ The next key is passed with the Alt key pressed.
426 | + The next key is passed with the Shift key pressed.
427 | %^ A literal ^
428 | %~ A literal ~
429 | %+ A literal +
430 | %% A literal %
431 | %Fxx A function key, where xx is 01 thru 12
432 | %. The Delete key.
433 | %0 The Insert key.
434 | %1 The End key.
435 | %2 The Down arrow key.
436 | %3 The PageDown key.
437 | %4 The Left arrow key.
438 | %6 The Right arrow key.
439 | %7 The Home key.
440 | %8 The Up arrow key.
441 | %9 The PageUp key. do_events ( [count] )
449 | listen ( handler )
458 | function event_handler(ev,id)
463 | -- handle the event here
464 | return true
465 | end
466 |
467 |
472 | "w" -- A new window was created.
473 | "x" -- The window was closed (its id is no longer valid!).
474 | "a" -- The window was activated (gained focus).
475 | "i" -- The window became inactive (lost focus).
476 | "g" -- The window's exterior geometry changed (size, position, or decoration).
477 | "t" -- The window's title text changed.
478 | "s" -- The window's state changed (iconified, maximized, sticky, layer, etc.)
479 | "d" -- Switched desktops: in this case id is the index of the activated desktop.
480 |
486 | local xc=xctrl.new()
487 |
488 | local event_callbacks = {
489 | w = function(id)
490 | io.write("A new window ",id, " was created.\n")
491 | return true
492 | end,
493 | x = function(id)
494 | io.write("The window ", id, " was closed.\n")
495 | return true
496 | end,
497 | a = function(id)
498 | io.write("The window ", id, " was activated.\n")
499 | return true
500 | end,
501 | i = function(id)
502 | io.write("The window ", id, " became inactive.\n")
503 | return true
504 | end,
505 | g = function(id)
506 | io.write("The window ", id, " geometry changed.\n")
507 | return true
508 | end,
509 | t = function(id)
510 | io.write("The window ", id, " title changed.\n")
511 | return true
512 | end,
513 | s = function(id)
514 | io.write("The window ", id, " state changed.\n")
515 | return true
516 | end,
517 | d = function(id)
518 | io.write("Switched to desktop number ", id, ".\n")
519 | return true
520 | end
521 | }
522 |
523 | function my_event_handler(ev,id)
524 | local callback=event_callbacks[ev]
525 | if callback ~= nil then
526 | return callback(id)
527 | else
528 | return true
529 | end
530 | end
531 |
532 | xc:listen(my_event_handler)
533 |
534 |
535 |
543 | Converts the string str from its original encoding from
544 | into the new encoding to and returns the new string.
545 |