Better support for option cleanup in python package
[adesklets.git] / doc / adesklets_en.texi
blob990502230cd3077bcb0e5c8702cd15184fe05272
1 \input texinfo   @c -*-texinfo-*-
2 @comment %**start of header
3 @setfilename adesklets_en.info
4 @include version_en.texi
5 @settitle adesklets @value{VERSION}
6 @syncodeindex pg cp
7 @comment %**end of header
8 @copying
9 This manual is for adesklets (version @value{VERSION}, @value{UPDATED}).
11 Copyright @copyright{} 2004, 2005 Sylvain Fourmanoit
12 @email{syfou@@users.sourceforge.net}.
14 Various corrections and updates by Mike Pirnat
15 @email{exilejedi@@users.sourceforge.net}.
17 @quotation
18 Permission is granted to copy, distribute and/or modify this document
19 under the terms of the GNU General Public License, Version 2 or
20 any later version published by the Free Software Foundation. 
21 A copy of the license is included in the appendix entitled 
22 ``Copying This Manual''.
24 @end quotation
25 @end copying
27 @c Define useful weblink macro
28 @macro weblink{link}
29 @html
30 <a href="
31 @end html
32 \link\
33 @html
34 ">\link\</a>
35 @end html
36 @end macro
38 @c Define weblink2 macro: a variation on the previous one
39 @macro weblink2{desk,link}
40 @html
41 <a href="\link\">
42 @end html
43 \desk\
44 @html
45 </a>
46 @end html
47 @end macro
49 @dircategory Graphics
50 @direntry
51 * adesklets: (adesklets).      Another desklets container.
52 @end direntry
54 @titlepage
55 @title adesklets
56 @subtitle for version @value{VERSION}, @value{UPDATED}
57 @author Sylvain Fourmanoit (@email{syfou@@users.sourceforge.net})
58 @author Mike Pirnat (@email{exilejedi@@users.sourceforge.net})
59 @page
60 @vskip 0pt plus 1filll
61 @insertcopying
62 @end titlepage
64 @contents
66 @ifnottex
67 @node Top
68 @top adesklets
70 @ifnothtml
71 Follow those links for documentation in other languages
72 (@xref{Top,French version, About adesklets, adesklets_fr,}.).
73 @end ifnothtml
74 @ifhtml
75 @weblink2{[French version],../fr/index.html}
76 @end ifhtml
78 @insertcopying
79 @end ifnottex
81 @menu
82 * About adesklets::
83 * What's new?::
84 * Installing adesklets::
85 * Using adesklets::
86 * Programming adesklets::
87 * Extending adesklets::
88 * Help wanted!::
89 * Frequently asked questions::
90 @ifhtml
91 * Python package documentation::
92 @end ifhtml
93 * Imlib2 documentation::
94 * Packaging GNU Makefile for desklets::
95 * Submitting a desklet::
96 * Copying This Manual::
97 * Open PGP Public Key::
98 * Index::
99 @end menu
101 @noindent The current version of this document can be found online at
102 @weblink{http://adesklets.sf.net/}.
104 @noindent Screenshots, source tarballs, etc. can also be found on
105 the project home page: @weblink{http://sf.net/projects/adesklets/}.
107 @node About adesklets
108 @chapter What is adesklets?
110 @section Short answer
112 @command{adesklets} is an interactive
113 @weblink2{Imlib2,http://www.enlightenment.org/pages/imlib2.html} console
114 for the X Window System. It provides scripted languages with a clean and 
115 simple way to write great looking, mildly interactive desktop integrated
116 graphic applets (aka ``desklets'').
118 It can also be used as a command line oriented graphic editor, a bit similar
119 to @weblink2{ImageMagick,http://www.imagemagick.org/}, but with different
120 functionality.
122 @section Long answer
124 @command{adesklets} stands for ``another desklets [container]''. It was
125 written as an alternative to other programs such as:
127 @enumerate
128 @item
129 gDesklets (@weblink{http://gdesklets.gnomedesktop.org/})
130 @item
131 SuperKaramba (@weblink{http://netdragon.sourceforge.net/}).
132 @item
133 GKrellM (@weblink{http://www.gkrellm.net/})
134 @end enumerate
136 Since this is 'a'desklets, others still have plenty of space to start similar
137 projets, from 'b'desklets to 'z', excluding 'g', which is already taken.
139 Seriously though, all those packages are nice. Nevertheless, the first two
140 have very heavy requirements in terms of library dependencies; basically,
141 gDesklets still requires a fair part of the GNOME environment to be installed 
142 (plus specialized libraries such as gnome-python@footnote{A report on this has 
143 been produced; you may find it online in PDF format at 
144 @weblink{http://adesklets.sf.net/verbatim/gdesklets.pdf}.}), while 
145 SuperKaramba needs almost all of the KDE libraries and base environment.
146 This also reflects on performance for the task at hand@footnote{Of course, this
147 is only the author's opinion--and both applications are making big progress on
148 resource efficiency from version to version.}. On the other hand, while GKrellM
149 is significantly lighter (it still depends on GTK+ though), it does not deliver
150 the same experience in terms of ``eye-candiness'' (to the author's taste, of
151 course) or ``scriptability'' than the other two.
153 Thus, @command{adesklets} was born. It provides:
155 @itemize
156 @item
157 a minimal framework for X Window desklets seamlessly integrated into the
158 desktop, with an easy to use central management for starting, positioning 
159 and stopping them.
160 @item
161 a generic, rich and easy to use drawing API similar to gDesklets and
162 SuperKaramba regarding its high visual quality, thanks to the Imlib2 library.
163 @item
164 very limited library dependencies: uses the very good (and lightning fast)
165 Imlib2 library for all graphic-related operations. No window toolkit used
166 whatsoever; the program relies directly on xlib.
167 @item
168 a light, robust and small interpreter potentially usable with all sorts of
169 scripting languages thanks to a clean, limited and homogenous syntax. As
170 on version
171 @value{VERSION}, support for Python is provided out of the box. Future support
172 for Perl and Ruby is planned. Feel free to contribute support for your
173 favorite language!
174 @item
175 Minimal disk space, memory footprint and CPU usage. Typically, on glibc 2.3.4
176 Linux 2.6 x86, a unique executable is less than 130 KB on disk, takes less than
177 3 MB of virtual memory per desklet right after initialization, and almost no
178 processor cycles (including cycles from a Python interpreted script) when idle.
179 @end itemize
181 It DOES NOT provide:
183 @itemize
184 @item
185 A sophisticated window API, or even access to widgets besides bare, ugly grey
186 menus.  You clearly cannot write any GUI application with this--only
187 ``desklets''.
188 @item
189 Convoluted mechanisms (or just plain mechanisms, for that matter) for
190 script configuration. Script developers are free (or doomed, depending on how
191 you see things) to do whatever they see fit.
192 @item
193 Support for everything that is not a truly POSIX compliant system. For
194 instance, it would be very surprising if this would ever compile on Cygwin.
195 @item
196 Feature-rich management of user events. @command{adesklets} aims at low
197 resource consumption and reliability; only a small set of events, mainly 
198 pointer-related, are exposed through its API.
199 @end itemize
201 @node What's new?
202 @chapter What's new?
204 @heading What's new in version 0.4.10
205 This is a bug fix release. An unwanted partial new feature made is way 
206 into previous release: it caused the contextual menu to stop working 
207 the advertised way (the control key needed to be pressed for the menu to
208 get fired). This release just revert back the change, and add a 
209 configuration-time option, --enable-control-on-context-menu, for
210 those who really wants this behavior.
212 @heading What's new in version 0.4.9
213 This is a bug fix release. It changes the global macro definitions for
214 adesklets to compile without problems on FreeBSD 6.x, corrects an error
215 with debugging flag stripping from the C compiler, and adds a new demo 
216 program about threading.
218 @heading What's new in version 0.4.8
219 This is a bug fix release. It changes the global macro definitions for
220 adesklets to compile without problems on FreeBSD 5.x, and it also adds
221 fake root window detection for KDE, thanks to yogi77, from the forum.
223 @heading What's new in version 0.4.7
224 This is a bug fix release. It removes calls to some C99 math routines not
225 available in earlier BSD's, making the code more portable. It also adds 
226 two new commands to the API for handling the image caching mechanism better.
228 @heading What's new in version 0.4.6
229 This is a bug fix and documentation update release. It corrects many small
230 bugs inside the desklets submission process scripts, makes portability changes
231 to the autoconf structure, adds a new demo scripts in test (widget.py), corrects
232 the xwindow_move_window routine for a small placement bugs on the screen (thanks
233 to man1ed from the forum from providing the patch), and finally adds a new
234 appendix containing a handy online version of the Imlib2 documentation.
236 @heading What's new in version 0.4.5
237 This is a bug fix and documentation update release. It improves the desklets
238 submission process by releasing the full check-in script used by the maintainer.
239 It also solves a bug with window refresh when using user-defined background
240 image and menus; thanks to ZeroDivide for reporting this. Various updates and
241 corrections have also been made to the documentation.
242       
243 @heading What's new in version 0.4.4
244 This is a documentation update release, principally aimed at desklet 
245 authors. It basically includes a new appendix on how to submit a desklet 
246 (including scripted support), and a new subsection on system-wide font
247 detection as well. The FAQ was also expanded to cover this topic.
249 @heading What's new in version 0.4.3
250 This is a documentation update release. Most of the work here was made by 
251 Mike Pirnat @email{exilejedi@@users.sourceforge.net}, who was kind enough 
252 to rectify the base author's deficient english by proofreading this manual 
253 from cover to cover. Thanks Mike! The FAQ was also slightly expanded, and 
254 a new appendix for desklets writer created.
256 @heading What's new in version 0.4.2
257 This is a new bug fix release. It corrects a bug within the Python package
258 that made it not compile on all versions of Python prior to 2.4.0. Thanks to 
259 nucular, from the adesklets forum, for reporting this. It also corrects another
260 minor mmap-related issue in the same package.
262 @heading What's new in version 0.4.1
263 This is a new bug fix release. It secures the use of the optional 
264 @code{adesklets.ConfigFile} class by completely changing 
265 the way config files are imported, thus removing a potential 
266 security exploit. Thanks to Mike Pirnat @email{exilejedi@@users.sourceforge.net}
267 for sharing his concerns on this issue.
269 @heading What's new in version 0.4.0
270 This is a new minor version release. The interpreter now supports
271 internationalization. It can now dynamically work with different
272 character sets on platforms supporting iconv (as standardized in UNIX98), and
273 display them in the right fashion. The Python package was also extended
274 to include an (optional) generic configuration class, hopefully useful
275 to desklets authors.
277 @heading What's new in version 0.3.2
278 This is a documentation update release. Documentation was added for Python
279 programmers, and the FAQ was slightly expanded.
281 @heading What's new in version 0.3.1
282 This is new bug fix release. It just adds support for interruption of time gates
283 by events. This is a feature absolutely required to make some timed effects 
284 possible.
286 @heading What's new in version 0.3.0
287 This is a new minor version release. Portability has been a big concern for us
288 since the beginning; with this version, the package compiles and runs flawlessly
289 on FreeBSD and NetBSD (@xref{Portability}.). Event handling has also been 
290 internally streamlined, and the Python binding was extended to support 
291 dynamic modification of caught events (see @file{test/test_events.py}).
293 The interpreter API now exposes everything the author wanted, 
294 and will probably not be expanded much further; everything is pretty much
295 in place to write any desklet, including animations.
297 @heading What's new in version 0.2.1
298 This is a minor bug fix release which removes a compatibility bug within
299 the GNU history library usage. Thanks to Mike Pirnat 
300 @email{exilejedi@@users.sourceforge.net} for reporting this.
302 @heading What's new in version 0.2.0
303 This is a new minor version release. Support was added for textual variables
304 (string substitution, in fact), and execution of timed preregistered
305 sequences of commands to the interpreter (indirect mode of execution).
306 This gives desklets a way to perform fluid animations. Run the demo script
307 @file{test/fading.py} from the source package to see those features in action.
309 For developers, this version also includes a rewritten, dynamically
310 configurable debug interface to the interpreter able to generate complete 
311 logs on any session.
313 @heading Details
314 See @file{Changelog} for all details.
316 @ifplaintext
317 @c Sets up a marker for automated INSTALL file generation
318 INSTALL_BEG
319 @node Installing adesklets
320 @unnumbered Installing adesklets
321 @end ifplaintext
322 @ifnotplaintext
323 @node Installing adesklets
324 @chapter Installing adesklets
325 @end ifnotplaintext
327 @section Compilation Requirements
329 To compile adesklets from source, you will need:
331 @itemize
332 @item
333 A compiler supporting ANSI C plus variadic macros (about every version
334 of @weblink2{gcc,http://gcc.gnu.org} from 2.7.0 will do - or about
335 everything else published in the last ten years, for that matter)
336 @item
337 @weblink2{X11,http://www.x.org/} libraries and
338 headers@footnote{Except for headless builds, useful
339 for server environments and such; read further for details.}
340 @item
341 Imlib2 1.1.2 and up (the more recent the better; go and fetch it from
342 @weblink{http://sourceforge.net/projects/enlightenment/})
343 @item
344 @weblink2{GNU readline,http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html}
345 @item
346 A reasonably POSIX-compliant system
347 @end itemize
349 @noindent It can also use, if present in the system:
351 @itemize
352 @item
353 @weblink2{fontconfig,http://www.fontconfig.org/}, for automated detection of
354 all usable fonts present in the system
355 @item
356 @weblink2{GNU history,http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html},
357 the faithful complement to GNU readline for command history support
358 @item
359 iconv library and headers (such
360 as @weblink2{libiconv,http://www.gnu.org/software/libiconv/}), for 
361 internationalization support (dynamic support of extended character sets)
362 @item
363 @weblink2{Python,http://www.python.org} 2.3 and up, if you want Python support
364 (you most probably do at this stage as it's the only scripted language that's
365 currently supported)
366 @end itemize
368 @section Portability Notice
369 @anchor{Portability}
370 This package was built with portability in mind: all vendor-specific
371 extensions were avoided, and specs (ANSI, SVID 3, BSD 4.3, POSIX) were followed
372 in a conservative way. Nevertheless, original development took place on a single
373 Linux system; it is quite probable that adesklets will not compile or work as 
374 expected in some cases. Fixing portability issues is an important concern for us.
376 adesklets has been ported and successfully tested by the developers on many
377 systems. As of version @value{VERSION}, it has been verified to compile and run
378 out of the box on:
380 @itemize
381 @item Linux 2.4 i386, glibc 2.1.3, gcc 2.95.2 (Debian Woody)
382 @item Linux 2.6 i686, glibc 2.3.4, gcc 3.4.3 (Gentoo Linux 2005.0)
383 @item Linux 2.6 amd64, glibc 2.3.3, gcc 3.4.2 (Fedora Core release 3)
384 @item Linux 2.6 amd64, glibc 2.3.4, gcc 3.4.3 (Gentoo Linux 2005.0)
385 @item FreeBSD i386, gcc 2.95.4 (4.10-BETA)
386 @item NetBSD i386, gcc 2.95.3 (1.6.1)
387 @end itemize
389 @strong{Update}: adesklets >=0.4.8 has also been reported to work on 
390 FreeBSD 5.3, but the author did not have a chance to verify this. Now 
391 that adesklets is in Debian unstable, it seems to at least compile on all
392 available kernels and architectures: go see @weblink{http://packages.debian.org/unstable/x11/adesklets}.
394 Did you try to run the package on something not listed here?
395 Let us know, especially if it did not work.
397 @section Software download
399 The current version of the software (as a source bzip'ed tarball) can be found
400 on the SourceForge project page: @weblink{http://sf.net/projects/adesklets/}
402 You can extract it from the console with @command{tar}. As of version
403 @value{VERSION}, the command line would be:
405 @example
406 tar xvjf adesklets-@value{VERSION}.tar.bz2
407 @end example
409 or, if your installed version of @command{tar} does not support
410 filtering archives through bzip2:
412 @example
413 bzcat adesklets-@value{VERSION}.tar.bz2 | tar xv
414 @end example
416 @section Verifying Software Integrity (optional)
418 As of adesklets @value{VERSION},  you can also
419 download from @weblink2{SourceForge,http://sf.net/projects/adesklets/} an 
420 ascii-armored detached signature named 
421 @command{adesklets-@value{VERSION}.tar.bz2.asc}, that you can match
422 against the author's Open PGP public key (@pxref{Open PGP Public Key},
423 in appendix) to assert the package integrity. For instance, with
424 @command{GnuPG} (@weblink{http://www.gnupg.org/}), you would use:
426 @example
427 gpg --verify adesklets-@value{VERSION}.tar.bz2.asc adesklets-@value{VERSION}.tar.bz2
428 @end example
430 You can also get the public key for @email{syfou@@users.sourceforge.net}
431 from various public key servers such as @weblink{http://www.keyserver.net/} or
432 @weblink{http://pgp.mit.edu/}. Feel free to contact the author directly if you
433 want to authenticate the key further.
435 @section Compilation and Installation:
437 adesklets provides the usual autoconf/automake scripts of GNU packages.
439 Therefore, in most cases, installation follows the normal three steps:
441 @enumerate
442 @item
443 `cd' to the directory containing the package's source code and type
444 `./configure' to configure the package for your system.  If you're
445 using `csh' on an old version of System V, you might need to type
446 `sh ./configure' instead to prevent `csh' from trying to execute
447 `configure' itself.
449 Running `configure' takes awhile.  While running, it prints some
450 messages describing which features it is checking for.
451 @item
452 Type `make' to compile the package.
453 @item
454 Type `make install' to install the programs and any data files and
455 documentation.
456 @end enumerate
458 You can remove the program binaries and object files from the
459 source code directory by typing `make clean'.  To also remove the
460 files that `configure' created (so you can compile the package for
461 a different kind of computer), type `make distclean'.
463 @section Compilers and Options:
465 Some systems require unusual options for compilation or linking that
466 the `configure' script does not know about.  You can give `configure'
467 initial values for variables by setting them in the environment.  Using
468 a Bourne-compatible shell, you can do that on the command line like
469 this:
471 @example
472 CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
473 @end example
475 @noindent Or on systems that have the `env' program, you can do it like this:
477 @example
478 env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
479 @end example
481 @section Optional Features:
483 adesklets comes with a few optional features you can select or not
484 from the `configure' script. Type:
486 @example
487 ./configure --help
488 @end example
490 @noindent for a complete, short description. Here are a few interesting ones:
492 @itemize
493 @item
494 You may choose to compile adesklets without X support at all
495 (@command{--without-x}).
496 You will get a version that is obviously not suited for
497 desklets rendering, but still good for command line image manipulation
498 @item
499 You can remove support for some others packages as well:
500 @command{--without-history}, @command{--without-fontconfig}
501 @end itemize
504 @node Using adesklets
507 @chapter Using adesklets
509 @ifplaintext 
510 INSTALL_END
511 @end ifplaintext
513 @section ... As a desklets container
515 By itself, adesklets does little: it only provides what is needed to
516 do more! You either need to tell it what to do by passing it commands
517 (see the next section) or you need other scripts (the desklets)
518 that will drive it for you.
520 @noindent Right now, only a very few desklets have been released: 
521 you may find them on the SourceForge projet page as separate downloads:
522 @weblink{http://sf.net/projects/adesklets/}. They will give you a feel
523 of what @command{adesklets} is capable of.
525 @subsection Add a new desklet to your X display
526 To add a new desklet script, simply:
528 @enumerate
529 @item
530 Download its tarball and unpack it somewhere in your home directory
531 @item
532 Look at the included README file; special requirements or instructions
533 will be given. Usually, all you have to do is to get adesklets installed,
534 your X server running, then launch the executable script file from the
535 base directory.
536 @end enumerate
538 @noindent Please note that:
540 @itemize
541 @item
542 Launching the same desklet script more than once will start multiple instances of it.
543 @item
544 On multi-head displays, scripts will be launched on their inherited default 
545 screen.  (For instance, if you do nothing special, calling a script from an
546 xterm on screen 1 will launch the desklet on screen 1).
547 @end itemize
549 @noindent Most of the time, desklets scripts are made to run as long as you
550 do not tell them to quit. The user has total control of starting, stopping,
551 restarting (when possible), and positionning the desklet (using the context menu, 
552 always available by right-clicking on the desklet). The desklet has 
553 no control over those operations.
555 @noindent Those few user settings are stored in the @file{$HOME/.adesklets}
556 file. Usually, you do not want to edit this file yourself.
557 If you do, make sure no instances of @command{adesklets} are running at
558 the same time.
560 @unnumberedsubsubsec Special notes on system fonts
562 @emph{You may safely skip this section if you do not intend to use
563 non-supplied fonts with adesklets.}
565 Provided your system supports fontconfig (@weblink{http://www.fontconfig.org/})
566 and adesklets was compiled without using @code{--without-fontconfig} (compiling
567 with fontconfig support is the default; @xref{Installing adesklets}.), all the
568 TrueType fonts present in your system are available for use with adesklets.
569 At initialization time, adesklets with fontconfig support compiled in will go
570 through all the fonts detected on your system to identify all the TrueType 
571 fonts. See your fontconfig documentation on how to set up your application
572 fonts access properly (@xref{Frequently asked questions}, for some fontconfig
573 debugging hints). It's also good to know that adesklets' package includes a
574 copy of Bitstream's Vera font; all users can rely on @command{adesklets} 
575 having at least this font available at all time.
577 @unnumberedsubsubsec Special notes on internationalization
579 @emph{You may safely skip this section if you do not intend to use
580 extended charaters within your desklets.}
582 If your system includes @command{iconv} support (@xref{Installing adesklets}.),
583 you should be able to use any character from any charsets your system 
584 knows about for displaying text, either inside a desklet or in its menus,
585 provided you have appropriate TrueType fonts (i.e. TrueType fonts containing
586 those character representations)@footnote{For instance, Bitstream's Vera font 
587 included with @command{adesklets} contains glyphs for practically all Latin-1
588 (ISO-8859-1) characters.}. 
590 Nevertheless, when using extended (outside 7-bit @code{ASCII}) characters, 
591 you need to make sure your local GNU readline settings do not interfere. These
592 three parameters should be set as indicated below in the appropriate 
593 @file{initrc} file@footnote{Please refer to your GNU readline documentation}:
595 @example
596 set input-meta on
597 set convert-meta off
598 output-meta on
599 @end example
601 If you do not want to adapt your GNU readline settings, you can also pass the
602 @code{--enable-force-extended-characters-input} switch to the @code{configure}
603 script when configuring the package from source, which will cause those three
604 variables to always be appropriately overriden internally by the interpreter.
606 Of course, you will also need desklets built to use those extended characters.
607 At the time of writing, all non-contributed Python desklets support them; for 
608 those, the charset can be set by the user in the configuration file, when it 
609 exists@footnote{When it does not exist, it means the desklet does not need 
610 internationalization anyway}; users merely have to set the 'coding' line 
611 appropriately@footnote{See @weblink{http://python.fyxm.net/peps/pep-0263.html}
612 if you need details.}.
614 For instance, for using ISO Latin-1 characters, one should use something 
615 similar to:
617 @example
618 # -*- coding: ISO-8859-1 -*-
619 @end example
621 as the first or second line in the Python desklet configuration file@footnote{
622 Obviously, such a configuration file needs to be saved using ISO Latin-1 
623 encoding or any subset of it, such as @code{ASCII}.}. 
625 Finally, please note that if your platform does not support iconv,
626 you should always leave the coding parameter to @code{ASCII}, otherwise
627 you will get fatal errors such as @code{charset conversion not compiled in}
628 from the desklets.
630 @subsection Restore previously running desklets on new X session
631 Invoking @command{adesklets} without any arguments:
633 @example
634 adesklets
635 @end example
637 @noindent is enough to restart all desklets that were running the
638 last time you killed the X server (in this mode, @command{adesklets}
639 will exit quickly by itself: there is no need to run it in the
640 background. adesklets does not use a daemon; each applet will fork a 
641 standalone @command{adesklets} interpreter as a child process). 
642 Invoking @command{adesklets} when desklets are already running
643 will cause them to be killed before the creation of new 
644 instances@footnote{Both @command{adesklets} process and their immediate parents
645 will be sent a @command{SIGKILL} signal.}.
647 @noindent If you plan on using desklets on a regular basis, you should put
648 the previous @code{adesklets} command somewhere in your X session
649 initialization.  I cannot tell you where with precision, as it varies greatly
650 from system to system. Have a look at: 
651 @weblink{http://www.google.ca/search?q=''x window''+startup} for general help.
653 @section ... As a command-line graphic editor
655 You can also use adesklets as a command-oriented graphic editor.
656 If you type, in a console:
658 @example
659 adesklets :
660 @end example
662 @noindent You will get something similar to:
664 @anchor{prompt}
665 @example
666 adesklets 0.1.0 (Fri Jan 28 19:09:13 EST 2005), on Linux 2.6.10
667 [gcc 3.4.3 20041125 (Gentoo Linux 3.4.3-r1, ssp-3.4.3-0, pie-8.7.7)]
668 Press TAB for hints.
669 0 >>> _
670 @end example
672 @noindent The last line is a prompt. It tells you you are ready
673 to enter command number 0. As of adesklets @value{VERSION}, you have around
674 150 commands at your fingertips. Thanks to GNU readline, a lot of
675 autocompletion hooks are present, giving you an easy way to look around. 
676 Press TAB while typing a  command name or a command's first argument, and 
677 useful information will be displayed. @xref{primer,,an adesklets's primer}, 
678 for more info.
680 @node Programming adesklets
681 @chapter Programming adesklets
682 @section An adesklets' primer
683 @anchor{primer}
685 As previously stated (@xref{About adesklets}.), adesklets is basically an
686 interactive Imlib2 console, with one or two aditionnal features:
688 @itemize
689 @item
690 When an X display is present, automated management of a single window
691 @item
692 Automated support for pseudo-transparency
693 @item
694 Management of long-running applets
695 @end itemize
697 @noindent So let's start a typical interactive session to see what
698 happens. Under X, open a terminal, and type:
700 @example
701 adesklets :
702 @end example
704 @noindent As in last section (@xref{prompt,,'Using adesklets as a command-line
705 graphic editor'}.),
706 you will get a prompt. Now, enter the command '@code{images_info}'. You should
707 get on stdout:
709 @example
710 2 images
711 id 0 width 1 height 1 alpha 1 filename (null)
712 id 1 width 1 height 1 alpha 1 filename (null)
713 command 0 ok: images_info
714 @end example
716 @noindent This tells you that you have two images: image 0 and image 1, each
717 1x1 pixels. Those are the only images you can never destroy nor do any
718 operations you want with (resize them independently, flip them diagonaly, etc.)
719 Why is that?
721 @itemize
722 @item
723 Image 0 is the foreground image. By default, it is the only image that is
724 displayed on the single window that @command{adesklets} manages.
725 @item
726 Image 1 is the background image. By default, it always contains the content
727 of the root window (the desktop) directly below the window.  Unless we set it
728 to be otherwise, it is always updated when the user moves it, when you resize
729 it, when your wallpaper changes, etc.
730 @end itemize
732 @noindent But where is this window? Well, right know, it is only 1x1 pixels,
733 and it is not shown@footnote{``Mapped'' in X Window lingo} on the screen.
734 So let's resize it to 100x100 pixels: type '@code{window_resize 100 100}'.
735 Now, if you re-enter the command '@code{images_info}', you will get:
737 @example
738 2 images
739 id 0 width 100 height 100 alpha 1 filename (null)
740 id 1 width 100 height 100 alpha 1 filename (null)
741 command 2 ok: images_info
742 @end example
744 @noindent The foreground and background images have been resized to
745 100x100 pixels.  Moreover, the background image has been updated to contain
746 a new image of the background. Now, let's make this window visible. Type two 
747 commands: '@code{window_reset managed}' and then '@code{window_show}'.
749 @noindent The first command tell adesklets to let your window manager
750 ``manage'' your window (the default is not to); it means the window gets
751 decorated, and you can interactively change its visibility@footnote{An
752 ``unmanaged'' window is very useful for scripted desklets: it looks like
753 it is part of the root window as it can be made to never go on top, and to stay
754 mapped when workspaces are switched.}. The second command shows our 100x100 
755 window. So far, it's nothing too impressive--just a black 100x100 square with a
756 titlebar and fixed-size borders.
758 @noindent As mentioned above, only image 0 (the foreground) is displayed by
759 default. Now, type: '@code{window_set_transparency 1}'. Wow! We see the
760 root window below! With ``window transparency'' on, the image 1 (background)
761 is first copied onto the window, then image 0 (foreground) which is purely
762 transparent black, is blended onto it@footnote{Well...Not quite. Actually,
763 there is a buffer involved for performance, but the operation is logically
764 equivalent to this description.}.
766 @noindent It is time to say a word about colors. Remember, adesklets is an 
767 Imlib2 console. Thus, as with Imlib2@footnote{Keep your Imlib2 documentation 
768 nearby; it is very handy! @xref{Imlib2 documentation}.}, colors are 
769 always true 32 colors, RGBA encoded, with eight bits (0 to 255) per channel,
770 including an alpha channel for transparency. Palette conversion and such will 
771 automatically take place if your screen depth is less than that, so you do not
772 need to bother with that. If you type: '@code{context_get_color}', you will get:
774 @example
775 command 0 ok: context color 255 255 255 255
776 @end example
778 @noindent Imlib2 is a kind of state machine; as such, it comes with a
779 ``context'' that remembers a series of attributes it will use in its future 
780 operations. For instance, we now know the color it will use as long as we do not
781 modify it is opaque pure white (red=255, blue=255, green=255, alpha=255). If we type: '@code{context_get_image}', it returns:
783 @example
784 command 0 ok: context image 0
785 @end example
787 @noindent Which means all window operations we perform are made directly on
788 the forgeground image. So, let's draw a filled semi-transparent magenta 
789 rectangle on the foreground. Commands could be: 
790 '@code{context_set_color 255 0 0 200}' and 
791 '@code{image_fill_rectangle 25 25 50 50}'. Neat, isn't it?
793 @noindent If you are used to Imlib2 programming, you will have noticed
794 by now those last few commands look quite familiar. This is pretty normal;
795 most of Imlib2 C functions are presented as corresponding 'commands' in
796 adesklets. This way, adesklets' command '@code{image_fill_rectangle}'
797 follows the same semantic as Imlib2's '@code{imlib_image_fill_rectangle()}'
798 function, the command '@code{context_set_color}' functions just like
799 '@code{imlib_context_set_color()}', etc. The only two significant (and
800 systematic) differences are that whenever you would use an 
801 '@code{Imlib_Something}' object in C, you use an integer ID with adesklets,
802 and on the semantic of the '@code{imlib_free_something()}' functions that need
803 to be given an ID instead of freeing the context selected object of this type.
805 @noindent This is pretty easy to illustrate. Let's load the ``Vera'' font 
806 included with adesklets at a 20pt size, set it as default font, and write in 
807 pure opaque white ``Hello'' diagonally on the foreground image from the top left
808 corner before unloading the font. It would look like:
810 @example
811 6 >>> load_font Vera/20
812 command 6 ok: new font 0
813 7 >>> context_set_font 0
814 command 7 ok: context_set_font 0
815 8 >>> context_set_direction text_to_angle
816 command 8 ok: context_set_direction text_to_angle
817 9 >>> context_set_angle 45
818 command 9 ok: context_set_angle 45
819 10 >>> context_set_color 255 255 255 255
820 command 10 ok: context_set_color 255 255 255 255
821 11 >>> text_draw 0 0 Hello
822 command 11 ok: text_draw 0 0 Hello
823 12 >>> free_font 0
824 command 12 ok: free_font 0
825 @end example
827 @noindent If you look at your imlib2 documentation, you will immediatly notice
828 the two differences we just talked about:  all references to the font Vera/20
829 are made through an integer ID (0 here), and the '@code{free_font}' command, 
830 unlike the corresponding '@code{imlib_free_font()}' function, is called with
831 the font ID as an argument instead of the context font.
833 @noindent Now let's say you want to save you resulting image; not a problem!
834 Let us type: '@code{save_image out.png}', and the foreground is saved in the
835 file ``out.png'' in the current working directory@footnote{For this to work, 
836 you need to have your Imlib2 installation properly configured for using libpng,
837 or you could receive a ``no loader for file format'' error.}. Now, just for 
838 the sake of it, let us exit adesklets, and start another interactive session
839 to see if we can reload this image. Just type in the ``@code{quit}'' command or
840 press ^D (Control D: end of file). Then your new session should look something like:
842 @example
843 0 >>> window_resize 100 100
844 command 0 ok: window_resize 100 100
845 1 >>> window_reset managed
846 command 1 ok: window_reset managed
847 2 >>> window_set_transparency 1
848 command 2 ok: window_set_transparency 1
849 3 >>> load_image out.png
850 command 3 ok: new image 2
851 4 >>> blend_image_onto_image 2 1 0 0 100 100 0 0 100 100
852 command 4 ok: blend_image_onto_image 2 1 0 0 100 100 0 0 100 100
853 5 >>> window_show
854 command 5 ok: window_show
855 6 >>> free_image 2
856 command 6 ok: free_image 2
857 @end example
859 @noindent Of course, we wanted to visualize the result; this is why we
860 emitted commands '@code{window_reset}', '@code{window_set_transparency}'
861 and '@code{window_show}'; they are not otherwise useful. The command
862 '@code{blend_image_onto_image}' comes straight from Imlib2 once again;
863 it takes the newly created image 2 from the third command and blends it
864 onto the context image (image 0, foreground by default), for its coordinates
865 (0,0) to 100x100 pixels farther, and puts it on the rectangle starting at (0,0)
866 of size 100x100 pixels of image 0. It is finally good to note that, with
867 adesklets, there is always an image in Imlib2 context: whenever you try to
868 free the current image, the image context is always reset to the foreground 
869 image.
871 @noindent OK, so it is almost the end of this primer... From there you should
872 play around with adesklets.  It is pretty straightforward to use if you are 
873 already familiar with Imlib2. If you are not, your best resource is certainly 
874 having Imlib2 documentation not far away. :-)
876 @noindent Some last tips:
878 @itemize
879 @item
880 If you get tired of typing, and typing, do not forget you have autocompletion:
881 'TAB' your problems away!
882 @item
883 If you want to have hints on how to do something, you have a built-in
884 '@code{help}' command.
885 @item
886 If you are working out a series of commands, things are not working
887 and all this interactive usage it getting tiresome:
888 @enumerate
889 @item
890 Use the '@code{history}' command to output your current session to a
891 file@footnote{For this to work, you need to have GNU history when
892 building adesklets.}.
893 @item
894 Use the '-f' switch with adesklets to get commands from a file instead
895 of the console tty.
896 @item
897 If you try to visualise something, insert a '@code{pause}' command at the
898 end of the script to freeze the interpreter.
899 @item
900 All strings from a pound sign '#' to the end of a line will get discarded,
901 allowing you to write comments.
902 @end enumerate
903 @end itemize
905 @noindent Here is an example:
907 @example
908 #!/usr/bin/env adesklets -f
910 # Make the window 'managed'
912 window_reset managed
914 # Resize the window to 100x100 pixels
916 window_resize 100 100
918 # Show the window, then freeze for 10 seconds before exiting
920 window_show
921 pause 10
922 @end example
924 @noindent You will just have to make this script executable and run it. As
925 usual, output from the commands will get printed to stdout.
927 @itemize
928 @item You could also use the @code{play} command. This two-arguments command
929 gives you a way to replay any sequence of commands from history, using the 
930 command number of the first and last command as parameters.
931 @end itemize
933 @section Real programming with adesklets: writing desklet scripts
935 When you are ready for real work@footnote{:-)}, you might want to use
936 a real scripted language instead of the raw @command{adesklets} interpreter we
937 used in the primer; you never know when just having variables could come in 
938 handy.
940 At the time of this writing (@value{UPDATED}), the Python package is included 
941 @footnote{adesklets was written to be easily used from a variety of interpreted
942 languages; future plans includes wrappers for Perl and Ruby--do not hesitate 
943 to propose your help if you want to speed things up!}, and the Perl 5 binding
944 is under way.
946 @subsection General tips for programmers
948 A really useful feature of the @command{adesklets} interpreter 
949 is its ability to produce a full trace of its session (commands, events and
950 special messages), either on @code{stdeerr} or as a log file, independently
951 of what is driving it. To have access to this feature, one must:
953 @enumerate
954 @item Configure the package from source, passing along the @code{--enable-debug}
955 switch to @code{configure}.
956 @item Export the @code{ADESKLETS_LOG} variable in the environment if 
957 the session's output should to be stored in files instead of printed
958 to @code{stderr}@footnote{Printing to @code{stderr} will break most bindings, 
959 and should therefore be used mainly when invoking the interpreter directly 
960 from the console.}. It should be an absolute filename prefix which the
961 interpreter, inheriting from the environment, can use to create complete file
962 names to write to.
963 @end enumerate
964 From there, it is possible to read complete chronological session logs;
965 used correcly, it is very useful for debugging purposes. You can use 
966 it in conjunction with the @code{echo} command to set easy to find log points.
968 @subsection adesklets and Python 
969 @unnumberedsubsubsec Python usage example
970 From Python, things are not very different than from the interpreter.
971 Commands have been wrapped into Python functions, and an @code{Events_handler} 
972 class has been made public to handle asynchronous feedback from the
973 interpreter.  Let's have a look at the @file{test/test.py} script from the
974 source tarball of version @value{VERSION}:
976 @verbatiminclude ../test/test.py
978 That's it! Twenty-six lines of Python code, and we have a perfectly functionnal
979 desklet. I think things are pretty self-explanatory; have a look at the
980 Python online help for @code{adesklets}, @code{adesklets.commands} and 
981 @code{adesklets.Events_handler} for a good, complete explanation
982 @ifhtml
983 (@xref{Python package documentation}.)
984 @end ifhtml
985 .  All we do here is:
987 @enumerate
988 @item
989 Import the @code{adesklets} package:
990 this automatically instantiates a child @command{adesklets} process and sets up
991 all communications.  When the package initialization returns without raising
992 any exception, it means the interpreter is up and ready to accept commands.
993 @item
994 Subclass @code{adesklets.Events_handler} and redefine the methods invoked
995 for the events we are interested in (all other events are not just ignored,
996 they are not generated).
997 @item
998 Instantiate an object of this class, and put it on hold indefinitely
999 @footnote{This last step is not mandatory; the script may very well continue,
1000 but it should be written so that it supports signal interruptions. See
1001 @code{help(adesklets.Events_handler)} for further explanations}.
1002 @end enumerate 
1004 @unnumberedsubsubsec Gotchas: a bit more about object IDs
1006 All adesklets objects (fonts, images, color ranges, polygons, etc), are stored 
1007 in stacks (one stack per object type). Python's ID's are nothing more than the 
1008 initial position of given objects inside the relevant stack, and therefore 
1009 will become invalid if an object of the same type below them gets freed.
1011 For instance, if we start with a clean state, all we have in the stack of 
1012 images is the window's foreground (ID 0) and background (ID 1). 
1013 When someone creates two other images from Python like so: 
1014 @example
1015 im_1 = adesklets.create_image(10,10)
1016 im_2 = adesklets.create_image(10,10)
1017 @end example
1018 @noindent We get @code{im_1==1}, and @code{im_2==2}. Whenever someones does:
1019 @example
1020 adesklets.free_image(im_1) 
1021 @end example
1022 @noindent The stack starts collapsing, and what was once image 3 (@code{im_1}) 
1023 is now image 2, and @code{im_2} is now an invalid reference. This clearly means 
1024 that invoking:
1025 @example
1026 adesklets.free_image(im_2) 
1027 @end example
1028 @noindent would generate an @code{image out of range} error message.
1030 @unnumberedsubsubsec Special subject: animations
1032 @command{adesklets} now includes an indirect mode of execution and textual 
1033 variables (non-recursive textual replacements, to be precise) as well. 
1034 This means desklets writers have what is needed to create precisely-timed
1035 animations. You can find an easy-to-follow example in @file{test/fading.py}.
1036 A somewhat more involved use of these features is also made in the @code{yab}
1037 desklet. To realize an animation from Python, one should:
1039 @enumerate
1040 @item @strong{Record} a sequence of commands 
1041 (we will call it a macro command, or macro for now on). From Python, this
1042 involves toggling on indirect mode using the @code{adesklets.start_recording()}
1043 function, emitting an undetermined number of @command{adesklets} commands,
1044 then toggling back into normal mode (direct execution) with 
1045 @code{adesklets.stop_recording()}. Of course, no command is ever evaluated
1046 while the interpreter is in indirect mode; commands are only stored in the
1047 history for future replay.
1048 @item @strong{Set up} whether the to-be-replayed sequence of commands can be
1049 interrupted by events or not, using the @code{adesklets.play_set_abort_on_events()}
1050 function. The high-level @code{adesklets.Events_handler::set_events()} method
1051 can also be used to dynamicaly change what events are caught. See 
1052 @file{test/test_events.py} for an example.
1053 @item @strong{Set up} the variables used within the recorded macro using the 
1054 @code{adesklets.set()} function, very similar to its Bourne shell homonym.
1055 @item @strong{Play} the macro using the @code{adesklets.play()} function.
1056 @end enumerate
1058 Here are a few additional remarks:
1059 @itemize
1060 @item Precise timing during replay is achieved through the @code{time_gate}
1061 command. This works very simply: every time a macro replays, adesklets
1062 records its starting time, and whenever a @code{time_gate} command is
1063 encountered during the replay, it waits for the number of seconds given as
1064 an argument to @code{time_gate} to run out. For instance, specifing
1065 @code{time_gate 0.1} in a macro will make any subsequent commands within the
1066 macro not execute before the macro has run for at least a tenth of second.
1067 @item Variable expansion always occurs just before command execution, regardless
1068 of current interpreter mode (direct or indirect). All sequences of characters
1069 not containing spaces directly following a single '$' will get replaced with
1070 the corresponding variable content (previously configured using @code{set}).
1071 If no matching variable is found, the sequence is simply discarded.
1072 @item All macro commands replayed through the @code{play} command are always 
1073 atomic for the driving desklet, as are any other non-macro commands. 
1074 Simply put, it means no event will ever get generated while a macro is replayed;
1075 they will all get issued right after the @code{play} command returns.
1076 @item As usual, the adesklets interpreter is stateful for indirect mode related 
1077 states and variables. You do not have to set up the @code{set_abort_on_events}
1078 flags or variable every time you want to call a macro, only if something
1079 needs to be changed since the last call.
1080 @item The main use of high-level @code{adesklets.Events_handler::set_events()}
1081 is to stop the catching of specific events during macro playback, so the macro
1082 can be interrupted only in specific circumstances. Of course, all events
1083 generated before the call to the method will not be lost but queued, and
1084 appropriate event methods will be called later, provided the handlers are set 
1085 back once the macro playback completes.
1086 @item Did we mention that it is a bad idea to do any of this from an unprotected
1087 place? Well, it is. Don't forget to use @code{adesklets.Events_handler::block()}
1088 and @code{adesklets.Events_handler::unblock()} around all animation-related code
1089 if you have an object of a child class of @code{adesklets.Events_handler}
1090 instantiated.
1091 @end itemize
1093 @unnumberedsubsubsec Configuration and internationalization
1095 Let us just mention here that from @command{adesklets} 0.4.0, the
1096 @code{adesklets.utils} module now includes an optional 
1097 @code{ConfigFile} class that can be easily reused by desklets authors 
1098 to add an easily extendable configuration facility to their 
1099 code@footnote{You can look at any non-contributed configurable desklet for 
1100 example usage.}
1101 @ifhtml
1102 (@xref{Python package documentation}.)
1103 @end ifhtml
1104 . The class also handles internationalization automatically by default, 
1105 setting the charsets according to users' needs. Charset usage can of course 
1106 be determined or changed at any time using the @code{adesklets.get_charset()}
1107 and  @code{adesklets.set_charset()} functions. The 
1108 @code{adesklets.utils.ConfigFile} class also has a @code{charset} attribute one
1109 can examine to determine the user's preference. When using this class, one
1110 should  note that an 'ASCII' charset is considered the default, and will not 
1111 toggle any conversion. This way, users on platforms not supporting iconv will 
1112 always be able to use @command{adesklets} without internationalization support.
1114 @unnumberedsubsubsec Final words
1116 @noindent Finally, let us mention you may want to take a look at the 
1117 @file{weather} desklet source code from the
1118 @weblink2{SourceForge project web site,http://sourceforge.net/projects/adesklets/} 
1119 for a more substantial piece of Python code using adesklets. There are also a 
1120 few other test desklets under @file{test/} that may give you some ideas.
1121 @ifhtml
1122 You could also have a look at pydoc's autogenerated
1123 @command{adesklets} package help, included with this document
1124 (@xref{Python package documentation}.). Whenever you are happy enough with 
1125 your desklet, feel free to share it with the rest of us (this would be 
1126 much appreciated)--package it (@xref{Packaging GNU Makefile for desklets}.), 
1127 and then submit it (@xref{Submitting a desklet}.).
1128 @end ifhtml
1130 @node Extending adesklets
1131 @chapter Using adesklets from other language environments
1133 adesklets was made to be easily usable from a variety of langage
1134 environments@footnote{We use the term ``langage environment'' because the 
1135 problem is not the syntax or the paradigm used (should it be imperative, 
1136 functional, or anything else); it is the way you can handle basic POSIX-related
1137 operations with files, signals, etc. (@xref{Requirements}.). Thus, a Perl 5 
1138 user should use adesklets easily, while a Linux JDK user would probably 
1139 encounter more difficulties (no flames intended).}. This chapter explains 
1140 to programmers how the adesklets interpreter hooks itself into the system 
1141 in a language-neutral fashion.
1143 @noindent If you are not minimally used to POSIX systems or do not have basic 
1144 notions on operating system programming, this chapter is probably of no
1145 interest to you.
1147 @noindent Please note that the Python package under 
1148 @file{scripting/python/adesklets} 
1149 is a good complement for what you are about to read.
1151 @section Requirements 
1152 @anchor{Requirements}
1153 If you want to use the adesklets interpreter from your favorite language
1154 but it is not supported out of the box@footnote{As of adesklets
1155 @value{VERSION}, only Python is supported out of the box.}, you can still do
1156 it, provided your langague supports one of these features:
1158 @itemize
1159 @item Reading and writing in pipes; or
1160 @item Reading and writing from/to files unbuffered 
1161 @end itemize
1163 @noindent It should also be able to either@footnote{This said, having both IPC
1164 support and poll/select will make things both simplier and cleaner. Being able 
1165 to block signals is also very useful.}:
1167 @itemize
1168 @item Catch IPC reliable signals; or
1169 @item Read files in non-blocking mode; or
1170 @item Be able to perform a poll/select on files
1171 @end itemize
1173 @noindent Finally, it should also be able to start a child process. 
1175 @noindent Those a pretty light requirements from a POSIX point of view, but let
1176 us mention for the sake of completeness that if your language environment does
1177 not meet these requirements, you could still use it provided you can get your
1178 application to talk reliably with another program@footnote{This would be a
1179 wrapper, basically.} that meets them. Of course, this is not an ideal situation
1180 and it should be avoided as much as possible.
1182 @section Initialization mechanism
1184 As you probably know (@xref{Using adesklets}.), there are two modes of operation
1185 for @command{adesklets}, as it can be called:
1187 @enumerate
1188 @item as a desklets launcher--whenever you call @command{adesklets} without 
1189 arguments.
1190 @item as an interpreter--in all other cases (interactive command line use
1191 or a child process from a desklet).
1192 @end enumerate
1194 @subsection adesklets called as a desklets launcher - restarting all desklets 
1195 @noindent On a new X session, the typical startup sequence is:
1197 @enumerate
1198 @item @command{adesklets} gets called without arguments, somewhere 
1199 from the X session initialization scripts.
1200 @item From there, the new adesklets instance acts as a desklets launcher. 
1201 It parses the @file{$HOME/.adesklets file}, then forks as many times as there 
1202 are desklets to start.  The original launcher process then exits as there is
1203 no need for a daemon here.
1204 @item All forked processes set up the @code{ADESKLETS_ID} environment variable
1205 with a string representation of the proper integer ID, then execute
1206 @footnote{With a call from the execve* family; see @code{man 2 execve}.} 
1207 the associated script.
1208 @item Each desklet launches itself an @command{adesklets} instance as a child
1209 process, passing along the @code{ADESKLETS_ID} variable without altering it. 
1210 It is the desklet's duty to make sure that:
1211 @itemize
1212 @item the adesklets interpreter standard streams, 
1213 @code{stdin}, @code{stdout} and @code{stderr}, get separately redirected, 
1214 in a way that parent process can easily write to adesklets' @code{stdin}, 
1215 and read from @code{stdout} and @code{stderr}. Use of pipes, FIFOs or event
1216 regular files are all possible.
1217 @item the writes to @code{stdin} and reads to the two other streams are 
1218 all unbuffered.
1219 @item the first command argument given to @command{adesklets} is the absolute
1220 file name of the desklet script.
1221 @end itemize
1222 @item Each newly created @command{adesklets} interpreter process initializes 
1223 itself using the environment @code{ADESKLETS_ID} variable and the command
1224 line absolute desklet name given as its first argument to lookup its 
1225 unscriptable characteristics@footnote{They are, namely, its screen and 
1226 coordinates.} from @file{$HOME/.adesklets}. When this operation is over, 
1227 the @code{ready!} event is generated (@xref{Events}.), and the interpreter is 
1228 ready to process commands.
1229 @end enumerate
1231 @subsection adesklets called as an interpreter - registration of a new desklet
1233 When a new desklet gets called directly, the startup sequence described in
1234 the previous subsection is the same, except for the first, second and third
1235 steps which simply don't occur. This means that the environment 
1236 @code{ADESKLETS_ID} is not set; the new @command{adesklets} interpreter uses 
1237 this fact to detect this is a new desklet, parse the @file{$HOME/.adesklets}
1238 configuration file and allocate the first free ID to the desklet.
1240 @noindent It should be noted that if the desklet file name given as the first 
1241 argument to the child @command{adesklets} instance is relative or is not both
1242 readable and executable by the current user, the desklet will not get registered
1243 in @file{$HOME/.adesklets}, and therefore not automatically restarted in 
1244 subsequent new X sessions by the launcher. In case @code{stdin} is a 
1245 terminal@footnote{Which means the session is interactive}, the registration
1246 does not take place either.
1248 @subsection Consequences
1249 This way, from the scripted desklet perspective, both cases are identical, and
1250 no conditionnal treatment is needed. All the desklet initialization job 
1251 is synthesized in the fourth point in the subsection above.
1253 @noindent If needed later on, the desklet can use the @code{get_id} command 
1254 to determine its ID.
1256 @section Using streams
1258 As explained previously, a desklet communicates with its private adesklets 
1259 interpreter via redirected unbuffered streams. Here, let us see what information
1260 they convey.
1262 @subsection stdin: the commands
1264 On the interpreter's @code{stdin}, the desklet outputs the commands it wants to
1265 execute in the order in which it wants them to be executed, one command per 
1266 line@footnote{A '\n' character should be emitted after each command.}. Since 
1267 reading this stream is suspended while a command is processed, a desklet should
1268 generally wait for a command to be processed before emitting 
1269 another@footnote{This is to avoid process blocking by overflowing the stream 
1270 with arbitrarily long commands; of course, there is no problem sending three
1271 commands of a few hundred bytes in one shot!} (See the next section).
1273 @noindent The command format is pretty simple: it is a command name, followed 
1274 by arguments separated by spaces, all in plain text representation, including 
1275 numbers. adesklets does not care about the number of spaces between arguments,
1276 as long as there is at least one. In the special case of commands where the
1277 last argument is a string (@code{text_draw}, for instance), adesklets will
1278 choose its first non-space characters to be its beginning; the rest of the
1279 line, including spaces, are considered to be part of the string.
1281 @noindent Two files, automatically kept in sync with the source 
1282 (@file{scripting/prototypes} and  @file{scripting/enums}) from the base source
1283 distribution, provide in tab-separated plain text format the description of all
1284 the commands and numeric constants that can be made available to the 
1285 desklets@footnote{See @file{scripting/protoize.sh.in} and 
1286 @file{scripting/enums.sh} for details on the format of the two files.}. A good 
1287 binding for a specific language should come with some automation to
1288 auto-generate pertinent parts of its own codebase based on those files; for
1289 instance, the Python binding adds a @code{protoize} action to its 
1290 @file{setup.py} @code{distutils} script to do so. Ideally, this automation code
1291 should be redacted in the target language with a reasonable set of 
1292 libraries@footnote{The key idea being that most users of your binding should be
1293 able to run it more or less from their base installation of the language.}; 
1294 if it is not well suited to this task, you need to limit yourself to use:
1296 @itemize
1297 @item Portable Bourne shell, conforming to POSIX 1003.2 and 1003.2a, scripts
1298 @item A recent sed (Streaming Editor), compatible with GNU
1299 sed@footnote{Nowadays, there is no problem running GNU sed on practically any
1300 POSIX system.}
1301 @item Portable use of any bc for arithmetic
1302 @end itemize
1304 @noindent if you want your work to become part of the official package.
1306 @subsection stdout: the command results
1308 The @command{adesklets} interpreter frequently polls its @code{stdin} 
1309 for new characters, and reads from it as needed. Whenever it receives an
1310 End-Of-Line ('\n'), it stops reading from it and tries executing the command. 
1311 Once the command has been carried out (possibly emitting a few lines on
1312 @code{stdout}), it sends as its last entry on it a status message of the form:
1314 @example
1315 command RANK ok: MESSAGE_STRING
1316 @end example
1318 @noindent if the command was successful, or:
1320 @example
1321 command RANK error: ERROR_STRING
1322 @end example
1324 @noindent if an error occurred.
1326 @noindent @code{RANK} is the numerical ID of the command (an unsigned integer)
1327 that starts at zero when the interpreter is created, and then is automatically
1328 incremented by one for every subsquent line it receives. All commands are 
1329 guaranteed to be processed in the order they were submitted. 
1330 @code{ERROR_STRING} is a free-form message in human-readable form explaining the
1331 source of the error. @code{MESSAGE_STRING} is also in human-readable form, but
1332 is formatted in such a way that it can be used to retrieve algorithmically
1333 useful return values for any commands. Those return values can be:
1335 @enumerate
1336 @item an integer--the return value ID (@code{create_image} and such)
1337 @item a tuple of integers--the numerical command output 
1338 (for @code{context_get_color} and the like)
1339 @item a list of strings--the ordered list of output strings 
1340 (for @code{images_info} and the like) for commands that output multiple lines
1341 on @code{stdout}, with the last line being the status message 
1342 @item a description string--a one-line textual answer from the command
1343 @item nothing at all
1344 @end enumerate
1346 @noindent Algorithmically, your "return value retrieving routine" should first
1347 try to retrieve integers from 
1348 @code{MESSAGE_STRING}@footnote{All parameters from the @code{MESSAGE_STRING}
1349 are separated by single spaces.}. If there is one or more integers present, 
1350 it should verify that the message is not a mere copy of an emitted command;
1351 if it is, the return value follows the fifth case (see above); otherwise, 
1352 if only one integer is found, this is the first case; if more than one is
1353 found, the second one.  If no integers are found and there was a list of lines 
1354 sent to stdout before the status message of the command, and after the status
1355 message of the previous command, it then returns according to third case.
1356 In what's left, if the status message is different from the emitted command, it
1357 is the fourth case. All remaining conditions should be mapped to the fifth
1358 case. This retrieving algorithm is working for all commands listed in
1359 @file{scripting/prototypes}.
1361 @subsection stderr: the events
1362 @anchor{Events}
1364 All remaining asynchronous event reports are sent to the interpreter's
1365 @code{stderr}. They are asynchronous regarding the processing of commands;
1366 if they will never occur while a command is processed (in the time interval
1367 between the submission of the complete command on @code{stdin} and the output
1368 of its message status line on @code{stdout}), they can be sent at any other
1369 time@footnote{No event is ever lost anyway; its report is only delayed.}.
1371 @noindent Event reports are single lines of the form@footnote{All other outputs
1372 on @code{stderr} can safely be discarded.}:
1374 @example
1375 event: EVENT_MESSAGE
1376 @end example
1378 @noindent In a stylized Backus Naur form, the grammar for EVENT_MESSAGE would 
1381 @verbatim
1382 EVENT_MESSAGE :: ready! |
1383                  backgroundgrab |
1384                  menufire MENU_ID MENU_STR |
1385                  motionnotify X Y |
1386                  enternotify X Y | 
1387                  leavenotify X Y |
1388                  buttonpress X Y BUTTON_ID |
1389                  buttonrelease X Y BUTTON_ID
1391 @end verbatim
1393 @noindent where @code{MENU_ID}, @code{X}, @code{Y}, and @code{BUTTON_ID} are
1394 all integers greater than or equal to zero, and @code{MENU_STR} is a string of
1395 characters, possibly including spaces. Let us detail things a bit further:
1397 @itemize
1398 @item Ready event: sent only once, whenever the @command{adesklets} interpreter
1399 becomes ready to process commands.
1400 @item BackgroundGrab event: sent every time the background image (image 1) gets 
1401 regenerated.
1402 @item MenuFire event: sent every time the user select an item in a menu not
1403 managed internally by adesklets.
1404 @item MotionNotify event: sent whenever the pointer moves inside the adesklets 
1405 window.
1406 @item EnterNotify, LeaveNotify: sent whenever the cursor passes over a visible
1407 border of the interpreter window, either going in or out.
1408 @item ButtonPress, ButtonRelease: sent when a pointer button is clicked inside 
1409 the interpreter window.
1410 @end itemize
1412 @noindent All events but Ready! (namely: MotionNotify, EnterNotify, 
1413 LeaveNotify, ButtonPress, ButtonRelease, BackgroundGrab and MenuFire) are
1414 masquable by the desklet. In fact, @command{adesklets} provides the desklet
1415 with commands for specifically handling the generation and output of events.
1416 They are: 
1417 @code{event_catch}, @code{events_get_send_sigusr1}, @code{events_reset_all},
1418 @code{event_uncatch}, @code{events_info}, @code{events_set_echo}, 
1419 @code{events_get_echo}, @code{events_purge} and @code{events_set_send_sigusr1}.
1420 It should be noted that those functions are not listed in
1421 @file{scripting/prototypes} as you most probably do not want your users having
1422 access to them. You should probably start an interactive session and play with
1423 them to make sure you fully understand this. This is also the right time to
1424 mention the @file{src/adesklets_debug.sh} script, which comes in handy when
1425 interactively experimenting with events.
1427 @noindent Two last things are worth mentionning about events:
1429 @enumerate
1430 @item By default, events are not echoed, but stored internally, waiting 
1431 to be purged with @code{events_purge}. You can change this with
1432 @code{events_set_echo}.
1433 @item You can set the adesklet interpreter to send a SIGUSR1 signal every time
1434 an event is printed out to its parent process (the desklet). It is a very
1435 useful IPC, since the signal can be trapped, allowing the event management
1436 routine to run only when necessary. This is what the Python package uses within
1437 its @code{Events_handler} class.
1438 @end enumerate
1440 @section SIGCHLD signal handler
1442 Whenever your language allows it, you should install some kind of SIGCHILD
1443 handler, so you can at least be notified if the adesklets interpreter ever
1444 exists without a reason (child zombies notwithstanding)@footnote{@code{man 2
1445 signal} is a very good reference on signals.}.
1447 @section Textual variables
1449 @command{adesklets} also supports differed execution (indirect mode)
1450 and textual replacement of variables. Here how variables work in indirect mode:
1452 @enumerate
1453 @item Once a command is entered, it is stored untouched into the commands
1454 history list, if applicable (in non-interactive usage of the interpreter,
1455 when the command lies bethween calls to @code{start_recording} 
1456 and @code{stop_recording})
1457 @item When a macro command is played back (using the @code{play} command,
1458 @xref{Programming adesklets}.), variables get expanded in a single pass, and no
1459 indirect reference is possible.  Expansion is pretty straightforward. The stored
1460 command line is scanned for any non-empty sequence of non-space characters
1461 beginning with a single '$'.  Each such sequence is replaced with the 
1462 corresponding @code{$variable} value, or removed if no variable is found.
1463 @item Expanded command get executed.
1464 @end enumerate
1466 The same expansion mechanism also applies to the direct mode of execution. All
1467 this leads to the fact that, using the Python package for instance, these two
1468 code snippets are equivalent:
1470 @example
1471 adesklets.window_resize(100,100)
1472 @end example
1474 and:
1476 @example
1477 adesklets.set('dim',100)
1478 adesklets.window_resize('$dim','$dim')
1479 @end example
1481 This did not require any alteration of our Python code, since Python is a
1482 dynamic language, but some other languages will require further thinking.
1484 @section Final words
1486 You should now know pretty much everything needed for integrating adesklets with
1487 your language environment. It may appear to be a daunting task, but a very
1488 clean binding can be produced by one programmer in only a few days. Once again,
1489 have a look at @file{src/adesklets_debug.sh}; it is a (very lame) Bourne shell 
1490 binding for adesklets written in only fifty lines, including comments.
1492 If you ever need assistance, you are encouraged to post on the 
1493 @weblink2{adesklets-devel mailing list,https://lists.sourceforge.net/lists/listinfo/adesklets-devel}...
1495 Happy coding!
1497 @noindent 
1498 @node Help wanted!
1499 @chapter Contributing to adesklets
1501 Your help is wanted! You can valuably contribute to adesklets by:
1503 @itemize
1504 @item
1505 @strong{Posting your adesklets screenshots online}. You use adesklets and think
1506 you have a pretty cool desktop? Share it with the world by posting it online,
1507 and send us a link! This way, you will help people learn about the project.
1508 @item
1509 @strong{Contribute to the documentation}. You have very good written
1510 knowledge of German, Spanish, Portugese, Arab or Swahili? Translators are always 
1511 welcomed, proofreaders too, for all languages.
1512 @item
1513 @strong{Writing new desklets}. adesklets is still young: we crave
1514 talented desklets writers, and we would be more than willing to post or link
1515 to your work. Do not worry too much about interface changes; the author spent
1516 considerable effort to ensure that the interface would be fairly stable even
1517 in the earliest releases.  It's not frozen forever, but it shouldn't break your
1518 desklets without some warning.  At this point, the API is predominantly getting
1519 internal bug fixes and portability improvements.
1520 @item
1521 @strong{Adding bindings for your language of choice}. Contact the developers 
1522 beforehand so that you don't waste time on something that is already written;
1523 they will be glad to share code.  Subscribe to the
1524 @weblink2{adesklets-devel mailing
1525 list,https://lists.sourceforge.net/lists/listinfo/adesklets-devel} on
1526 SourceForge for quick access to them.
1527 @end itemize
1529 @noindent Contact me by email at @email{syfou@@users.sourceforge.net}.
1531 @node Frequently asked questions
1532 @appendix Frequently asked questions
1534 Last update: @value{UPDATED}
1535 @section Compiling adesklets
1537 @subsection The adesklets configure script says my Python install is too old, but it's not. What's the problem?
1539 Some platforms (NetBSD, Ubuntu Linux, probably others too) sometimes alter 
1540 the Python version, appending letters, prefixing minor numbers, etc., thus 
1541 preventing the configuration script from detecting it properly. If you know 
1542 @strong{for sure} that what you have installed is at least 2.3.0,
1543 you can pass the @code{--with-python-force-detection} switch to 
1544 @code{configure}; this will make the configuration script skip the version 
1545 detection.
1547 @section Starting desklets
1549 @subsection When I try to start a new desklet, I get an @code{ImportError: No module named adesklets} error from the Python interpreter. What's happening?
1551 It means what is written: @command{python} cannot find the @code{adesklets}
1552 package; maybe it did not get installed, or it did get installed in the wrong
1553 place.
1555 @itemize
1556 @item Restart from the beginning the installation procedure
1557 (@xref{Installing adesklets}.). Make sure you @strong{do not} select
1558 the @code{--without-python-support} configuration option.
1559 @item Retry starting the desklet. If it still does not work, verify that the
1560 installation directory, given by:@example
1561 sed -n '/PYTHON_SITE_PKG/p' Makefile
1562 @end example
1563 @noindent is included in :@example
1564 echo 'import sys; print sys.path' | python
1565 @end example
1567 @noindent If not, you can still manually move the adesklets directory 
1568 from @code{PYTHON_SITE_PKG} to any path displayed by this last command.
1569 @end itemize
1571 @subsection When I try to start a new desklet, I get an @code{ADESKLETSError: adesklets process exited} error from the Python interpreter. What is this?
1573 On some rare systems (@weblink2{archlinux,http://www.archlinux.org/} for instance),
1574 the @code{PATH} variable for the Python interpreter differs from
1575 what is inherited from standard environment, which causes the Python package to
1576 fail to launch adesklets as a child process. On such systems, make sure
1577 to install @command{adesklets} using an appropriate @code{--prefix} switch at
1578 the configuration stage. For instance, on most recent Linux platforms, you 
1579 should use:
1581 @example
1582 ./configure --prefix=/usr
1583 @end example
1585 @subsection Everything worked fine but then I tried upgrading a desklet, and I couldn't ever see the new one. What is wrong?
1587 There is a built-in lock mechanism in the interpreter that prevents a user from
1588 simultaneously running more than one desklet with the same @code{ID} and name,
1589 regardless of version.  Whenever you upgrade a given desklet, you should first
1590 cleanly quit the desklet (by using @code{Quit} from the context menu), then
1591 install the updated desklet by following the instructions provided in the 
1592 @file{README} file.
1594 @subsection Gosh! The desklet X is working, but does not remember its settings, or it always starts on the top left corner of screen 0 on a new X session. What is that? It sucks!
1596 This is most probably related to the way you started the desklet
1597 (Please @pxref{Using adesklets}.). You need to invoke the desklet script
1598 @strong{only once}. Afterwards you just need to run the command:
1600 @example
1601 @command{adesklets}
1602 @end example
1604 and it will remember where you placed your desklets and which desklets 
1605 you had running.
1607 @subsection This is exactly what I did, but the darn thing wouldn't restart anyway.
1609 Did you store the desklets under a @file{$HOME/.adesklets} directory?
1610 Please don't.
1611 @command{adesklets} need a @file{$HOME/.adesklets} file to store the various
1612 user settings on running desklets; setting up a directory of the same name 
1613 prevents it from doing its job right, so just move your directory some place 
1614 else (@file{$HOME/.desklets}, for instance).
1616 @section Displaying desklets
1618 @subsection Where are my desklets? @command{adesklets} interpreters seem to be running fine, but I just cannot see anything on my desktop!
1620 Try the command:
1622 @example
1623 python test/test.py
1624 @end example
1626 @noindent from the base source directory. If a 100x100 window appears, 
1627 it most probably means you are using a window manager that draws 
1628 a big window over the root window; your desklets are just drawn below it.
1629 Such window managers include Nautilus, KDE, Xfce4, CDE or E17. 
1630 Right now, Nautilus, KDE and Xfce4 are handled automatically, but others are not.
1632 All the necessary infrastructure is already in place. In most cases, only the 
1633 @code{xwindow_get_root_window()} function from @file{src/xwindow.c} has 
1634 to be expanded to detect new window managers. You can either submit a patch, 
1635 or ask for it on the @weblink2{adesklets development mailing list, http://lists.sourceforge.net/lists/listinfo/adesklets-devel}.
1637 @subsection I cannot see smaller desklets such as xmms_bar or asimpleclock, while others work. What gives?
1639 New desklets are always started in the leftmost, upper corner of the screen, at
1640 the very bottom of the windows stack. Make sure you do not have some elements 
1641 (gnomebar, engage, etc) already masking this zone of the screen. Beware! Some 
1642 applications use pseudo-transparency, and can mask the root window seamlessly.
1644 @subsection I am running Fvwm as my window manager. Why can't I keep the desklets below all my other windows? They keep popping on top!
1646 Go see the Fvwm faq: @weblink{http://www.fvwm.org/documentation/faq/#5.11}.
1647 This @code{BugOpts RaiseOverUnmanaged on} option was reported to work for many 
1648 Fvwm users.
1650 @section Running desklets
1651 @subsection The 'Configure' item from the context menu of many desklets doesn't work!
1652 For this to work--at least for all the demo desklets--you need to have
1653 @command{xterm} installed, and the @code{EDITOR} variable properly set in 
1654 your environment, as it is customary in UNIX. Please note this only launches a 
1655 text editor in a terminal. Editing the desklet's configuration file
1656 (usually @file{config.txt} from base desklet directory) has the same effect.
1658 @subsection Do you plan including SVG support? I would like to use a SVG image in one of my desklets.
1659 No we do not, sorry. It is not
1660 that @weblink2{SVG,http://www.w3.org/Graphics/SVG/} is a bad format; in fact 
1661 it is quite good. But it is also a vector-oriented one (and rather complex), 
1662 while Imlib2, on which @command{adesklets} relies heavily, is completely 
1663 raster-oriented, and using Imlib2 is the main reason for @command{adesklets}'
1664 simplicity, relatively good speed and low resource usage. 
1666 That said, there is no reason for you not using SVG's with desklets, since 
1667 it is quite easy to convert images in SVG to high quality PNG's, 
1668 using programs such as @weblink2{sodipodi,http://www.sodipodi.com/}, @weblink2{inkscape,http://www.inkscape.org/} or @weblink2{xsvg,http://xsvg.org/}. 
1669 In a directory full of SVG's, on a GNU system you can use a command such as:
1670 @example
1671 ls *.svg | sed 's/\(.*\).svg/-z --file=& --export-png=\1.png --export-width=128 --export-height=128/' | xargs --max-lines=1 sodipodi
1672 @end example
1673 to convert them all to 128x128 semi-transparent PNG's.
1675 @subsection I would like to use some of my system's fonts with adesklets, but I cannot get my desklets to find them. What should I do?
1677 First, you need to have fontconfig support enabled in adesklets. See the
1678 config.log from the configuration phase to verify it. If you did not keep the
1679 log, you can also look at the dynamic libraries linked against the interpreter.
1680 On a system with GNU binutils, you can do something like:
1681 @example
1682 ldd `which adesklets` | grep fontconfig
1683 @end example
1684 If you get output similar to:
1685 @example
1686  libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x45c75000)
1687 @end example
1688 it means everything is fine. Otherwise, you should recompile 
1689 @command{adesklets} from source. From there, you can use the line:
1690 @example
1691 echo 'list_font_path' | adesklets :
1692 @end example
1693 to see all the font directories that adesklets will into look for TrueType
1694 fonts.  Consult your fontconfig documentation to learn how to change this
1695 (on up-to-date systems, @code{man 5 fonts-conf} is a good starting point).
1696 Similarily:
1697 @example
1698 echo 'list_fonts' | adesklets :
1699 @end example
1700 Will give you all the fonts that are currently found... Keep in mind when
1701 typing them that font names are case-sensitive.
1703 Alternatively, if you just cannot get fontconfig to work, a way to get around
1704 the problem would be to create symbolic links to the fonts you want to use
1705 inside any absolute font paths listed by the command
1706 @code{echo 'list_font_path' ...} above.
1707 @ifhtml
1708 @node Python package documentation
1709 @appendix Python package documentation
1711 Here are links to significant sections of the Python package documentation:
1713 @itemize
1714 @item @weblink2{adesklets,../pydoc/adesklets.html}
1715 @item @weblink2{adesklets.events_handler,../pydoc/adesklets.events_handler.html}
1716 @item @weblink2{adesklets.commands,../pydoc/adesklets.commands.html}
1717 @item @weblink2{adesklets.utils,../pydoc/adesklets.utils.html}
1718 @item @weblink2{adesklets.configfile,../pydoc/adesklets.configfile.html}
1719 @end itemize
1721 @end ifhtml
1723 @node Imlib2 documentation
1724 @appendix Imlib2 documentation
1726 Carsten Haitzler (@email{raster@@rasterman.com}) took the time to produce very
1727 nice cross-referenced documentation for Imlib2, but for some reason (size
1728 considerations most probably), it is not included in the Imlib2 source
1729 tarball@footnote{Although it can be quite easily regenerated using doxygen.}.
1730 You can
1731 @ifhtml
1732 have it @weblink2{here,../imlib2}.
1733 @end ifhtml
1735 @ifnothtml
1736 find it online at @weblink{http://adesklets.sf.net/doc/imlib2/}.
1737 @end ifnothtml
1739 Most functions of the Imlib2 API have corresponding, homonymic commands
1740 in @command{adesklets}. @xref{Programming adesklets}, for specific details
1741 on the transition from direct Imlib2 programming in C to adesklets.
1743 @node Packaging GNU Makefile for desklets
1744 @appendix Packaging GNU Makefile for desklets
1746 Here is a convenient Makefile that automates the packaging of new or 
1747 existing desklets on a GNU system. Just copy the Makefile below 
1748 into @file{GNUmakefile} from your base desklet directory to use it. 
1749 There is nothing at all to edit, provided you named your base directory
1750 in a proper 'NAME-MAJOR.MINOR.REVISION' fashion, such as @code{beast-0.666.0}.
1752 @verbatiminclude ../utils/GNUmakefile.desklet
1754 @node Submitting a desklet
1756 @appendix Submitting a desklet
1758 @section Desklet package requirements
1759 Requirements for ``official'' desklets packages are scarce; authors are free to
1760 do as they wish. There are only two things that should be enforced:
1761 @enumerate
1762 @item A meaningful @file{README} file should exist in the base source directory 
1763 of the desklet archive and be kept up to date. It should at least contain:
1764 @itemize
1765 @item the name and contact email adress of the author@footnote{It is probably 
1766 not a good idea to give away your private email adress here; 
1767 for spam-related reasons, you should probably open an account 
1768 on @weblink2{SourceForge,http://sourceforge.net/}, or at another similar place 
1769 with a serious spam containment infrastructure.}
1770 @item a short description of the desklet
1771 @item the requirements for running it
1772 @item how to run it
1773 @end itemize
1774 @item The package should be a bzip'ed tarball containing a single source
1775 directory of the form @code{NAME-MAJOR.MINOR.REVISION}, where @code{NAME} is 
1776 the desklet base name, and @code{MAJOR.MINOR.REVISION} the version. Please note
1777 that a makefile (@xref{Packaging GNU Makefile for desklets}.) is also provided
1778 to automate creation of such an archive on GNU systems.
1779 @end enumerate
1781 @section The @command{adesklets_submit} script
1783 Starting in @command{adesklets} 0.4.4, desklet authors are provided with a 
1784 Python script to automate the submission of their desklets: 
1785 @file{utils/adesklets_submit} from the source package. Use the 
1786 @code{--with-python-install-submission-scripts} option at configuration time
1787 to place it in your @code{bindir} directory upon installation.
1789 @file{adesklets_submit} can be used to:
1790 @itemize
1791 @item Submit a new or updated desklet description for inclusion on the
1792 @weblink2{adesklets web site,http://adesklets.sf.net/desklets.html};
1793 @item Submit a bzip'ed desklet archive for inclusion in SourceForge's desklets
1794 package (this is optional--you may choose to host it yourself).
1795 @end itemize
1797 @section Invoking @command{adesklets_submit}
1798 Desklet submission is initiated by sending a specially crafted email to 
1799 @email{adesklets@@mailworks.org}@footnote{It is useless to send anything else 
1800 to this address; all messages that cannot be parsed by the automatic reception
1801 script are just silently dropped. Write to @email{syfou@@users.sourceforge.net}
1802 instead if you want to get in touch with the maintainer.}.
1803 The @command{adesklets_submit} script assits you in the construction of
1804 such an email using the user configuration file @file{$HOME/.adesklets_submit}
1805 and the command line switches. Here is an example of a valid
1806 @file{$HOME/.adesklets_submit} configuration:
1808 @verbatiminclude ../utils/adesklets_submit.example
1810 This is pretty self-explanatory, but here are a few less obvious points:
1812 @itemize
1813 @item
1814 Try to avoid using pseudonyms and nicknames for the @code{author_name} as much
1815 as possible, unless, of course, you already have a pretty well-established
1816 online identity under this name.
1817 @item
1818 @code{send_confirmation} specifies if an email should be sent back to your 
1819 @code{author_email} address whenever your desklet is succesfully published. 
1820 If the submitted entry is rejected, you will always be written back anyway
1821 with an explanation. Usually, the maintainer will not try to make changes to
1822 problematic entries; it will only summarize back to the author what was not OK.
1823 @item
1824 @emph{Double check} your @code{author_email} address, since this is the only
1825 one the maintainer will try to use when contacting you, regardless of what 
1826 the headers say. Failing to supply a valid address will cause all messages to
1827 fail to be sent to you, and all new desklet entries will be rejected.
1828 @item
1829 You can very well use adesklets_submit without any prior contact with the adesklets
1830 maintainer (either via email, within the forum using this adress for
1831 registration, or through the mailing list), but some back and forth will be
1832 needed before publication just to assert your identity and its effective
1833 relation to the provided email address.
1834 @item
1835 @code{desklets} is a dictionary of dictionaries (one dictionary per desklet, 
1836 desklets' names being the keys); all the items referring to files (thumbnail,
1837 screenshot and download) could either be publicly accessible URI's (this is the
1838 preferred method), or local files, either absolute or relative to your $HOME
1839 directory. In that case, needed files will be attached to the generated
1840 multipart email.
1841 @item
1842 All images will always be fetched and integrated on the adesklets.sf.net
1843 web site; you can safely remove them from your online location afterwards 
1844 if you provided live URI's.
1845 @item
1846 When updating already included desklets, there is no need to submit back
1847 the @code{thumbnail} or @code{screenshot} images if they did not change;
1848 you can just as easily reference the already installed images on SourceForge:
1849 @itemize
1850 @item The @code{thumbnail} is always stored under @code{http://adesklets.sf.net/images/NAME_thumb.[jpg|png]}
1851 @item The @code{screenshot} is always stored under @code{http://adesklets.sf.net/images/NAME_screen.[jpg|png]}
1852 where @code{NAME} is the name of the desklet.
1853 @end itemize
1854 @item
1855 Using the @code{host_on_sourceforge} value, you can choose to have 
1856 your desklet package either hosted on SourceForge or just referenced 
1857 on your site if you provided a URI. Of course, choosing this last 
1858 alternative also means you will need to keep it in place.
1859 @item
1860 The @code{thumbnail} image should be a JPG (preferably) or PNG (if you 
1861 @emph{really} need higher resolutions) of dimensions lying between 190x35 and 
1862 230x110 pixels.
1863 @item
1864 The @code{screenshot} image should be a 640x480 JPG (preferably) or PNG.
1865 It should put your desklet in evidence, and thus contain no other ones.  
1866 @item
1867 You can choose not to submit thumbnails and/or screenshots. In that case,
1868 default, generic images will be used instead.
1869 @item
1870 @code{Category} is unused for now, and just ignored.
1871 @item
1872 All emails weighing more than 300 KB will be rejected by the maintainer's
1873 email server; thus, adesklets_submit will refuse to generate them. Instead of
1874 submitting such big entries, use the URI facility described above to trim
1875 them down.
1876 @item @command{adesklets_submit} does not enforce the requirements above; it only
1877 checks what is strictly required to build a compliant submission email:
1878 the existence of dictionary entries, availability of files, the validity 
1879 of file types if they are local... It is your duty to make sure the entries
1880 meet the other requirements if you want to avoid rejection.
1881 @end itemize
1883 For example, Belial Leviathan would fisrt check his @code{beast} desklet's
1884 entry by doing something similar to:
1885 @example
1886 adesklets_submit beast
1887 @end example
1889 If everything goes fine, it will output the resulting submission email 
1890 on @code{stdout}. From there, Belial can either:
1891 @itemize
1892 @item Pipe it to his favorite MTA (mail transfert agent) to send it to
1893 @email{adesklets@@mailworks.org}.
1894 @item Make @command{adesklets_submit} send it itself by SMTP, using the
1895 @code{smtp_host} and @code{smtp_port} parameters in its 
1896 @file{$HOME/.adesklets_submit}. For this, Belial would use:
1897 @end itemize
1898 @example
1899 adesklets_submit --send beast
1900 @end example
1902 One last thing: you should try to avoid sending minor corrections multiple
1903 times, especially if you use local files.  It both adds to the workload of the
1904 maintainer's email server and to the management work. Please try to create a
1905 valid entry @emph{then} send it, not the other way around.
1907 @subsection Further submission validation using @command{adesklets_checkin}
1908 From @command{adesklets} 0.4.5, you now have access to the 
1909 @command{adesklets_checkin} script as well. This is the Python 
1910 script that the maintainer uses for checking in all submissions.
1911 @emph{Be aware that this script is only provided to desklet authors as a
1912 convenience, to lower their submission rejection count--developers are in no
1913 way forced to use it, and may even be unable to do so, since the script was not
1914 written with portability in mind as adesklets_submit was. Look at the script 
1915 header for a complete list of requirements.}
1917 @command{adesklets_checkin} has two modes of operation: interactive and 
1918 non-interactive. Only the non-interactive mode will interest desklet authors.
1919 In this mode, usage is fairly simple. Belial, for instance, would do:
1920 @example
1921 adesklets_submit beast | adesklets_checkin
1922 @end example
1924 If everything goes fine, an output similar to this will be produced:
1925 @example
1926 Validation started. Please wait.
1927 Everything seems fine, but keep in mind a few things cannot be
1928 verified without human intervention. See documentation for details.
1929 @end example
1931 If not, you will get an exception trace with some (hopefully) meaningful 
1932 explanations. 
1934 @subsection Limitations of @command{adesklets_checkin} in non-interactive mode
1936 Here are the remaining problems that @command{adesklets_checkin} 
1937 cannot detect and thus must absolutely be solved manually
1938 (the maintainer would interactively catch most of them, and you would have to
1939 resubmit anyway):
1940 @itemize
1941 @item
1942 Incomplete README file in base directory (Does it contain all the details
1943 enumerated above?).
1944 @item
1945 Out-of-date README file (Does its content reflect the current state
1946 of the desklet?).
1947 @item
1948 Desklet fails to run out-of-the-box (i.e. with or without minimal
1949 configuration) when requirements in the README file are met and special
1950 instructions are followed.
1951 @end itemize
1953 @node Copying This Manual
1954 @appendix Copying This Manual
1956 @menu
1957 * GNU General Public License::  License for copying this manual.
1958 @end menu
1960 @include gpl.texi
1962 @node Open PGP Public Key
1963 @appendix Open PGP Public Key
1965 @verbatiminclude syfou.asc
1967 @noindent You can also get this certificate from many public key servers on 
1968 the internet, such as @weblink{http://www.keyserver.net/}, or
1969 @weblink{http://pgp.mit.edu/}. Contact its rightful owner,
1970 Sylvain Fourmanoit, by email at @email{syfou@@users.sourceforge.net} 
1971 to arrange further key validation if you need any.
1973 @node Index
1974 @unnumbered Index
1976 @printindex cp
1978 @bye