Typo.
[adesklets.git] / doc / adesklets_en.texi
blob04cbb1e21836c786c1a84e9d71386e33675e109d
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 @c @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 @end menu
100 @noindent The latest version of this document can be found online at
101 @weblink{http://adesklets.sf.net/doc/en/}.
103 @noindent Screenshots, source tarballs, downloadable web documentation tarballs, 
104 etc. can also be found on the project home page: @weblink{http://sf.net/projects/adesklets/}.
106 @node About adesklets
107 @chapter What is adesklets?
109 @section Short answer
111 @command{adesklets} is an interactive
112 @weblink2{Imlib2,http://www.enlightenment.org/} console
113 for the X Window System. It provides scripted languages with a clean and 
114 simple way to write great looking, mildly interactive desktop integrated
115 graphic applets (aka ``desklets'').
117 It can also be used as a command line oriented graphic editor, a bit similar
118 to @weblink2{ImageMagick,http://www.imagemagick.org/}, but with different
119 functionality.
121 @section Long answer
123 @command{adesklets} stands for ``another desklets [container]''. It was
124 written as an alternative to other programs such as:
126 @enumerate
127 @item
128 gDesklets (@weblink{http://gdesklets.gnomedesktop.org/})
129 @item
130 SuperKaramba (@weblink{http://netdragon.sourceforge.net/}).
131 @item
132 GKrellM (@weblink{http://www.gkrellm.net/})
133 @end enumerate
135 Since this is 'a'desklets, others still have plenty of space to start similar
136 projets, from 'b'desklets to 'z', excluding 'g', which is already taken.
138 Seriously though, all those packages are nice. Nevertheless, the first two
139 have very heavy requirements in terms of library dependencies; basically,
140 gDesklets still requires a fair part of the GNOME environment to be installed 
141 (plus specialized libraries such as gnome-python@footnote{A report on this has 
142 been produced; you may find it online in PDF format at 
143 @weblink{http://adesklets.sf.net/verbatim/gdesklets.pdf}.}), while 
144 SuperKaramba needs almost all of the KDE libraries and base environment.
145 This also reflects on performance for the task at hand@footnote{Of course, this
146 is only the author's opinion--and both applications are making big progress on
147 resource efficiency from version to version.}. On the other hand, while GKrellM
148 is significantly lighter (it still depends on GTK+ though), it does not deliver
149 the same experience in terms of ``eye-candiness'' (to the author's taste, of
150 course) or ``scriptability'' than the other two.
152 Thus, @command{adesklets} was born. It provides:
154 @itemize
155 @item
156 a minimal framework for X Window desklets seamlessly integrated into the
157 desktop, with an easy to use central management for starting, positioning 
158 and stopping them.
159 @item
160 a generic, rich and easy to use drawing API similar to gDesklets and
161 SuperKaramba regarding its high visual quality, thanks to the Imlib2 library.
162 @item
163 very limited library dependencies: uses the very good (and lightning fast)
164 Imlib2 library for all graphic-related operations. No window toolkit used
165 whatsoever; the program relies directly on xlib.
166 @item
167 a light, robust and small interpreter potentially usable with all sorts of
168 scripting languages thanks to a clean, limited and homogenous syntax. As
169 on version
170 @value{VERSION}, support for Python is provided out of the box. Future support
171 for Perl and Ruby would be fairly possible. Feel free to contribute support 
172 for your favorite language (@xref{Extending adesklets}.)!
173 @item
174 Minimal disk space, memory footprint and CPU usage. Typically, on glibc 2.3.4
175 Linux 2.6 x86, a unique executable is less than 130 KB on disk, takes less than
176 3 MB of virtual memory per desklet right after initialization, and almost no
177 processor cycles (including cycles from a Python interpreted script) when idle.
178 @end itemize
180 It DOES NOT provide:
182 @itemize
183 @item
184 A sophisticated window API, or even access to widgets besides bare, ugly grey
185 menus.  You clearly cannot write any GUI application with this--only
186 ``desklets''.
187 @item
188 Convoluted mechanisms (or just plain mechanisms, for that matter) for
189 script configuration. Script developers are free (or doomed, depending on how
190 you see things) to do whatever they see fit.
191 @item
192 Support for everything that is not a truly POSIX compliant system. For
193 instance, it would be very surprising if this would ever compile on Cygwin.
194 @item
195 Feature-rich management of user events. @command{adesklets} aims at low
196 resource consumption and reliability; only a small set of events, mainly 
197 pointer-related, are exposed through its API.
198 @end itemize
200 @node What's new?
201 @chapter What's new?
203 @heading What's new in version 0.5.0
204 This is new minor version and bug fix release. It extends the documentation
205 and FAQ on many topics, includes many fixes to the autotools scripts (special 
206 thanks to Steve Langasek  @email{vorlon@@debian.org}), regularises a few 
207 exceptions in the interpreter, adds support to WM-specific contextual menu, 
208 adds a few use cases scripts under @command{test/}, 
209 and adds a brand new adesklets installer (@command{adesklets_installer}) for 
210 automated download and unpacking of desklets.
212 @heading What's new in version 0.4.12
213 This is a bug fix release. It corrects an error with the new distributed 
214 documentation makefile that prevented info files and manual pages from
215 installing right on arbitrary, empty directory trees (thanks to 
216 Bart Kreska for the patch). It also add support for nautilus and KDE >=3.4.1,
217 as well as preliminary support for xffm-desktop and ROX-Filer. It 
218 should rectify a long-standing issue with some desklets failing to
219 complete their initial display. Finally, the documentation FAQ also 
220 got slightly expanded.
222 @heading What's new in version 0.4.11
223 This is a bug fix release. Documentation wize, it brings the french 
224 documentation up to speed with the english version (thanks to Martin 
225 Kirchgessner @email{martin.kirch@@gmail.com} for all his work), and take 
226 the whole documentation source and html 
227 version out of the main package (thanks to this, adesklets is now about 300 KB 
228 lighter). Code wize, this version includes many small fixes for various platforms 
229 -- FreeBSD 7 should hopefully be supported unpatched, manuals have been added 
230 for desklets submission script to please Debian. Yet, the biggest change is 
231 probably the inclusion of an optional shell driver to the interpreter, that
232 ease up the administration of adesklets and the quick adaptation of the code
233 to new windows managers.
235 @heading What's new in version 0.4.10
236 This is a bug fix release. An unwanted partial new feature made is way 
237 into previous release: it caused the contextual menu to stop working 
238 the advertised way (the control key needed to be pressed for the menu to
239 get fired). This release just revert back the change, and add a 
240 configuration-time option, --enable-control-on-context-menu, for
241 those who really wants this behavior.
243 @heading What's new in version 0.4.9
244 This is a bug fix release. It changes the global macro definitions for
245 adesklets to compile without problems on FreeBSD 6.x, corrects an error
246 with debugging flag stripping from the C compiler, and adds a new demo 
247 program about threading.
249 @heading What's new in version 0.4.8
250 This is a bug fix release. It changes the global macro definitions for
251 adesklets to compile without problems on FreeBSD 5.x, and it also adds
252 fake root window detection for KDE, thanks to yogi77, from the forum.
254 @heading What's new in version 0.4.7
255 This is a bug fix release. It removes calls to some C99 math routines not
256 available in earlier BSD's, making the code more portable. It also adds 
257 two new commands to the API for handling the image caching mechanism better.
259 @heading What's new in version 0.4.6
260 This is a bug fix and documentation update release. It corrects many small
261 bugs inside the desklets submission process scripts, makes portability changes
262 to the autoconf structure, adds a new demo scripts in test (widget.py), corrects
263 the xwindow_move_window routine for a small placement bugs on the screen (thanks
264 to man1ed from the forum from providing the patch), and finally adds a new
265 appendix containing a handy online version of the Imlib2 documentation.
267 @heading What's new in version 0.4.5
268 This is a bug fix and documentation update release. It improves the desklets
269 submission process by releasing the full check-in script used by the maintainer.
270 It also solves a bug with window refresh when using user-defined background
271 image and menus; thanks to ZeroDivide for reporting this. Various updates and
272 corrections have also been made to the documentation.
273       
274 @heading What's new in version 0.4.4
275 This is a documentation update release, principally aimed at desklet 
276 authors. It basically includes a new appendix on how to submit a desklet 
277 (including scripted support), and a new subsection on system-wide font
278 detection as well. The FAQ was also expanded to cover this topic.
280 @heading What's new in version 0.4.3
281 This is a documentation update release. Most of the work here was made by 
282 Mike Pirnat @email{exilejedi@@users.sourceforge.net}, who was kind enough 
283 to rectify the base author's deficient english by proofreading this manual 
284 from cover to cover. Thanks Mike! The FAQ was also slightly expanded, and 
285 a new appendix for desklets writer created.
287 @heading What's new in version 0.4.2
288 This is a new bug fix release. It corrects a bug within the Python package
289 that made it not compile on all versions of Python prior to 2.4.0. Thanks to 
290 nucular, from the adesklets forum, for reporting this. It also corrects another
291 minor mmap-related issue in the same package.
293 @heading What's new in version 0.4.1
294 This is a new bug fix release. It secures the use of the optional 
295 @code{adesklets.ConfigFile} class by completely changing 
296 the way config files are imported, thus removing a potential 
297 security exploit. Thanks to Mike Pirnat @email{exilejedi@@users.sourceforge.net}
298 for sharing his concerns on this issue.
300 @heading What's new in version 0.4.0
301 This is a new minor version release. The interpreter now supports
302 internationalization. It can now dynamically work with different
303 character sets on platforms supporting iconv (as standardized in UNIX98), and
304 display them in the right fashion. The Python package was also extended
305 to include an (optional) generic configuration class, hopefully useful
306 to desklets authors.
308 @heading What's new in version 0.3.2
309 This is a documentation update release. Documentation was added for Python
310 programmers, and the FAQ was slightly expanded.
312 @heading What's new in version 0.3.1
313 This is new bug fix release. It just adds support for interruption of time gates
314 by events. This is a feature absolutely required to make some timed effects 
315 possible.
317 @heading What's new in version 0.3.0
318 This is a new minor version release. Portability has been a big concern for us
319 since the beginning; with this version, the package compiles and runs flawlessly
320 on FreeBSD and NetBSD (@xref{Portability}.). Event handling has also been 
321 internally streamlined, and the Python binding was extended to support 
322 dynamic modification of caught events (see @file{test/test_events.py}).
324 The interpreter API now exposes everything the author wanted, 
325 and will probably not be expanded much further; everything is pretty much
326 in place to write any desklet, including animations.
328 @heading What's new in version 0.2.1
329 This is a minor bug fix release which removes a compatibility bug within
330 the GNU history library usage. Thanks to Mike Pirnat 
331 @email{exilejedi@@users.sourceforge.net} for reporting this.
333 @heading What's new in version 0.2.0
334 This is a new minor version release. Support was added for textual variables
335 (string substitution, in fact), and execution of timed preregistered
336 sequences of commands to the interpreter (indirect mode of execution).
337 This gives desklets a way to perform fluid animations. Run the demo script
338 @file{test/fading.py} from the source package to see those features in action.
340 For developers, this version also includes a rewritten, dynamically
341 configurable debug interface to the interpreter able to generate complete 
342 logs on any session.
344 @heading Details
345 See @file{Changelog} for all details.
347 @ifplaintext
348 @c Sets up a marker for automated INSTALL file generation
349 INSTALL_BEG
350 @node Installing adesklets
351 @unnumbered Installing adesklets
352 @end ifplaintext
353 @ifnotplaintext
354 @node Installing adesklets
355 @chapter Installing adesklets
356 @end ifnotplaintext
358 @section Compilation Requirements
360 To compile adesklets from source, you will need:
362 @itemize
363 @item
364 A compiler supporting ANSI C plus variadic macros (about every version
365 of @weblink2{gcc,http://gcc.gnu.org} from 2.7.0 will do - or about
366 everything else published in the last ten years, for that matter)
367 @item
368 @weblink2{X11,http://www.x.org/} libraries and
369 headers@footnote{Except for headless builds, useful
370 for server environments and such; read further for details.}
371 @item
372 Imlib2 1.1.2 and up (the more recent the better; go and fetch it from
373 @weblink{http://sourceforge.net/projects/enlightenment/})
374 @item
375 @weblink2{GNU readline,http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html}
376 @item
377 A reasonably POSIX-compliant system
378 @end itemize
380 @noindent It can also use, if present in the system:
382 @itemize
383 @item
384 @weblink2{fontconfig,http://www.fontconfig.org/}, for automated detection of
385 all usable fonts present in the system
386 @item
387 @weblink2{GNU history,http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html},
388 the faithful complement to GNU readline for command history support
389 @item
390 iconv library and headers (such
391 as @weblink2{libiconv,http://www.gnu.org/software/libiconv/}), for 
392 internationalization support (dynamic support of extended character sets)
393 @item
394 @weblink2{Python,http://www.python.org} 2.3 and up, if you want Python support
395 (you most probably do -- desklets are written in this language)
396 @end itemize
398 Many systems routinely package ``development'' versions of libraries and 
399 tools separately (@command{imlib2-devel}, @command{readline-devel}, 
400 @command{fontconfig-devel}, @command{python-devel}, etc); if this is the case for
401 the target system, those have to be chosen over the ``regular'' versions.
403 @section Runtime requirements
405 In addition to the compilation requirements, the optional adesklets 
406 shell frontend, installed by default, will itself 
407 need a few utilities, all expected to minimally comply with POSIX 1003.2 and 
408 1003.2a specifications:
410 @itemize
411 @item a sh-compatible @command{/bin/sh} shell
412 @item a Streaming EDitor (sed)
413 @item test, mkdir, rmdir, sleep, kill and ls
414 @end itemize
416 The @command{xwininfo} and @command{xprop} programs can also be used 
417 by this frontend, if a given fake-root window detection routine 
418 is explicitely invoked. Both XFree86 and X.org implementations 
419 of these utilities have been tested. Other programs will eventually be used
420 by specific detection routine: see the frontend source for details.
422 @section Portability Notice
423 @anchor{Portability}
424 This package was built with portability in mind: all vendor-specific
425 extensions were avoided, and specs (ANSI, SVID 3, BSD 4.3, POSIX) were followed
426 in a conservative way. Nevertheless, original development took place on a single
427 Linux system; it is quite probable that adesklets will not compile or work as 
428 expected in some cases. Fixing portability issues is an important concern for us.
430 adesklets has been ported and successfully tested by the developers on many
431 systems. As of version @value{VERSION}, it has been verified to compile and run
432 out of the box on a variety of
434 @itemize 
435 @item @strong{Kernels/Systems}: Linux (2.2, 2.4, 2.6 series), FreeBSD
436       (4.10, 5, 6 and 7), NetBSD (1.6)
437 @item @strong{C Libraries} (when applicable): glibc (2.1.3 and up), uclibc (0.9.28)
438 @item @strong{Compilers}: gcc (2.95.2, whole 3 serie, 4.0.2), 
439       icc 7.0 (with tweaking)
440 @end itemize
442 Moreover, adesklets itself is fully architecture independent, although 
443 Imlib2 is further optimized for the x86 and amd64. It is routinely used on 
444 x86, amd64 and ppc machines by the author.
446 At the time of writing, adesklets is already integrated in ports collections of
447 many BSD and software libraries of linux distributions. For reference, let's 
448 mention:
450 @itemize
451 @item Debian package: @weblink{http://packages.debian.org/unstable/x11/adesklets},
452 maintained by Bartosz Fenski @email{fenio@@debian.org}.
453 @item FreeBSD port: @weblink{http://www.freshports.org/deskutils/adesklets/},
454 maintained by Roman Bogorodskiy @email{novel@@freebsd.org}.
455 @end itemize
457 Did you try to run the package on something not listed here?
458 Let us know, especially if it did not work.
460 @section Software download
462 The current version of the software (as a source bzip'ed tarball) can be found
463 on the SourceForge project page: @weblink{http://sf.net/projects/adesklets/}
465 You can extract it from the console with @command{tar}. As of version
466 @value{VERSION}, the command line would be:
468 @example
469 tar xvjf adesklets-@value{VERSION}.tar.bz2
470 @end example
472 or, if your installed version of @command{tar} does not support
473 filtering archives through bzip2:
475 @example
476 bzcat adesklets-@value{VERSION}.tar.bz2 | tar xv
477 @end example
479 @section Verifying Software Integrity (optional)
481 As of adesklets @value{VERSION},  you can also
482 download from @weblink2{SourceForge,http://sf.net/projects/adesklets/} an 
483 ascii-armored detached signature named 
484 @command{adesklets-@value{VERSION}.tar.bz2.asc}, that you can match
485 against the author's Open PGP public key (@pxref{Open PGP Public Key},
486 in appendix) to assert the package integrity. For instance, with
487 @command{GnuPG} (@weblink{http://www.gnupg.org/}), you would use:
489 @example
490 gpg --verify adesklets-@value{VERSION}.tar.bz2.asc adesklets-@value{VERSION}.tar.bz2
491 @end example
493 You can also get the public key for @email{syfou@@users.sourceforge.net}
494 from various public key servers such as @weblink{http://www.keyserver.net/} or
495 @weblink{http://pgp.mit.edu/}. Feel free to contact the author directly if you
496 want to authenticate the key further.
498 @section Compilation and Installation:
500 adesklets provides the usual autoconf/automake scripts of GNU packages.
502 Therefore, in most cases, installation follows the normal three steps:
504 @enumerate
505 @item
506 `cd' to the directory containing the package's source code and type
507 `./configure' to configure the package for your system.  If you're
508 using `csh' on an old version of System V, you might need to type
509 `sh ./configure' instead to prevent `csh' from trying to execute
510 `configure' itself.
512 Running `configure' takes awhile.  While running, it prints some
513 messages describing which features it is checking for.
514 @item
515 Type `make' to compile the package.
516 @item
517 Type `make install' to install the programs and any data files and
518 documentation.
519 @end enumerate
521 You can remove the program binaries and object files from the
522 source code directory by typing `make clean'.  To also remove the
523 files that `configure' created (so you can compile the package for
524 a different kind of computer), type `make distclean'.
526 @section Compilers and Options:
528 Some systems require unusual options for compilation or linking that
529 the `configure' script does not know about.  You can give `configure'
530 initial values for variables by setting them in the environment.  Using
531 a Bourne-compatible shell, you can do that on the command line like
532 this:
534 @example
535 CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
536 @end example
538 @noindent Or on systems that have the `env' program, you can do it like this:
540 @example
541 env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
542 @end example
544 @section Optional Features:
546 adesklets comes with a few optional features you can select or not
547 from the `configure' script. Type:
549 @example
550 ./configure --help
551 @end example
553 @noindent for a complete, short description. Here are a few interesting ones:
555 @itemize
556 @item
557 You may choose to compile adesklets without X support at all
558 (@command{--without-x}).
559 You will get a version that is obviously not suited for
560 desklets rendering, but still good for command line image manipulation
561 @item
562 You can remove support for some others packages as well:
563 @command{--without-history}, @command{--without-fontconfig}
564 @item
565 The shell frontend can be avoided altogether using:
566 @command{--disable-frontend-shell-driver}
567 @end itemize
570 @node Using adesklets
573 @chapter Using adesklets
575 @ifplaintext 
576 INSTALL_END
577 @end ifplaintext
579 @section ... As a desklets container
581 By itself, adesklets does little: it only provides what is needed to
582 do more! You either need to tell it what to do by passing it commands
583 (see the next section) or you need other scripts (the desklets)
584 that will drive it for you.
586 @noindent Right now, many desklets exist: 
587 you may find them on adesklets web page as separate downloads:
588 @weblink{http://adesklets.sf.net/desklets.html}.
590 @subsection Add a new desklet to your X display
591 To add a new desklet script, simply:
593 @enumerate
594 @item
595 Download its tarball and unpack it somewhere in your home directory.
596 @item
597 Look at the included README file; special requirements or instructions
598 will be given. Usually, all you have to do is to get adesklets installed,
599 your X server running, then launch the executable script file from the
600 base directory.
601 @end enumerate
603 From adesklets 0.4.11, Python-based desklets will ask you explicitely if you want
604 to register or to test them. They will also support a @command{--help} switch,
605 that you can use to know the useful options you can pass to the adesklets 
606 interpreter when testing (fake root window detection, etc.).
608 @noindent Please note that:
610 @itemize
611 @item
612 Launching the same desklet script more than once will start multiple instances 
613 of it.
614 @item
615 On multi-head displays, scripts will be launched on their inherited default 
616 screen.  (For instance, if you do nothing special, calling a script from an
617 xterm on screen 1 will launch the desklet on screen 1).
618 @end itemize
620 @noindent Most of the time, desklets scripts are made to run as long as you
621 do not tell them to quit. The user has total control of starting, stopping,
622 restarting (when possible), and positionning the desklet (using the context menu, 
623 always available by right-clicking on the desklet). The desklet has 
624 no control over those operations.
626 @noindent Those few user settings are stored in the @file{$HOME/.adesklets}
627 file. Usually, you do not want to edit this file yourself.
628 If you do, make sure no instances of @command{adesklets} are running at
629 the same time.
631 @unnumberedsubsubsec Alternative to manual downloading the desklets
633 Since adesklets 0.5.0, you have a new @command{adesklets_installer}
634 script available if you installed the package with Python support: it provides
635 you with automated management of your desklets under @file{$HOME/.desklets} 
636 through a simple interactive interface. From a real or pseudo-terminal, 
637 invoke:
639 @example
640 adesklets_installer
641 @end example
643 Or, if you have the adesklets shell frontend:
645 @example
646 adesklets -i
647 @end example
649 It is able to detect what desklets you have, and to download, check integrity and
650 unpack new ones based on the information contained in 
651 the official desklets atom feed (@weblink{http://adesklets.sf.net/desklets.atom}).
652 Of course, it is still your duty to manually configure and launch them from there.
654 The @command{adesklets_installer} script comes with three user interfaces:
655 a Tk interface (the default, based on the Tkinter module), a curses interface as
656 well as a raw interface, that just assumes a trivial terminal is present 
657 (characters-based @file{stdin} and @file{stdout} streams). By default, the script
658 will try to present to the user the first it can in the given order, then fallback
659 to the next if it doesn't work @footnote{The raw interface should always work at the end of the day.},
660 but you can select one as well from the command line. See:
662 @example
663 adesklets_installer --help
664 @end example
666 for the invocation details.
668 @unnumberedsubsubsec Special notes on system fonts
670 @emph{You may safely skip this section if you do not intend to use
671 non-supplied fonts with adesklets.}
673 Provided your system supports fontconfig (@weblink{http://www.fontconfig.org/})
674 and adesklets was compiled without using @code{--without-fontconfig} (compiling
675 with fontconfig support is the default; @xref{Installing adesklets}.), all the
676 TrueType fonts present in your system are available for use with adesklets.
677 At initialization time, adesklets with fontconfig support compiled in will go
678 through all the fonts detected on your system to identify all the TrueType 
679 fonts. See your fontconfig documentation on how to set up your application
680 fonts access properly (@xref{Frequently asked questions}, for some fontconfig
681 debugging hints). It's also good to know that adesklets' package includes a
682 copy of Bitstream's Vera font; all users can rely on @command{adesklets} 
683 having at least this font available at all time.
685 @unnumberedsubsubsec Special notes on internationalization
687 @emph{You may safely skip this section if you do not intend to use
688 extended charaters within your desklets.}
690 If your system includes @command{iconv} support (@xref{Installing adesklets}.),
691 you should be able to use any character from any charsets your system 
692 knows about for displaying text, either inside a desklet or in its menus,
693 provided you have appropriate TrueType fonts (i.e. TrueType fonts containing
694 those character representations)@footnote{For instance, Bitstream's Vera font 
695 included with @command{adesklets} contains glyphs for practically all Latin-1
696 (ISO-8859-1) characters.}. 
698 Nevertheless, when using extended (outside 7-bit @code{ASCII}) characters, 
699 you need to make sure your local GNU readline settings do not interfere. These
700 three parameters should be set as indicated below in the appropriate 
701 @file{initrc} file@footnote{Please refer to your GNU readline documentation}:
703 @example
704 set input-meta on
705 set convert-meta off
706 output-meta on
707 @end example
709 If you do not want to adapt your GNU readline settings, you can also pass the
710 @code{--enable-force-extended-characters-input} switch to the @code{configure}
711 script when configuring the package from source, which will cause those three
712 variables to always be appropriately overriden internally by the interpreter.
714 Of course, you will also need desklets built to use those extended characters.
715 At the time of writing, all non-contributed Python desklets support them; for 
716 those, the charset can be set by the user in the configuration file, when it 
717 exists@footnote{When it does not exist, it means the desklet does not need 
718 internationalization anyway}; users merely have to set the 'coding' line 
719 appropriately@footnote{See @weblink{http://python.fyxm.net/peps/pep-0263.html}
720 if you need details.}.
722 For instance, for using ISO Latin-1 characters, one should use something 
723 similar to:
725 @example
726 # -*- coding: ISO-8859-1 -*-
727 @end example
729 as the first or second line in the Python desklet configuration file@footnote{
730 Obviously, such a configuration file needs to be saved using ISO Latin-1 
731 encoding or any subset of it, such as @code{ASCII}.}. 
733 Finally, please note that if your platform does not support iconv,
734 you should always leave the coding parameter to @code{ASCII}, otherwise
735 you will get fatal errors such as @code{charset conversion not compiled in}
736 from the desklets.
738 @subsection Restore previously running desklets on new X session
739 Invoking @command{adesklets} without any arguments@footnote{A word of warning: 
740 by default on adesklets 0.4.11 and up, you @emph{need} to employ some flags if 
741 your Window Manager uses a fake root window. @xref{Frequently asked questions}.}:
743 @example
744 adesklets
745 @end example
747 @noindent is enough to restart all desklets that were running the
748 last time you killed the X server (in this mode, @command{adesklets}
749 will exit quickly by itself: there is no need to run it in the
750 background. adesklets does not use a daemon; each applet will fork a 
751 standalone @command{adesklets} interpreter as a child process). 
752 Invoking @command{adesklets} when desklets are already running
753 will cause them to be killed before the creation of new 
754 instances@footnote{Both @command{adesklets} process and their immediate parents
755 will be sent a @command{SIGKILL} signal.}.
757 @noindent If you plan on using desklets on a regular basis, you should put
758 the previous @code{adesklets} command somewhere in your X session
759 initialization.  I cannot tell you where with precision, as it varies greatly
760 from system to system. Have a look at: 
761 @weblink{http://www.google.ca/search?q=''x window''+startup} for general help.
763 Since adesklets 0.4.11, a more complete shell based frontend is available
764 to you, if you installed it (which is the default). It gives you a more
765 feature-complete set of options. Run
767 @example
768 adesklets --help
769 @end example
771 To see what is at your fingertips. Please note that since adesklets 0.4.11, you 
772 usually @strong{must} specify on the command line proper flags if you need 
773 fake root window detection (@xref{Frequently asked questions}.).
775 @section ... As a command-line graphic editor
777 You can also use adesklets as a command-oriented graphic editor.
778 If you type, in a console:
780 @example
781 adesklets :
782 @end example
784 @noindent You will get something similar to:
786 @anchor{prompt}
787 @example
788 adesklets 0.1.0 (Fri Jan 28 19:09:13 EST 2005), on Linux 2.6.10
789 [gcc 3.4.3 20041125 (Gentoo Linux 3.4.3-r1, ssp-3.4.3-0, pie-8.7.7)]
790 Press TAB for hints.
791 0 >>> _
792 @end example
794 @noindent The last line is a prompt. It tells you you are ready
795 to enter command number 0. As of adesklets @value{VERSION}, you have around
796 150 commands at your fingertips. Thanks to GNU readline, a lot of
797 autocompletion hooks are present, giving you an easy way to look around. 
798 Press TAB while typing a  command name or a command's first argument, and 
799 useful information will be displayed. @xref{primer,,an adesklets's primer}, 
800 for more info.
802 @node Programming adesklets
803 @chapter Programming adesklets
804 @section An adesklets' primer
805 @anchor{primer}
807 As previously stated (@xref{About adesklets}.), adesklets is basically an
808 interactive Imlib2 console, with one or two aditionnal features:
810 @itemize
811 @item
812 When an X display is present, automated management of a single window
813 @item
814 Automated support for pseudo-transparency
815 @item
816 Management of long-running applets
817 @end itemize
819 @noindent So let's start a typical interactive session to see what
820 happens. Under X, open a terminal, and type:
822 @example
823 adesklets :
824 @end example
826 @noindent As in last section (@xref{prompt,,'Using adesklets as a command-line
827 graphic editor'}.),
828 you will get a prompt. Now, enter the command '@code{images_info}'. You should
829 get on stdout:
831 @example
832 2 images
833 id 0 width 1 height 1 alpha 1 filename (null)
834 id 1 width 1 height 1 alpha 1 filename (null)
835 command 0 ok: images_info
836 @end example
838 @noindent This tells you that you have two images: image 0 and image 1, each
839 1x1 pixels. Those are the only images you can never destroy nor do any
840 operations you want with (resize them independently, flip them diagonaly, etc.)
841 Why is that?
843 @itemize
844 @item
845 Image 0 is the foreground image. By default, it is the only image that is
846 displayed on the single window that @command{adesklets} manages.
847 @item
848 Image 1 is the background image. By default, it always contains the content
849 of the root window (the desktop) directly below the window.  Unless we set it
850 to be otherwise, it is always updated when the user moves it, when you resize
851 it, when your wallpaper changes, etc.
852 @end itemize
854 @noindent But where is this window? Well, right know, it is only 1x1 pixels,
855 and it is not shown@footnote{``Mapped'' in X Window lingo} on the screen.
856 So let's resize it to 100x100 pixels: type '@code{window_resize 100 100}'.
857 Now, if you re-enter the command '@code{images_info}', you will get:
859 @example
860 2 images
861 id 0 width 100 height 100 alpha 1 filename (null)
862 id 1 width 100 height 100 alpha 1 filename (null)
863 command 2 ok: images_info
864 @end example
866 @noindent The foreground and background images have been resized to
867 100x100 pixels.  Moreover, the background image has been updated to contain
868 a new image of the background. Now, let's make this window visible. Type two 
869 commands: '@code{window_reset managed}' and then '@code{window_show}'.
871 @noindent The first command tell adesklets to let your window manager
872 ``manage'' your window (the default is not to); it means the window gets
873 decorated, and you can interactively change its visibility@footnote{An
874 ``unmanaged'' window is very useful for scripted desklets: it looks like
875 it is part of the root window as it can be made to never go on top, and to stay
876 mapped when workspaces are switched.}. The second command shows our 100x100 
877 window. So far, it's nothing too impressive--just a black 100x100 square with a
878 titlebar and fixed-size borders.
880 @noindent As mentioned above, only image 0 (the foreground) is displayed by
881 default. Now, type: '@code{window_set_transparency 1}'. Wow! We see the
882 root window below! With ``window transparency'' on, the image 1 (background)
883 is first copied onto the window, then image 0 (foreground) which is purely
884 transparent black, is blended onto it@footnote{Well...Not quite. Actually,
885 there is a buffer involved for performance, but the operation is logically
886 equivalent to this description.}.
888 @noindent It is time to say a word about colors. Remember, adesklets is an 
889 Imlib2 console. Thus, as with Imlib2@footnote{Keep your Imlib2 documentation 
890 nearby; it is very handy! @xref{Imlib2 documentation}.}, colors are 
891 always true 32 colors, RGBA encoded, with eight bits (0 to 255) per channel,
892 including an alpha channel for transparency. Palette conversion and such will 
893 automatically take place if your screen depth is less than that, so you do not
894 need to bother with that. If you type: '@code{context_get_color}', you will get:
896 @example
897 command 0 ok: context color 255 255 255 255
898 @end example
900 @noindent Imlib2 is a kind of state machine; as such, it comes with a
901 ``context'' that remembers a series of attributes it will use in its future 
902 operations. For instance, we now know the color it will use as long as we do not
903 modify it is opaque pure white (red=255, blue=255, green=255, alpha=255). 
904 If we type: '@code{context_get_image}', it returns:
906 @example
907 command 0 ok: context image 0
908 @end example
910 @noindent Which means all window operations we perform are made directly on
911 the forgeground image. So, let's draw a filled semi-transparent magenta 
912 rectangle on the foreground. Commands could be: 
913 '@code{context_set_color 255 0 0 200}' and 
914 '@code{image_fill_rectangle 25 25 50 50}'. Neat, isn't it?
916 @noindent If you are used to Imlib2 programming, you will have noticed
917 by now those last few commands look quite familiar. This is pretty normal;
918 most of Imlib2 C functions are presented as corresponding 'commands' in
919 adesklets. This way, adesklets' command '@code{image_fill_rectangle}'
920 follows the same semantic as Imlib2's '@code{imlib_image_fill_rectangle()}'
921 function, the command '@code{context_set_color}' functions just like
922 '@code{imlib_context_set_color()}', etc. The only two significant (and
923 systematic) differences are that whenever you would use an 
924 '@code{Imlib_Something}' object in C, you use an integer ID with adesklets,
925 and on the semantic of the '@code{imlib_free_something()}' functions that need
926 to be given an ID instead of freeing the context selected object of this type.
928 @noindent This is pretty easy to illustrate. Let's load the ``Vera'' font 
929 included with adesklets at a 20pt size, set it as default font, and write in 
930 pure opaque white ``Hello'' diagonally on the foreground image from the top left
931 corner before unloading the font. It would look like:
933 @example
934 6 >>> load_font Vera/20
935 command 6 ok: new font 0
936 7 >>> context_set_font 0
937 command 7 ok: context_set_font 0
938 8 >>> context_set_direction text_to_angle
939 command 8 ok: context_set_direction text_to_angle
940 9 >>> context_set_angle 45
941 command 9 ok: context_set_angle 45
942 10 >>> context_set_color 255 255 255 255
943 command 10 ok: context_set_color 255 255 255 255
944 11 >>> text_draw 0 0 Hello
945 command 11 ok: text_draw 0 0 Hello
946 12 >>> free_font 0
947 command 12 ok: free_font 0
948 @end example
950 @noindent If you look at your imlib2 documentation, you will immediatly notice
951 the two differences we just talked about:  all references to the font Vera/20
952 are made through an integer ID (0 here), and the '@code{free_font}' command, 
953 unlike the corresponding '@code{imlib_free_font()}' function, is called with
954 the font ID as an argument instead of the context font.
956 @noindent Now let's say you want to save you resulting image; not a problem!
957 Let us type: '@code{save_image out.png}', and the foreground is saved in the
958 file ``out.png'' in the current working directory@footnote{For this to work, 
959 you need to have your Imlib2 installation properly configured for using libpng,
960 or you could receive a ``no loader for file format'' error.}. Now, just for 
961 the sake of it, let us exit adesklets, and start another interactive session
962 to see if we can reload this image. Just type in the ``@code{quit}'' command or
963 press ^D (Control D: end of file). Then your new session should look 
964 something like:
966 @example
967 0 >>> window_resize 100 100
968 command 0 ok: window_resize 100 100
969 1 >>> window_reset managed
970 command 1 ok: window_reset managed
971 2 >>> window_set_transparency 1
972 command 2 ok: window_set_transparency 1
973 3 >>> load_image out.png
974 command 3 ok: new image 2
975 4 >>> blend_image_onto_image 2 1 0 0 100 100 0 0 100 100
976 command 4 ok: blend_image_onto_image 2 1 0 0 100 100 0 0 100 100
977 5 >>> window_show
978 command 5 ok: window_show
979 6 >>> free_image 2
980 command 6 ok: free_image 2
981 @end example
983 @noindent Of course, we wanted to visualize the result; this is why we
984 emitted commands '@code{window_reset}', '@code{window_set_transparency}'
985 and '@code{window_show}'; they are not otherwise useful. The command
986 '@code{blend_image_onto_image}' comes straight from Imlib2 once again;
987 it takes the newly created image 2 from the third command and blends it
988 onto the context image (image 0, foreground by default), for its coordinates
989 (0,0) to 100x100 pixels farther, and puts it on the rectangle starting at (0,0)
990 of size 100x100 pixels of image 0. It is finally good to note that, with
991 adesklets, there is always an image in Imlib2 context: whenever you try to
992 free the current image, the image context is always reset to the foreground 
993 image.
995 @noindent OK, so it is almost the end of this primer... From there you should
996 play around with adesklets.  It is pretty straightforward to use if you are 
997 already familiar with Imlib2. If you are not, your best resource is certainly 
998 having Imlib2 documentation not far away. :-)
1000 @noindent Some last tips:
1002 @itemize
1003 @item
1004 If you get tired of typing, and typing, do not forget you have autocompletion:
1005 'TAB' your problems away!
1006 @item
1007 If you want to have hints on how to do something, you have a built-in
1008 '@code{help}' command.
1009 @item
1010 If you are working out a series of commands, things are not working
1011 and all this interactive usage it getting tiresome:
1012 @enumerate
1013 @item
1014 Use the '@code{history}' command to output your current session to a
1015 file@footnote{For this to work, you need to have GNU history when
1016 building adesklets.}.
1017 @item
1018 Use the '-f' switch with adesklets to get commands from a file instead
1019 of the console tty.
1020 @item
1021 If you try to visualise something, insert a '@code{pause}' command at the
1022 end of the script to freeze the interpreter.
1023 @item
1024 All strings from a pound sign '#' to the end of a line will get discarded,
1025 allowing you to write comments.
1026 @end enumerate
1027 @end itemize
1029 @noindent Here is an example:
1031 @example
1032 #!/usr/bin/env adesklets -f
1034 # Make the window 'managed'
1036 window_reset managed
1038 # Resize the window to 100x100 pixels
1040 window_resize 100 100
1042 # Show the window, then freeze for 10 seconds before exiting
1044 window_show
1045 pause 10
1046 @end example
1048 @noindent You will just have to make this script executable and run it. As
1049 usual, output from the commands will get printed to stdout.
1051 @itemize
1052 @item You could also use the @code{play} command. This two-arguments command
1053 gives you a way to replay any sequence of commands from history, using the 
1054 command number of the first and last command as parameters.
1055 @end itemize
1057 @section Real programming with adesklets: writing desklet scripts
1059 When you are ready for real work@footnote{:-)}, you might want to use
1060 a real scripted language instead of the raw @command{adesklets} interpreter we
1061 used in the primer; you never know when just having variables could come in 
1062 handy.
1064 At the time of this writing (@value{UPDATED}), the Python package is included 
1065 @footnote{adesklets was written to be easily used from a variety of interpreted
1066 languages -- do not hesitate to propose your help if you want to bring support 
1067 for your language of choice!}.
1069 @subsection General tips for programmers
1071 A really useful feature of the @command{adesklets} interpreter 
1072 is its ability to produce a full trace of its session (commands, events and
1073 special messages), either on @code{stdeerr} or as a log file, independently
1074 of what is driving it. To have access to this feature, one must:
1076 @enumerate
1077 @item Configure the package from source, passing along the @code{--enable-debug}
1078 switch to @code{configure}.
1079 @item Export the @code{ADESKLETS_LOG} variable in the environment if 
1080 the session's output should to be stored in files instead of printed
1081 to @code{stderr}@footnote{Printing to @code{stderr} will break most bindings, 
1082 and should therefore be used mainly when invoking the interpreter directly 
1083 from the console.}. It should be an absolute filename prefix which the
1084 interpreter, inheriting from the environment, can use to create complete file
1085 names to write to.
1086 @end enumerate
1087 From there, it is possible to read complete chronological session logs;
1088 used correcly, it is very useful for debugging purposes. You can use 
1089 it in conjunction with the @code{echo} command to set easy to find log points.
1091 @subsection adesklets and Python 
1092 @unnumberedsubsubsec Python usage example
1093 From Python, things are not very different than from the interpreter.
1094 Commands have been wrapped into Python functions, and an @code{Events_handler} 
1095 class has been made public to handle asynchronous feedback from the
1096 interpreter.  Let's have a look at the @file{test/test.py} script from the
1097 source tarball of version @value{VERSION}:
1099 @verbatiminclude ../test/test.py
1101 That's it! Twenty-six lines of Python code, and we have a perfectly functionnal
1102 desklet. I think things are pretty self-explanatory; have a look at the
1103 Python online help for @code{adesklets}, @code{adesklets.commands} and 
1104 @code{adesklets.Events_handler} for a good, complete explanation
1105 @ifhtml
1106 (@xref{Python package documentation}.)
1107 @end ifhtml
1108 .  All we do here is:
1110 @enumerate
1111 @item
1112 Import the @code{adesklets} package:
1113 this automatically instantiates a child @command{adesklets} process and sets up
1114 all communications.  When the package initialization returns without raising
1115 any exception, it means the interpreter is up and ready to accept commands.
1116 @item
1117 Subclass @code{adesklets.Events_handler} and redefine the methods invoked
1118 for the events we are interested in (all other events are not just ignored,
1119 they are not generated).
1120 @item
1121 Instantiate an object of this class, and put it on hold indefinitely
1122 @footnote{This last step is not mandatory; the script may very well continue,
1123 but it should be written so that it supports signal interruptions. See
1124 @code{help(adesklets.Events_handler)} for further explanations}.
1125 @end enumerate 
1127 @unnumberedsubsubsec Gotchas: a bit more about object IDs
1129 All adesklets objects (fonts, images, color ranges, polygons, etc), are stored 
1130 in stacks (one stack per object type). Python's ID's are nothing more than the 
1131 initial position of given objects inside the relevant stack, and therefore 
1132 will become invalid if an object of the same type below them gets freed.
1134 For instance, if we start with a clean state, all we have in the stack of 
1135 images is the window's foreground (ID 0) and background (ID 1). 
1136 When someone creates two other images from Python like so: 
1137 @example
1138 im_1 = adesklets.create_image(10,10)
1139 im_2 = adesklets.create_image(10,10)
1140 @end example
1141 @noindent We get @code{im_1==2}, and @code{im_2==3}. Whenever someones does:
1142 @example
1143 adesklets.free_image(im_1) 
1144 @end example
1145 @noindent The stack starts collapsing, and what was once image 3 (@code{im_2}) 
1146 is now image 2, and @code{im_2} is now an invalid reference. This clearly means 
1147 that invoking:
1148 @example
1149 adesklets.free_image(im_2) 
1150 @end example
1151 @noindent would generate an @code{image out of range} error message.
1153 @unnumberedsubsubsec Special subject: animations
1155 @command{adesklets} now includes an indirect mode of execution and textual 
1156 variables (non-recursive textual replacements, to be precise) as well. 
1157 This means desklets writers have what is needed to create precisely-timed
1158 animations. You can find an easy-to-follow example in @file{test/fading.py}.
1159 A somewhat more involved use of these features is also made in the @code{yab}
1160 desklet. To realize an animation from Python, one should:
1162 @enumerate
1163 @item @strong{Record} a sequence of commands 
1164 (we will call it a macro command, or macro for now on). From Python, this
1165 involves toggling on indirect mode using the @code{adesklets.start_recording()}
1166 function, emitting an undetermined number of @command{adesklets} commands,
1167 then toggling back into normal mode (direct execution) with 
1168 @code{adesklets.stop_recording()}. Of course, no command is ever evaluated
1169 while the interpreter is in indirect mode; commands are only stored in the
1170 history for future replay.
1171 @item @strong{Set up} whether the to-be-replayed sequence of commands can be
1172 interrupted by events or not, using the @code{adesklets.play_set_abort_on_events()}
1173 function. The high-level @code{adesklets.Events_handler::set_events()} method
1174 can also be used to dynamicaly change what events are caught. See 
1175 @file{test/test_events.py} for an example.
1176 @item @strong{Set up} the variables used within the recorded macro using the 
1177 @code{adesklets.set()} function, very similar to its Bourne shell homonym.
1178 @item @strong{Play} the macro using the @code{adesklets.play()} function.
1179 @end enumerate
1181 Here are a few additional remarks:
1182 @itemize
1183 @item Precise timing during replay is achieved through the @code{time_gate}
1184 command. This works very simply: every time a macro replays, adesklets
1185 records its starting time, and whenever a @code{time_gate} command is
1186 encountered during the replay, it waits for the number of seconds given as
1187 an argument to @code{time_gate} to run out. For instance, specifing
1188 @code{time_gate 0.1} in a macro will make any subsequent commands within the
1189 macro not execute before the macro has run for at least a tenth of second.
1190 @item Variable expansion always occurs just before command execution, regardless
1191 of current interpreter mode (direct or indirect). All sequences of characters
1192 not containing spaces directly following a single '$' will get replaced with
1193 the corresponding variable content (previously configured using @code{set}).
1194 If no matching variable is found, the sequence is simply discarded.
1195 @item All macro commands replayed through the @code{play} command are always 
1196 atomic for the driving desklet, as are any other non-macro commands. 
1197 Simply put, it means no event will ever get generated while a macro is replayed;
1198 they will all get issued right after the @code{play} command returns.
1199 @item As usual, the adesklets interpreter is stateful for indirect mode related 
1200 states and variables. You do not have to set up the @code{set_abort_on_events}
1201 flags or variable every time you want to call a macro, only if something
1202 needs to be changed since the last call.
1203 @item The main use of high-level @code{adesklets.Events_handler::set_events()}
1204 is to stop the catching of specific events during macro playback, so the macro
1205 can be interrupted only in specific circumstances. Of course, all events
1206 generated before the call to the method will not be lost but queued, and
1207 appropriate event methods will be called later, provided the handlers are set 
1208 back once the macro playback completes.
1209 @item Did we mention that it is a bad idea to do any of this from an unprotected
1210 place? Well, it is. Don't forget to use @code{adesklets.Events_handler::block()}
1211 and @code{adesklets.Events_handler::unblock()} around all animation-related code
1212 if you have an object of a child class of @code{adesklets.Events_handler}
1213 instantiated.
1214 @end itemize
1216 @unnumberedsubsubsec Configuration and internationalization
1218 Let us just mention here that from @command{adesklets} 0.4.0, the
1219 @code{adesklets.utils} module now includes an optional 
1220 @code{ConfigFile} class that can be easily reused by desklets authors 
1221 to add an easily extendable configuration facility to their 
1222 code@footnote{You can look at any non-contributed configurable desklet for 
1223 example usage.}
1224 @ifhtml
1225 (@xref{Python package documentation}.)
1226 @end ifhtml
1227 . The class also handles internationalization automatically by default, 
1228 setting the charsets according to users' needs. Charset usage can of course 
1229 be determined or changed at any time using the @code{adesklets.get_charset()}
1230 and  @code{adesklets.set_charset()} functions. The 
1231 @code{adesklets.utils.ConfigFile} class also has a @code{charset} attribute one
1232 can examine to determine the user's preference. When using this class, one
1233 should  note that an 'ASCII' charset is considered the default, and will not 
1234 toggle any conversion. This way, users on platforms not supporting iconv will 
1235 always be able to use @command{adesklets} without internationalization support.
1237 @unnumberedsubsubsec Final words
1239 @noindent Finally, let us mention you may want to take a look at the 
1240 @file{weather} desklet source code from the
1241 @weblink2{SourceForge project web site,http://sourceforge.net/projects/adesklets/} 
1242 for a more substantial piece of Python code using adesklets. There are also a 
1243 few other test desklets under @file{test/} that may give you some ideas.
1244 @ifhtml
1245 You could also have a look at pydoc's autogenerated
1246 @command{adesklets} package help, included with this document
1247 (@xref{Python package documentation}.). Whenever you are happy enough with 
1248 your desklet, feel free to share it with the rest of us (this would be 
1249 much appreciated)--package it (@xref{Packaging GNU Makefile for desklets}.), 
1250 and then submit it (@xref{Submitting a desklet}.).
1251 @end ifhtml
1253 @node Extending adesklets
1254 @chapter Using adesklets from other language environments
1256 adesklets was made to be easily usable from a variety of langage
1257 environments@footnote{We use the term ``langage environment'' because the 
1258 problem is not the syntax or the paradigm used (should it be imperative, 
1259 functional, or anything else); it is the way you can handle basic POSIX-related
1260 operations with files, signals, etc. (@xref{Requirements}.). Thus, a Perl 5 
1261 user should use adesklets easily, while a Linux JDK user would probably 
1262 encounter more difficulties (no flames intended).}. This chapter explains 
1263 to programmers how the adesklets interpreter hooks itself into the system 
1264 in a language-neutral fashion.
1266 @noindent If you are not minimally used to POSIX systems or do not have basic 
1267 notions on operating system programming, this chapter is probably of no
1268 interest to you.
1270 @noindent Please note that the Python package under 
1271 @file{scripting/python/adesklets} 
1272 is a good complement for what you are about to read.
1274 @section Requirements 
1275 @anchor{Requirements}
1276 If you want to use the adesklets interpreter from your favorite language
1277 but it is not supported out of the box@footnote{As of adesklets
1278 @value{VERSION}, only Python is supported out of the box.}, you can still do
1279 it, provided your langague supports one of these features:
1281 @itemize
1282 @item Reading and writing in pipes; or
1283 @item Reading and writing from/to files unbuffered 
1284 @end itemize
1286 @noindent It should also be able to either@footnote{This said, having both IPC
1287 support and poll/select will make things both simplier and cleaner. Being able 
1288 to block signals is also very useful.}:
1290 @itemize
1291 @item Catch IPC reliable signals; or
1292 @item Read files in non-blocking mode; or
1293 @item Be able to perform a poll/select on files
1294 @end itemize
1296 @noindent Finally, it should also be able to start a child process. 
1298 @noindent Those a pretty light requirements from a POSIX point of view, but let
1299 us mention for the sake of completeness that if your language environment does
1300 not meet these requirements, you could still use it provided you can get your
1301 application to talk reliably with another program@footnote{This would be a
1302 wrapper, basically.} that meets them. Of course, this is not an ideal situation
1303 and it should be avoided as much as possible.
1305 @section Initialization mechanism
1307 As you probably know (@xref{Using adesklets}.), there are two modes of operation
1308 for @command{adesklets}, as it can be called:
1310 @enumerate
1311 @item as a desklets launcher--whenever you call @command{adesklets} without 
1312 arguments.
1313 @item as an interpreter--in all other cases (interactive command line use
1314 or a child process from a desklet).
1315 @end enumerate
1317 @subsection adesklets called as a desklets launcher - restarting all desklets 
1318 @noindent On a new X session, the typical startup sequence is:
1320 @enumerate
1321 @item @command{adesklets} gets called without arguments, somewhere 
1322 from the X session initialization scripts.
1323 @item From there, the new adesklets instance acts as a desklets launcher. 
1324 It parses the @file{$HOME/.adesklets file}, then forks as many times as there 
1325 are desklets to start.  The original launcher process then exits as there is
1326 no need for a daemon here.
1327 @item All forked processes set up the @code{ADESKLETS_ID} environment variable
1328 with a string representation of the proper integer ID, then execute
1329 @footnote{With a call from the execve* family; see @code{man 2 execve}.} 
1330 the associated script.
1331 @item Each desklet launches itself an @command{adesklets} instance as a child
1332 process, passing along the @code{ADESKLETS_ID} variable without altering it. 
1333 It is the desklet's duty to make sure that:
1334 @itemize
1335 @item the adesklets interpreter standard streams, 
1336 @code{stdin}, @code{stdout} and @code{stderr}, get separately redirected, 
1337 in a way that parent process can easily write to adesklets' @code{stdin}, 
1338 and read from @code{stdout} and @code{stderr}. Use of pipes, FIFOs or event
1339 regular files are all possible.
1340 @item the writes to @code{stdin} and reads to the two other streams are 
1341 all unbuffered.
1342 @item the first command argument given to @command{adesklets} is the absolute
1343 file name of the desklet script.
1344 @end itemize
1345 @item Each newly created @command{adesklets} interpreter process initializes 
1346 itself using the environment @code{ADESKLETS_ID} variable and the command
1347 line absolute desklet name given as its first argument to lookup its 
1348 unscriptable characteristics@footnote{They are, namely, its screen and 
1349 coordinates.} from @file{$HOME/.adesklets}. When this operation is over, 
1350 the @code{ready!} event is generated (@xref{Events}.), and the interpreter is 
1351 ready to process commands.
1352 @end enumerate
1354 @subsection adesklets called as an interpreter - registration of a new desklet
1356 When a new desklet gets called directly, the startup sequence described in
1357 the previous subsection is the same, except for the first, second and third
1358 steps which simply don't occur. This means that the environment 
1359 @code{ADESKLETS_ID} is not set; the new @command{adesklets} interpreter uses 
1360 this fact to detect this is a new desklet, parse the @file{$HOME/.adesklets}
1361 configuration file and allocate the first free ID to the desklet.
1363 @noindent It should be noted that if the desklet file name given as the first 
1364 argument to the child @command{adesklets} instance is relative or is not both
1365 readable and executable by the current user, the desklet will not get registered
1366 in @file{$HOME/.adesklets}, and therefore not automatically restarted in 
1367 subsequent new X sessions by the launcher. In case @code{stdin} is a 
1368 terminal@footnote{Which means the session is interactive}, the registration
1369 does not take place either.
1371 @subsection Consequences
1372 This way, from the scripted desklet perspective, both cases are identical, and
1373 no conditionnal treatment is needed. All the desklet initialization job 
1374 is synthesized in the fourth point in the subsection above.
1376 @noindent If needed later on, the desklet can use the @code{get_id} command 
1377 to determine its ID.
1379 @section Using streams
1381 As explained previously, a desklet communicates with its private adesklets 
1382 interpreter via redirected unbuffered streams. Here, let us see what information
1383 they convey.
1385 @subsection stdin: the commands
1387 On the interpreter's @code{stdin}, the desklet outputs the commands it wants to
1388 execute in the order in which it wants them to be executed, one command per 
1389 line@footnote{A '\n' character should be emitted after each command.}. Since 
1390 reading this stream is suspended while a command is processed, a desklet should
1391 generally wait for a command to be processed before emitting 
1392 another@footnote{This is to avoid process blocking by overflowing the stream 
1393 with arbitrarily long commands; of course, there is no problem sending three
1394 commands of a few hundred bytes in one shot!} (See the next section).
1396 @noindent The command format is pretty simple: it is a command name, followed 
1397 by arguments separated by spaces, all in plain text representation, including 
1398 numbers. adesklets does not care about the number of spaces between arguments,
1399 as long as there is at least one. In the special case of commands where the
1400 last argument is a string (@code{text_draw}, for instance), adesklets will
1401 choose its first non-space characters to be its beginning; the rest of the
1402 line, including spaces, are considered to be part of the string.
1404 @noindent Two files, automatically kept in sync with the source 
1405 (@file{scripting/prototypes} and  @file{scripting/enums}) from the base source
1406 distribution, provide in tab-separated plain text format the description of all
1407 the commands and numeric constants that can be made available to the 
1408 desklets@footnote{See @file{scripting/protoize.sh.in} and 
1409 @file{scripting/enums.sh} for details on the format of the two files.}. A good 
1410 binding for a specific language should come with some automation to
1411 auto-generate pertinent parts of its own codebase based on those files; for
1412 instance, the Python binding adds a @code{protoize} action to its 
1413 @file{setup.py} @code{distutils} script to do so. Ideally, this automation code
1414 should be redacted in the target language with a reasonable set of 
1415 libraries@footnote{The key idea being that most users of your binding should be
1416 able to run it more or less from their base installation of the language.}; 
1417 if it is not well suited to this task, you need to limit yourself to use:
1419 @itemize
1420 @item Portable Bourne shell, conforming to POSIX 1003.2 and 1003.2a, scripts
1421 @item A recent sed (Streaming Editor), compatible with GNU
1422 sed@footnote{Nowadays, there is no problem running GNU sed on practically any
1423 POSIX system.}
1424 @item Portable use of any bc for arithmetic
1425 @end itemize
1427 @noindent if you want your work to become part of the official package.
1429 @subsection stdout: the command results
1431 The @command{adesklets} interpreter frequently polls its @code{stdin} 
1432 for new characters, and reads from it as needed. Whenever it receives an
1433 End-Of-Line ('\n'), it stops reading from it and tries executing the command. 
1434 Once the command has been carried out (possibly emitting a few lines on
1435 @code{stdout}), it sends as its last entry on it a status message of the form:
1437 @example
1438 command RANK ok: MESSAGE_STRING
1439 @end example
1441 @noindent if the command was successful, or:
1443 @example
1444 command RANK error: ERROR_STRING
1445 @end example
1447 @noindent if an error occurred.
1449 @noindent @code{RANK} is the numerical ID of the command (an unsigned integer)
1450 that starts at zero when the interpreter is created, and then is automatically
1451 incremented by one for every subsquent line it receives. All commands are 
1452 guaranteed to be processed in the order they were submitted. 
1453 @code{ERROR_STRING} is a free-form message in human-readable form explaining the
1454 source of the error. @code{MESSAGE_STRING} is also in human-readable form, but
1455 is formatted in such a way that it can be used to retrieve algorithmically
1456 useful return values for any commands. Those return values can be:
1458 @enumerate
1459 @item an integer--the return value ID (@code{create_image} and such)
1460 @item a tuple of integers--the numerical command output 
1461 (for @code{context_get_color} and the like)
1462 @item a list of strings--the ordered list of output strings 
1463 (for @code{images_info} and the like) for commands that output multiple lines
1464 on @code{stdout}, with the last line being the status message 
1465 @item a description string--a one-line textual answer from the command
1466 @item nothing at all
1467 @end enumerate
1469 @noindent Algorithmically, your "return value retrieving routine" should first
1470 try to retrieve integers from 
1471 @code{MESSAGE_STRING}@footnote{All parameters from the @code{MESSAGE_STRING}
1472 are separated by single spaces.}. If there is one or more integers present, 
1473 it should verify that the message is not a mere copy of an emitted command;
1474 if it is, the return value follows the fifth case (see above); otherwise, 
1475 if only one integer is found, this is the first case; if more than one is
1476 found, the second one.  If no integers are found and there was a list of lines 
1477 sent to stdout before the status message of the command, and after the status
1478 message of the previous command, it then returns according to third case.
1479 In what's left, if the status message is different from the emitted command, it
1480 is the fourth case. All remaining conditions should be mapped to the fifth
1481 case. This retrieving algorithm is working for all commands listed in
1482 @file{scripting/prototypes}.
1484 @subsection stderr: the events
1485 @anchor{Events}
1487 All remaining asynchronous event reports are sent to the interpreter's
1488 @code{stderr}. They are asynchronous regarding the processing of commands;
1489 if they will never occur while a command is processed (in the time interval
1490 between the submission of the complete command on @code{stdin} and the output
1491 of its message status line on @code{stdout}), they can be sent at any other
1492 time@footnote{No event is ever lost anyway; its report is only delayed.}.
1494 @noindent Event reports are single lines of the form@footnote{All other outputs
1495 on @code{stderr} can safely be discarded.}:
1497 @example
1498 event: EVENT_MESSAGE
1499 @end example
1501 @noindent In a stylized Backus Naur form, the grammar for EVENT_MESSAGE would 
1504 @verbatim
1505 EVENT_MESSAGE :: ready! |
1506                  backgroundgrab |
1507                  menufire MENU_ID MENU_STR |
1508                  motionnotify X Y |
1509                  enternotify X Y | 
1510                  leavenotify X Y |
1511                  buttonpress X Y BUTTON_ID |
1512                  buttonrelease X Y BUTTON_ID
1514 @end verbatim
1516 @noindent where @code{MENU_ID}, @code{X}, @code{Y}, and @code{BUTTON_ID} are
1517 all integers greater than or equal to zero, and @code{MENU_STR} is a string of
1518 characters, possibly including spaces. Let us detail things a bit further:
1520 @itemize
1521 @item Ready event: sent only once, whenever the @command{adesklets} interpreter
1522 becomes ready to process commands.
1523 @item BackgroundGrab event: sent every time the background image (image 1) gets 
1524 regenerated.
1525 @item MenuFire event: sent every time the user select an item in a menu not
1526 managed internally by adesklets.
1527 @item MotionNotify event: sent whenever the pointer moves inside the adesklets 
1528 window.
1529 @item EnterNotify, LeaveNotify: sent whenever the cursor passes over a visible
1530 border of the interpreter window, either going in or out.
1531 @item ButtonPress, ButtonRelease: sent when a pointer button is clicked inside 
1532 the interpreter window.
1533 @end itemize
1535 @noindent All events but Ready! (namely: MotionNotify, EnterNotify, 
1536 LeaveNotify, ButtonPress, ButtonRelease, BackgroundGrab and MenuFire) are
1537 masquable by the desklet. In fact, @command{adesklets} provides the desklet
1538 with commands for specifically handling the generation and output of events.
1539 They are: 
1540 @code{event_catch}, @code{events_get_send_sigusr1}, @code{events_reset_all},
1541 @code{event_uncatch}, @code{events_info}, @code{events_set_echo}, 
1542 @code{events_get_echo}, @code{events_purge} and @code{events_set_send_sigusr1}.
1543 It should be noted that those functions are not listed in
1544 @file{scripting/prototypes} as you most probably do not want your users having
1545 access to them. You should probably start an interactive session and play with
1546 them to make sure you fully understand this. This is also the right time to
1547 mention the @file{src/adesklets_debug.sh} script, which comes in handy when
1548 interactively experimenting with events.
1550 @noindent Two last things are worth mentionning about events:
1552 @enumerate
1553 @item By default, events are not echoed, but stored internally, waiting 
1554 to be purged with @code{events_purge}. You can change this with
1555 @code{events_set_echo}.
1556 @item You can set the adesklet interpreter to send a SIGUSR1 signal every time
1557 an event is printed out to its parent process (the desklet). It is a very
1558 useful IPC, since the signal can be trapped, allowing the event management
1559 routine to run only when necessary. This is what the Python package uses within
1560 its @code{Events_handler} class.
1561 @end enumerate
1563 @section SIGCHLD signal handler
1565 Whenever your language allows it, you should install some kind of SIGCHILD
1566 handler, so you can at least be notified if the adesklets interpreter ever
1567 exists without a reason (child zombies notwithstanding)@footnote{@code{man 2
1568 signal} is a very good reference on signals.}.
1570 @section Textual variables
1572 @command{adesklets} also supports differed execution (indirect mode)
1573 and textual replacement of variables. Here how variables work in indirect mode:
1575 @enumerate
1576 @item Once a command is entered, it is stored untouched into the commands
1577 history list, if applicable (in non-interactive usage of the interpreter,
1578 when the command lies bethween calls to @code{start_recording} 
1579 and @code{stop_recording})
1580 @item When a macro command is played back (using the @code{play} command,
1581 @xref{Programming adesklets}.), variables get expanded in a single pass, and no
1582 indirect reference is possible.  Expansion is pretty straightforward. The stored
1583 command line is scanned for any non-empty sequence of non-space characters
1584 beginning with a single '$'.  Each such sequence is replaced with the 
1585 corresponding @code{$variable} value, or removed if no variable is found.
1586 @item Expanded command get executed.
1587 @end enumerate
1589 The same expansion mechanism also applies to the direct mode of execution. All
1590 this leads to the fact that, using the Python package for instance, these two
1591 code snippets are equivalent:
1593 @example
1594 adesklets.window_resize(100,100)
1595 @end example
1597 and:
1599 @example
1600 adesklets.set('dim',100)
1601 adesklets.window_resize('$dim','$dim')
1602 @end example
1604 This did not require any alteration of our Python code, since Python is a
1605 dynamic language, but some other languages will require further thinking.
1607 @section Final words
1609 You should now know pretty much everything needed for integrating adesklets with
1610 your language environment. It may appear to be a daunting task, but a very
1611 clean binding can be produced by one programmer in only a few days. Once again,
1612 have a look at @file{src/adesklets_debug.sh}; it is a (very lame) Bourne shell 
1613 binding for adesklets written in only fifty lines, including comments.
1615 If you ever need assistance, you are encouraged to post on the 
1616 @weblink2{adesklets-devel mailing list,https://lists.sourceforge.net/lists/listinfo/adesklets-devel}...
1618 Happy coding!
1620 @noindent 
1621 @node Help wanted!
1622 @chapter Contributing to adesklets
1624 Your help is wanted! You can valuably contribute to adesklets by:
1626 @itemize
1627 @item
1628 @strong{Posting your adesklets screenshots online}. You use adesklets and think
1629 you have a pretty cool desktop? Share it with the world by posting it online,
1630 and send us a link! This way, you will help people learn about the project.
1631 @item
1632 @strong{Contribute to the documentation}. You have very good written
1633 knowledge of German, Spanish, Portugese, Arab or Swahili? Translators are always 
1634 welcomed, proofreaders too, for all languages.
1635 @item
1636 @strong{Writing new desklets}. adesklets is still young: we crave
1637 talented desklets writers, and we would be more than willing to post or link
1638 to your work. Do not worry too much about interface changes; the author spent
1639 considerable effort to ensure that the interface would be fairly stable even
1640 in the earliest releases.  It's not frozen forever, but it shouldn't break your
1641 desklets without some warning.  At this point, the API is predominantly getting
1642 internal bug fixes and portability improvements.
1643 @item
1644 @strong{Adding bindings for your language of choice}. Contact the developers 
1645 beforehand so that you don't waste time on something that is already written;
1646 they will be glad to share code.  Subscribe to the
1647 @weblink2{adesklets-devel mailing
1648 list,https://lists.sourceforge.net/lists/listinfo/adesklets-devel} on
1649 SourceForge for quick access to them.
1650 @end itemize
1652 @noindent Contact me by email at @email{syfou@@users.sourceforge.net}.
1654 @node Frequently asked questions
1655 @appendix Frequently asked questions
1657 Last update: @value{UPDATED}
1658 @appendixsection Compiling adesklets
1660 @subheading The adesklets configure script says my Python install is too old, but it's not. What's the problem?
1662 Some platforms (NetBSD, Ubuntu Linux, probably others too) sometimes alter 
1663 the Python version, appending letters, prefixing minor numbers, etc., thus 
1664 preventing the configuration script from detecting it properly. If you know 
1665 @strong{for sure} that what you have installed is at least 2.3.0,
1666 you can pass the @code{--with-python-force-detection} switch to 
1667 @code{configure}; this will make the configuration script skip the version 
1668 detection.
1670 @appendixsection Installing desklets
1672 @subheading I find the default desklets installation method tedious: it there a simpler way to install them?
1674 From adesklets 0.5.0, you have a new @command{adesklets_installer} 
1675 script (@xref{Using adesklets}.). It can
1676 help you download and unpack new or updated desklets. 
1678 @subheading Well, that's kinda better, but it is still not fully automated (I hate reading and understanding new things, you know)...
1680 True. @command{adesklets_installer} just notify you of updates, download, 
1681 check and unpack desklets, but it is still your duty to see their README, 
1682 fulfill their requirements, start, stop and configure them.
1684 But frankly, it is @emph{that} difficult? Most people does not change their
1685 desklets settings very often anyway. This is was deliberate choice from our
1686 part: the goal of adesklets has always been to minimize overall code 
1687 complexity, leading to a leaner, tighter, more consistent package. Why solving
1688 in a long, tedious, hard to write and maintain software all the corner cases a 
1689 smart user can figure out in minutes with proper documentation?
1691 If full automation it what you look for, have a look at the alternatives 
1692 to adesklets (@xref{About adesklets}.).
1693 @appendixsection Starting and stopping desklets
1695 @subheading 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?
1697 It means what is written: @command{python} cannot find the @code{adesklets}
1698 package; maybe it did not get installed, or it did get installed in the wrong
1699 place.
1701 @itemize
1702 @item Restart from the beginning the installation procedure
1703 (@xref{Installing adesklets}.). Make sure you @strong{do not} select
1704 the @code{--without-python-support} configuration option.
1705 @item Retry starting the desklet. If it still does not work, verify that the
1706 installation directory, given by:@example
1707 sed -n '/PYTHON_SITE_PKG/p' Makefile
1708 @end example
1709 @noindent is included in :@example
1710 echo 'import sys; print sys.path' | python
1711 @end example
1713 @noindent If not, you can still manually move the adesklets directory 
1714 from @code{PYTHON_SITE_PKG} to any path displayed by this last command.
1715 @end itemize
1717 @subheading When I try to start a new desklet, I get an @code{ADESKLETSError: adesklets process exited} error from the Python interpreter. What is this?
1719 This is a generic error telling you something is off with the low-level 
1720 interpreter, critical enough to cause it to exit. If  you are lucky, 
1721 you will have at the end of the line a dash, followed by 
1722 a descriptive message telling you what went wrong. In that case, if you have 
1723 difficulty understanding it, just seek help online. If no clue is given to you regarding the error origin, try this from a pseudo-terminal under X:
1724 @example
1725 echo x_status | adesklets :
1726 @end example
1727 You should normally get something similar to:
1728 @example
1729 event: ready!
1730 command 0 ok: x_status 1 (connected to ':0.0')
1731 @end example
1733 If you do, you are probably using a system
1734 (@weblink2{archlinux,http://www.archlinux.org/} for instance),
1735 on which the @code{PATH} variable for the Python interpreter differs from
1736 what is inherited from standard environment, which causes the Python package to
1737 fail to launch adesklets as a child process. On such systems, make sure
1738 to install @command{adesklets} using an appropriate @code{--prefix} switch at
1739 the configuration stage. For instance, on most recent Linux platforms, you 
1740 should use:
1742 @example
1743 ./configure --prefix=/usr
1744 @end example
1746 @subheading I cannot run any Python-based desklet: I get garbage collection errors!
1747 If you get errors similar to:
1749 @example
1750 python: Modules/gcmodule.c:275: visit_decref: Assertion `gc->gc.gc_refs != 0' failed.
1751 Aborted 
1752 @end example
1754 It means your installment of Python has a corrupted garbage collector; it is 
1755 often caused by incorrect or aggressive optimization during the compilation. 
1756 Just recompiling a stock python environment from 
1757 @weblink{http://python.org/} usually solves this.
1759 @subheading Desklets start fine as root, or as local user account, but just freeze or exit on NFS-mounted accounts
1761 adesklets needs to be able to lock some files under @code{$HOME} for working 
1762 reliably: most problems with network file systems are due to semi-functionning 
1763 installment failing to honour such locks. You have a short script under 
1764 @code{test/flock.py} in adesklets source tarball that provides a simple test 
1765 of fcntl locks; its normal behavior is to acquire a lock in the current working 
1766 directory, wait for the user to press a key, then release it and exit. 
1767 You can launch multiple instances of the script from the same directory to 
1768 verify that the locking is indeed working. If not, making it work will very likely
1769 make adesklets work too.
1771 @subheading Everything worked fine but then I tried upgrading a desklet, and I couldn't ever see the new one. What is wrong?
1773 There is a built-in lock mechanism in the interpreter that prevents a user from
1774 simultaneously running more than one desklet with the same @code{ID} and name,
1775 regardless of version.  Whenever you upgrade a given desklet, you should first
1776 cleanly quit the desklet (by using @code{Quit} from the context menu), then
1777 install the updated desklet by following the instructions provided in the 
1778 @file{README} file.
1780 @subheading 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!
1782 This is most probably related to the way you started the desklet
1783 (Please @pxref{Using adesklets}.). You need to invoke the desklet script
1784 @strong{only once}. Afterwards you just need to run the command:
1786 @example
1787 @command{adesklets}
1788 @end example
1790 and it will remember where you placed your desklets and which desklets 
1791 you had running. Do not forget the pass flags to @command{adesklets}, 
1792 as appropriate.
1794 @subheading This is exactly what I did, but the darn thing wouldn't restart anyway.
1796 Did you store the desklets under a @file{$HOME/.adesklets} directory?
1797 Please don't.
1798 @command{adesklets} need a @file{$HOME/.adesklets} file to store the various
1799 user settings on running desklets; setting up a directory of the same name 
1800 prevents it from doing its job right, so just move your directory some place 
1801 else (@file{$HOME/.desklets}, for instance).
1803 @subheading Starting the desklets works fine, but they continue running when I terminate the X session.
1805 Normally, the desklets are supposed to be automatically terminated on the dead of
1806 the session. If you have the frontend shell server installed (the default), 
1807 you can also kill them manually by invoking the 
1809 @example
1810 adesklets --killall
1811 @end example
1813 command somewhere from the session exit.
1815 @appendixsec Displaying desklets
1817 @subheading Where are my desklets? @command{adesklets} interpreters seem to be running fine, but I just cannot see anything on my desktop (the so-called flickering problem)!
1819 Try the command:
1821 @example
1822 python test/test.py
1823 @end example
1825 @noindent from the base source directory. If a 100x100 window appears when 
1826 testing the desklet, it most probably means you are using a window manager 
1827 that draws a big window (so called ``fake'' root window) over the root window; 
1828 your desklets are just drawn below it. Such window managers include Nautilus, 
1829 KDE, Xfce4, CDE or E17. As on adesklets @value{VERSION}, supported window 
1830 managers in that category are:
1832 @itemize
1833 @item @strong{KDE}: for versions >= 3.4.1 (earlier versions untested). 
1834 You need to turn on ``Control Center -> Desktop -> Show icons on desktop -> 
1835 Allow programs in desktop window'', or to turn off the ``Show icons on desktop'' 
1836 altogether@footnote{Thanks to Stefan Jungcurt for the hint.}.
1837 @item @strong{Nautilus}
1838 @item @strong{ROX-Filer}: only preliminary support for now
1839 @item @strong{Xfce4}
1840 @item @strong{xffm-desktop}: only preliminary support for now
1841 @end itemize
1843 From adesklets 0.4.11 and onward, the fake root window detection method had 
1844 changed: it is no longer part of the C code by 
1845 default@footnote{Although you can get back
1846 the old behavior if you wish by using
1847 @command{--enable-legacy-fake-root-window-detection} at configuration time.
1848 @xref{Installing adesklets}.}. The interpreter now expects 
1849 the ADESKLETS_ROOT environment variable to contain the correct fake root
1850 window hexadecimal ID, if any. You can of course set it manually, 
1851 but a shell frontend will be handling most common window managers for you 
1852 (see list above), as long as you instruct it to. Try invoking:
1854 @example
1855 adesklets --help
1856 @end example
1858 If the shell frontend is installed, you will get many options, including how to
1859 trigger window managers specific fake root window detection routines.
1860 You also have a ``generic'' fake root window detection under 
1861 the switch @command{--user}: it could work (or not) for you, depending on 
1862 the structure of your window manager. Finally, please note the frontend 
1863 is a simple sh-compatible script, installed by default under 
1864 @command{$prefix/share/adesklets} -- it should be pretty
1865 straighforward to modify by anyone wishing to implement other detection schemes.
1867 It is also good to remember that fake root window detection obviously requires
1868 such windows to exist. It is therefore important to invoke 
1869 @command{adesklets} @emph{after} 
1870 the window manager is reasonably initialized. To help you do this, you have at
1871 your disposal a @command{-w progname} switch in the shell frontend.
1873 @subheading What about enlightenment?
1874 adesklets works as expected with e16 as long as you do not enable features causing 
1875 the use of fake root windows (see previous question), hiding in some circumstances
1876 the desklets behind the Window Manager structure. In the author experimentation 
1877 with version 0.16.7.2, it is only possible to see the desklets in the first 
1878 virtual desktop. This said, in enlightenment lingo, virtual desktops can span 
1879 on many ``screens'' (four, horizontally aligned by default), making perfectly 
1880 possible multiple workspaces usage while keeping adesklets' desklets in sight.
1882 As for e17, it is unsupported. If you insist, you can find more hints on this in 
1883 @weblink2{enlightenment FAQ, http://www.get-e.org/Main/FAQs/#48}. This said, 
1884 e17 comes with something called ``e17 modules'' (engage, etc.), that work 
1885 great under this WM and fill the same niche.
1887 @subheading Now I see the desklets, but the transparency is screwed!
1889 Proper pseudo-transparency relies on the capacity to grab the background image 
1890 as well as getting notified when it changes. There is no entirely reliable 
1891 or even well established method to do this on anything but the real
1892 root window using the core X11 protocol (please read from the beginning of this 
1893 ``Displaying desklets'' section to full understand what follows). 
1895 Hence, even when using a fake root window, adesklets always grabs 
1896 the background from the real root window, no matter what: some windows managers
1897 are careful enough to ensure the synchronisation of the fake root window and 
1898 the real root window at all time, but not too many. adesklets does its best, 
1899 when portably possible, to synchronize @emph{on initial load} the background 
1900 of the real root window with the one of the fake root window, but in some 
1901 supported cases (ROX-Filer, xffm-desktop), this is not even possible. 
1902 Therefore, if you experience screwed-up backgrounds (no background at all, 
1903 incorrect backgroud or background not reflecting the latest change you made, 
1904 while you effectively see the new wallpaper in a fake root window), all you 
1905 need to do is to duplicate the wallpaper set on the real root window, preferably 
1906 using a wallpaper setter supporting the ad-hoc, widely supported
1907 @weblink2{enlightenment mechanism,http://gershwin.ens.fr/vdaniel/Doc-Locale/Outils-Gnu-Linux/Eterm-0.9/#trans} for wallpaper change notification -- any of 
1908 @command{Esetroot}, @command{wmsetbg}, @command{feh}, @command{hsetroot}, 
1909 @command{chbg} or @command{xsri} 
1910 should work fine. In fact, you can even use any wallpaper setter 
1911 to change the real root, but then you could have to rerun the adesklets 
1912 launcher afterwards to take advantage of a correct initial background grab 
1913 if no notification was sent.
1915 @subheading I cannot see smaller desklets such as xmms_bar or asimpleclock, while others work. What gives?
1917 New desklets are always started in the leftmost, upper corner of the screen, at
1918 the very bottom of the windows stack. Make sure you do not have some elements 
1919 (gnomebar, engage, etc) already masking this zone of the screen. Beware! Some 
1920 applications use pseudo-transparency, and can mask the root window seamlessly.
1922 @subheading 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!
1924 Go see the Fvwm faq: @weblink{http://www.fvwm.org/documentation/faq/#5.11}.
1925 This @code{BugOpts RaiseOverUnmanaged on} option was reported to work for many 
1926 Fvwm users.
1928 @subheading I am so tired of hitting the desklets context menu when all I want is my windows manager's! Can I do something about it?
1930 Invoke the @command{--enable-control-on-context-menu} switch at configuration 
1931 time. This way, normal left click on a desklet should trigger your windows manager
1932 menu in most cases (tested on Xfce4 and *box derivatives). In all cases, you will 
1933 need to press control at the same time to trigger the desklet context menu.
1935 @section Running desklets
1936 @subheading The 'Configure' item from the context menu of many desklets doesn't work!
1937 For this to work--at least for all the demo desklets--you need to have
1938 @command{xterm} installed, and the @code{EDITOR} variable properly set in 
1939 your environment, as it is customary in UNIX. Please note this only launches a 
1940 text editor in a terminal. Editing the desklet's configuration file
1941 (usually @file{config.txt} from base desklet directory) has the same effect.
1943 @subheading Can the 'Configure' item from the context menu invoke a non console-based editor?
1945 Yes, why not? Since adesklets 0.5.0, there is a facilitating wrapper to 
1946 automate this in the shell frontend: see the @command{adesklets -e} (editor)
1947 switch.
1949 @subheading Do you plan including SVG support? I would like to use a SVG image in one of my desklets.
1950 No we do not, sorry. It is not
1951 that @weblink2{SVG,http://www.w3.org/Graphics/SVG/} is a bad format; in fact 
1952 it is quite good. But it is also a vector-oriented one (and rather complex), 
1953 while Imlib2, on which @command{adesklets} relies heavily, is completely 
1954 raster-oriented, and using Imlib2 is the main reason for @command{adesklets}'
1955 simplicity, relatively good speed and low resource usage. 
1957 That said, there is no reason for you not using SVG's with desklets, since 
1958 it is quite easy to convert images in SVG to high quality PNG's, 
1959 using programs such as @weblink2{sodipodi,http://www.sodipodi.com/}, 
1960 @weblink2{inkscape,http://www.inkscape.org/} or @weblink2{xsvg,http://xsvg.org/}. 
1961 In a directory full of SVG's, on a GNU system you can use a command such as:
1962 @example
1963 ls *.svg | sed 's/\(.*\).svg/-z --file=& --export-png=\1.png --export-width=128 --export-height=128/' | xargs --max-lines=1 sodipodi
1964 @end example
1965 to convert them all to 128x128 semi-transparent PNG's.
1967 @subheading 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?
1969 First, you need to have fontconfig support enabled in adesklets. See the
1970 config.log from the configuration phase to verify it. If you did not keep the
1971 log, you can also look at the dynamic libraries linked against the interpreter.
1972 On a system with GNU binutils, you can do something like:
1973 @example
1974 ldd `which adesklets` | grep fontconfig
1975 @end example
1976 If you get output similar to:
1977 @example
1978  libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x45c75000)
1979 @end example
1980 it means everything is fine. Otherwise, you should recompile 
1981 @command{adesklets} from source. From there, you can use the line:
1982 @example
1983 echo 'list_font_path' | adesklets :
1984 @end example
1985 to see all the font directories that adesklets will into look for TrueType
1986 fonts.  Consult your fontconfig documentation to learn how to change this
1987 (on up-to-date systems, @code{man 5 fonts-conf} is a good starting point).
1988 Similarily:
1989 @example
1990 echo 'list_fonts' | adesklets :
1991 @end example
1992 Will give you all the fonts that are currently found... Keep in mind when
1993 typing them that font names are case-sensitive.
1995 Alternatively, if you just cannot get fontconfig to work, a way to get around
1996 the problem would be to create symbolic links to the fonts you want to use
1997 inside any absolute font paths listed by the command
1998 @code{echo 'list_font_path' ...} above.
1999 @ifhtml
2000 @node Python package documentation
2001 @appendix Python package documentation
2003 Here are links to significant sections of the Python package documentation:
2005 @itemize
2006 @item @weblink2{adesklets,../pydoc/adesklets.html}
2007 @item @weblink2{adesklets.events_handler,../pydoc/adesklets.events_handler.html}
2008 @item @weblink2{adesklets.commands,../pydoc/adesklets.commands.html}
2009 @item @weblink2{adesklets.utils,../pydoc/adesklets.utils.html}
2010 @item @weblink2{adesklets.configfile,../pydoc/adesklets.configfile.html}
2011 @end itemize
2013 @end ifhtml
2015 @node Imlib2 documentation
2016 @appendix Imlib2 documentation
2018 Carsten Haitzler (@email{raster@@rasterman.com}) took the time to produce very
2019 nice cross-referenced documentation for Imlib2, but for some reason (size
2020 considerations most probably), it is not included in the Imlib2 source
2021 tarball@footnote{Although it can be quite easily regenerated using doxygen.}.
2022 You can
2023 @ifhtml
2024 have it @weblink2{here,../imlib2}.
2025 @end ifhtml
2027 @ifnothtml
2028 find it online at @weblink{http://adesklets.sf.net/doc/imlib2/}.
2029 @end ifnothtml
2031 Most functions of the Imlib2 API have corresponding, homonymic commands
2032 in @command{adesklets}. @xref{Programming adesklets}, for specific details
2033 on the transition from direct Imlib2 programming in C to adesklets.
2035 @node Packaging GNU Makefile for desklets
2036 @appendix Packaging GNU Makefile for desklets
2038 Here is a convenient Makefile that automates the packaging of new or 
2039 existing desklets on a GNU system. Just copy the Makefile below 
2040 into @file{GNUmakefile} from your base desklet directory to use it. 
2041 There is nothing at all to edit, provided you named your base directory
2042 in a proper 'NAME-MAJOR.MINOR.REVISION' fashion, such as @code{beast-0.666.0}.
2044 @verbatiminclude ../utils/GNUmakefile.desklet
2046 @node Submitting a desklet
2048 @appendix Submitting a desklet
2050 @section Desklet package requirements
2051 Requirements for ``official'' desklets packages are scarce; authors are free to
2052 do as they wish. There are only two things that should be enforced:
2053 @enumerate
2054 @item A meaningful @file{README} file should exist in the base source directory 
2055 of the desklet archive and be kept up to date. It should at least contain:
2056 @itemize
2057 @item the name and contact email adress of the author@footnote{It is probably 
2058 not a good idea to give away your private email adress here; 
2059 for spam-related reasons, you should probably open an account 
2060 on @weblink2{SourceForge,http://sourceforge.net/}, or at another similar place 
2061 with a serious spam containment infrastructure.}
2062 @item a short description of the desklet
2063 @item the requirements for running it
2064 @item how to run it
2065 @end itemize
2066 @item The package should be a bzip'ed tarball containing a single source
2067 directory of the form @code{NAME-MAJOR.MINOR.REVISION}, where @code{NAME} is 
2068 the desklet base name, and @code{MAJOR.MINOR.REVISION} the version. Please note
2069 that a makefile (@xref{Packaging GNU Makefile for desklets}.) is also provided
2070 to automate creation of such an archive on GNU systems.
2071 @end enumerate
2073 @section The @command{adesklets_submit} script
2075 Starting in @command{adesklets} 0.4.4, desklet authors are provided with a 
2076 Python script to automate the submission of their desklets: 
2077 @file{utils/adesklets_submit} from the source package. Use the 
2078 @code{--with-python-install-submission-scripts} option at configuration time
2079 to place it in your @code{bindir} directory upon installation.
2081 @file{adesklets_submit} can be used to:
2082 @itemize
2083 @item Submit a new or updated desklet description for inclusion on the
2084 @weblink2{adesklets web site,http://adesklets.sf.net/desklets.html};
2085 @item Submit a bzip'ed desklet archive for inclusion in SourceForge's desklets
2086 package (this is optional--you may choose to host it yourself).
2087 @end itemize
2089 @section Invoking @command{adesklets_submit}
2090 Desklet submission is initiated by sending a specially crafted email to 
2091 @email{adesklets@@mailworks.org}@footnote{It is useless to send anything else 
2092 to this address; all messages that cannot be parsed by the automatic reception
2093 script are just silently dropped. Write to @email{syfou@@users.sourceforge.net}
2094 instead if you want to get in touch with the maintainer.}.
2095 The @command{adesklets_submit} script assits you in the construction of
2096 such an email using the user configuration file @file{$HOME/.adesklets_submit}
2097 and the command line switches. Here is an example of a valid
2098 @file{$HOME/.adesklets_submit} configuration:
2100 @verbatiminclude ../utils/adesklets_submit.example
2102 This is pretty self-explanatory, but here are a few less obvious points:
2104 @itemize
2105 @item
2106 Try to avoid using pseudonyms and nicknames for the @code{author_name} as much
2107 as possible, unless, of course, you already have a pretty well-established
2108 online identity under this name.
2109 @item
2110 @code{send_confirmation} specifies if an email should be sent back to your 
2111 @code{author_email} address whenever your desklet is succesfully published. 
2112 If the submitted entry is rejected, you will always be written back anyway
2113 with an explanation. Usually, the maintainer will not try to make changes to
2114 problematic entries; it will only summarize back to the author what was not OK.
2115 @item
2116 @emph{Double check} your @code{author_email} address, since this is the only
2117 one the maintainer will try to use when contacting you, regardless of what 
2118 the headers say. Failing to supply a valid address will cause all messages to
2119 fail to be sent to you, and all new desklet entries will be rejected.
2120 @item
2121 You can very well use adesklets_submit without any prior contact with the adesklets
2122 maintainer (either via email, within the forum using this adress for
2123 registration, or through the mailing list), but some back and forth will be
2124 needed before publication just to assert your identity and its effective
2125 relation to the provided email address.
2126 @item
2127 @code{desklets} is a dictionary of dictionaries (one dictionary per desklet, 
2128 desklets' names being the keys); all the items referring to files (thumbnail,
2129 screenshot and download) could either be publicly accessible URI's (this is the
2130 preferred method), or local files, either absolute or relative to your $HOME
2131 directory. In that case, needed files will be attached to the generated
2132 multipart email.
2133 @item
2134 All images will always be fetched and integrated on the adesklets.sf.net
2135 web site; you can safely remove them from your online location afterwards 
2136 if you provided live URI's.
2137 @item
2138 When updating already included desklets, there is no need to submit back
2139 the @code{thumbnail} or @code{screenshot} images if they did not change;
2140 you can just as easily reference the already installed images on SourceForge:
2141 @itemize
2142 @item The @code{thumbnail} is always stored under 
2143 @code{http://adesklets.sf.net/images/NAME_thumb.[jpg|png]}
2144 @item The @code{screenshot} is always stored under 
2145 @code{http://adesklets.sf.net/images/NAME_screen.[jpg|png]}
2146 where @code{NAME} is the name of the desklet.
2147 @end itemize
2148 @item
2149 Using the @code{host_on_sourceforge} value, you can choose to have 
2150 your desklet package either hosted on SourceForge or just referenced 
2151 on your site if you provided a URI. Of course, choosing this last 
2152 alternative also means you will need to keep it in place.
2153 @item
2154 The @code{thumbnail} image should be a JPG (preferably) or PNG (if you 
2155 @emph{really} need higher resolutions) of dimensions lying between 190x35 and 
2156 230x110 pixels.
2157 @item
2158 The @code{screenshot} image should be a 640x480 JPG (preferably) or PNG.
2159 It should put your desklet in evidence, and thus contain no other ones.  
2160 @item
2161 You can choose not to submit thumbnails and/or screenshots. In that case,
2162 default, generic images will be used instead.
2163 @item
2164 @code{Category} is unused for now, and just ignored.
2165 @item
2166 All emails weighing more than 300 KB will be rejected by the maintainer's
2167 email server; thus, adesklets_submit will refuse to generate them. Instead of
2168 submitting such big entries, use the URI facility described above to trim
2169 them down.
2170 @item @command{adesklets_submit} does not enforce the requirements above; it only
2171 checks what is strictly required to build a compliant submission email:
2172 the existence of dictionary entries, availability of files, the validity 
2173 of file types if they are local... It is your duty to make sure the entries
2174 meet the other requirements if you want to avoid rejection.
2175 @end itemize
2177 For example, Belial Leviathan would fisrt check his @code{beast} desklet's
2178 entry by doing something similar to:
2179 @example
2180 adesklets_submit beast
2181 @end example
2183 If everything goes fine, it will output the resulting submission email 
2184 on @code{stdout}. From there, Belial can either:
2185 @itemize
2186 @item Pipe it to his favorite MTA (mail transfert agent) to send it to
2187 @email{adesklets@@mailworks.org}.
2188 @item Make @command{adesklets_submit} send it itself by SMTP, using the
2189 @code{smtp_host} and @code{smtp_port} parameters in its 
2190 @file{$HOME/.adesklets_submit}. For this, Belial would use:
2191 @end itemize
2192 @example
2193 adesklets_submit --send beast
2194 @end example
2196 One last thing: you should try to avoid sending minor corrections multiple
2197 times, especially if you use local files.  It both adds to the workload of the
2198 maintainer's email server and to the management work. Please try to create a
2199 valid entry @emph{then} send it, not the other way around.
2201 @appendixsubsec Further submission validation using @command{adesklets_checkin}
2202 From @command{adesklets} 0.4.5, you now have access to the 
2203 @command{adesklets_checkin} script as well. This is the Python 
2204 script that the maintainer uses for checking in all submissions.
2205 @emph{Be aware that this script is only provided to desklet authors as a
2206 convenience, to lower their submission rejection count--developers are in no
2207 way forced to use it, and may even be unable to do so, since the script was not
2208 written with portability in mind as adesklets_submit was. Look at the script 
2209 header for a complete list of requirements.}
2211 @command{adesklets_checkin} has two modes of operation: interactive and 
2212 non-interactive. Only the non-interactive mode will interest desklet authors.
2213 In this mode, usage is fairly simple. Belial, for instance, would do:
2214 @example
2215 adesklets_submit beast | adesklets_checkin
2216 @end example
2218 If everything goes fine, an output similar to this will be produced:
2219 @example
2220 Validation started. Please wait.
2221 Everything seems fine, but keep in mind a few things cannot be
2222 verified without human intervention. See documentation for details.
2223 @end example
2225 If not, you will get an exception trace with some (hopefully) meaningful 
2226 explanations. 
2228 @appendixsubsec Limitations of @command{adesklets_checkin} in non-interactive mode
2230 Here are the remaining problems that @command{adesklets_checkin} 
2231 cannot detect and thus must absolutely be solved manually
2232 (the maintainer would interactively catch most of them, and you would have to
2233 resubmit anyway):
2234 @itemize
2235 @item
2236 Incomplete README file in base directory (Does it contain all the details
2237 enumerated above?).
2238 @item
2239 Out-of-date README file (Does its content reflect the current state
2240 of the desklet?).
2241 @item
2242 Desklet fails to run out-of-the-box (i.e. with or without minimal
2243 configuration) when requirements in the README file are met and special
2244 instructions are followed.
2245 @end itemize
2247 @node Copying This Manual
2248 @appendix Copying This Manual
2250 @menu
2251 * GNU General Public License::  License for copying this manual.
2252 @end menu
2254 @include gpl.texi
2256 @node Open PGP Public Key
2257 @appendix Open PGP Public Key
2259 @verbatiminclude syfou.asc
2261 @noindent You can also get this certificate from many public key servers on 
2262 the internet, such as @weblink{http://www.keyserver.net/}, or
2263 @weblink{http://pgp.mit.edu/}. Contact its rightful owner,
2264 Sylvain Fourmanoit, by email at @email{syfou@@users.sourceforge.net} 
2265 to arrange further key validation if you need any.
2267 @bye