Adapt the autoconf machinery to OpenBSD 3.8
[adesklets.git] / doc / adesklets_en.texi
blob039af876d815ea43e639e51f22a9a6c234671b4f
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: @emph{it is 
389 required to have it for all the desklets using interactive mode of execution}
390 @item
391 iconv library and headers (such
392 as @weblink2{libiconv,http://www.gnu.org/software/libiconv/}), for 
393 internationalization support (dynamic support of extended character sets)
394 @item
395 @weblink2{Python,http://www.python.org} 2.3 and up, if you want Python support
396 (you most probably do -- desklets are written in this language)
397 @end itemize
399 Many systems routinely package ``development'' versions of libraries and 
400 tools separately (@command{imlib2-devel}, @command{readline-devel}, 
401 @command{fontconfig-devel}, @command{python-devel}, etc); if this is the case for
402 the target system, those have to be chosen over the ``regular'' versions.
404 @section Runtime requirements
406 In addition to the compilation requirements, the optional adesklets 
407 shell frontend, installed by default, will itself 
408 need a few utilities, all expected to minimally comply with POSIX 1003.2 and 
409 1003.2a specifications:
411 @itemize
412 @item a sh-compatible @command{/bin/sh} shell
413 @item a Streaming EDitor (sed)
414 @item test, mkdir, rmdir, sleep, kill and ls
415 @end itemize
417 The @command{xwininfo} and @command{xprop} programs can also be used 
418 by this frontend, if a given fake-root window detection routine 
419 is explicitely invoked. Both XFree86 and X.org implementations 
420 of these utilities have been tested. Other programs will eventually be used
421 by specific detection routine: see the frontend source for details.
423 @section Portability Notice
424 @anchor{Portability}
425 This package was built with portability in mind: all vendor-specific
426 extensions were avoided, and specs (ANSI, SVID 3, BSD 4.3, POSIX) were followed
427 in a conservative way. Nevertheless, original development took place on a single
428 Linux system; it is quite probable that adesklets will not compile or work as 
429 expected in some cases. Fixing portability issues is an important concern for us.
431 adesklets has been ported and successfully tested by the developers on many
432 systems. As of version @value{VERSION}, it has been verified to compile and run
433 out of the box on a variety of
435 @itemize 
436 @item @strong{Kernels/Systems}: Linux (2.2, 2.4, 2.6 series), FreeBSD
437       (4.10, 5, 6 and 7), NetBSD (1.6), OpenBSD (3.8)
438 @item @strong{C Libraries} (when applicable): glibc (2.1.3 and up), uclibc (0.9.28)
439 @item @strong{Compilers}: gcc (2.95.2, whole 3 serie, 4.0.2), 
440       icc 7.0 (with tweaking)
441 @end itemize
443 Moreover, adesklets itself is fully architecture independent, although 
444 Imlib2 is further optimized for the x86 and amd64. It is routinely used on 
445 x86, amd64 and ppc machines by the author.
447 At the time of writing, adesklets is already integrated in ports collections of
448 many BSD and software libraries of linux distributions. For reference, let's 
449 mention:
451 @itemize
452 @item Debian package: @weblink{http://packages.debian.org/unstable/x11/adesklets},
453 maintained by Bartosz Fenski @email{fenio@@debian.org}.
454 @item FreeBSD port: @weblink{http://www.freshports.org/deskutils/adesklets/},
455 maintained by Roman Bogorodskiy @email{novel@@freebsd.org}.
456 @end itemize
458 Did you try to run the package on something not listed here?
459 Let us know, especially if it did not work.
461 @section Software download
463 The current version of the software (as a source bzip'ed tarball) can be found
464 on the SourceForge project page: @weblink{http://sf.net/projects/adesklets/}
466 You can extract it from the console with @command{tar}. As of version
467 @value{VERSION}, the command line would be:
469 @example
470 tar xvjf adesklets-@value{VERSION}.tar.bz2
471 @end example
473 or, if your installed version of @command{tar} does not support
474 filtering archives through bzip2:
476 @example
477 bzcat adesklets-@value{VERSION}.tar.bz2 | tar xv
478 @end example
480 @section Verifying Software Integrity (optional)
482 As of adesklets @value{VERSION},  you can also
483 download from @weblink2{SourceForge,http://sf.net/projects/adesklets/} an 
484 ascii-armored detached signature named 
485 @command{adesklets-@value{VERSION}.tar.bz2.asc}, that you can match
486 against the author's Open PGP public key (@pxref{Open PGP Public Key},
487 in appendix) to assert the package integrity. For instance, with
488 @command{GnuPG} (@weblink{http://www.gnupg.org/}), you would use:
490 @example
491 gpg --verify adesklets-@value{VERSION}.tar.bz2.asc adesklets-@value{VERSION}.tar.bz2
492 @end example
494 You can also get the public key for @email{syfou@@users.sourceforge.net}
495 from various public key servers such as @weblink{http://www.keyserver.net/} or
496 @weblink{http://pgp.mit.edu/}. Feel free to contact the author directly if you
497 want to authenticate the key further.
499 @section Compilation and Installation:
501 adesklets provides the usual autoconf/automake scripts of GNU packages.
503 Therefore, in most cases, installation follows the normal three steps:
505 @enumerate
506 @item
507 `cd' to the directory containing the package's source code and type
508 `./configure' to configure the package for your system.  If you're
509 using `csh' on an old version of System V, you might need to type
510 `sh ./configure' instead to prevent `csh' from trying to execute
511 `configure' itself.
513 Running `configure' takes awhile.  While running, it prints some
514 messages describing which features it is checking for.
515 @item
516 Type `make' to compile the package.
517 @item
518 Type `make install' to install the programs and any data files and
519 documentation.
520 @end enumerate
522 You can remove the program binaries and object files from the
523 source code directory by typing `make clean'.  To also remove the
524 files that `configure' created (so you can compile the package for
525 a different kind of computer), type `make distclean'.
527 @section Compilers and Options:
529 Some systems require unusual options for compilation or linking that
530 the `configure' script does not know about.  You can give `configure'
531 initial values for variables by setting them in the environment.  Using
532 a Bourne-compatible shell, you can do that on the command line like
533 this:
535 @example
536 CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
537 @end example
539 @noindent Or on systems that have the `env' program, you can do it like this:
541 @example
542 env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
543 @end example
545 @section Optional Features:
547 adesklets comes with a few optional features you can select or not
548 from the `configure' script. Type:
550 @example
551 ./configure --help
552 @end example
554 @noindent for a complete, short description. Here are a few interesting ones:
556 @itemize
557 @item
558 You may choose to compile adesklets without X support at all
559 (@command{--without-x}).
560 You will get a version that is obviously not suited for
561 desklets rendering, but still good for command line image manipulation
562 @item
563 You can remove support for some others packages as well:
564 @command{--without-history}, @command{--without-fontconfig}
565 @item
566 The shell frontend can be avoided altogether using:
567 @command{--disable-frontend-shell-driver}
568 @end itemize
571 @node Using adesklets
574 @chapter Using adesklets
576 @ifplaintext 
577 INSTALL_END
578 @end ifplaintext
580 @section ... As a desklets container
582 By itself, adesklets does little: it only provides what is needed to
583 do more! You either need to tell it what to do by passing it commands
584 (see the next section) or you need other scripts (the desklets)
585 that will drive it for you.
587 @noindent Right now, many desklets exist: 
588 you may find them on adesklets web page as separate downloads:
589 @weblink{http://adesklets.sf.net/desklets.html}.
591 @subsection Add a new desklet to your X display
592 To add a new desklet script, simply:
594 @enumerate
595 @item
596 Download its tarball and unpack it somewhere in your home directory.
597 @item
598 Look at the included README file; special requirements or instructions
599 will be given. Usually, all you have to do is to get adesklets installed,
600 your X server running, then launch the executable script file from the
601 base directory.
602 @end enumerate
604 From adesklets 0.4.11, Python-based desklets will ask you explicitely if you want
605 to register or to test them. They will also support a @command{--help} switch,
606 that you can use to know the useful options you can pass to the adesklets 
607 interpreter when testing (fake root window detection, etc.).
609 @noindent Please note that:
611 @itemize
612 @item
613 Launching the same desklet script more than once will start multiple instances 
614 of it.
615 @item
616 On multi-head displays, scripts will be launched on their inherited default 
617 screen.  (For instance, if you do nothing special, calling a script from an
618 xterm on screen 1 will launch the desklet on screen 1).
619 @end itemize
621 @noindent Most of the time, desklets scripts are made to run as long as you
622 do not tell them to quit. The user has total control of starting, stopping,
623 restarting (when possible), and positionning the desklet (using the context menu, 
624 always available by right-clicking on the desklet). The desklet has 
625 no control over those operations.
627 @noindent Those few user settings are stored in the @file{$HOME/.adesklets}
628 file. Usually, you do not want to edit this file yourself.
629 If you do, make sure no instances of @command{adesklets} are running at
630 the same time.
632 @unnumberedsubsubsec Alternative to manually downloading the desklets
634 Since adesklets 0.5.0, you have a new @command{adesklets_installer}
635 script available if you installed the package with Python support: it provides
636 you with automated management of your desklets under @file{$HOME/.desklets} 
637 through a simple interactive interface. From a real or pseudo-terminal, 
638 invoke:
640 @example
641 adesklets_installer
642 @end example
644 Or, if you have the adesklets shell frontend:
646 @example
647 adesklets -i
648 @end example
650 It is able to detect what desklets you have, and to download, check integrity and
651 unpack new ones based on the information contained in 
652 the official desklets atom feed (@weblink{http://adesklets.sf.net/desklets.atom}).
653 Of course, it is still your duty to manually configure and launch them from there.
655 The @command{adesklets_installer} script comes with three user interfaces:
656 a Tk interface (the default, based on the Tkinter module), a curses interface as
657 well as a raw interface, that just assumes a trivial terminal is present 
658 (characters-based @file{stdin} and @file{stdout} streams). By default, the script
659 will try to present to the user the first it can in the given order, then fallback
660 to the next if it doesn't work @footnote{The raw interface should always work at the end of the day.},
661 but you can select one as well from the command line. See:
663 @example
664 adesklets_installer --help
665 @end example
667 for the invocation details.
669 @unnumberedsubsubsec Special notes on system fonts
671 @emph{You may safely skip this section if you do not intend to use
672 non-supplied fonts with adesklets.}
674 Provided your system supports fontconfig (@weblink{http://www.fontconfig.org/})
675 and adesklets was compiled without using @code{--without-fontconfig} (compiling
676 with fontconfig support is the default; @xref{Installing adesklets}.), all the
677 TrueType fonts present in your system are available for use with adesklets.
678 At initialization time, adesklets with fontconfig support compiled in will go
679 through all the fonts detected on your system to identify all the TrueType 
680 fonts. See your fontconfig documentation on how to set up your application
681 fonts access properly (@xref{Frequently asked questions}, for some fontconfig
682 debugging hints). It's also good to know that adesklets' package includes a
683 copy of Bitstream's Vera font; all users can rely on @command{adesklets} 
684 having at least this font available at all time.
686 @unnumberedsubsubsec Special notes on internationalization
688 @emph{You may safely skip this section if you do not intend to use
689 extended charaters within your desklets.}
691 If your system includes @command{iconv} support (@xref{Installing adesklets}.),
692 you should be able to use any character from any charsets your system 
693 knows about for displaying text, either inside a desklet or in its menus,
694 provided you have appropriate TrueType fonts (i.e. TrueType fonts containing
695 those character representations)@footnote{For instance, Bitstream's Vera font 
696 included with @command{adesklets} contains glyphs for practically all Latin-1
697 (ISO-8859-1) characters.}. 
699 Nevertheless, when using extended (outside 7-bit @code{ASCII}) characters, 
700 you need to make sure your local GNU readline settings do not interfere. These
701 three parameters should be set as indicated below in the appropriate 
702 @file{initrc} file@footnote{Please refer to your GNU readline documentation}:
704 @example
705 set input-meta on
706 set convert-meta off
707 output-meta on
708 @end example
710 If you do not want to adapt your GNU readline settings, you can also pass the
711 @code{--enable-force-extended-characters-input} switch to the @code{configure}
712 script when configuring the package from source, which will cause those three
713 variables to always be appropriately overriden internally by the interpreter.
715 Of course, you will also need desklets built to use those extended characters.
716 At the time of writing, all non-contributed Python desklets support them; for 
717 those, the charset can be set by the user in the configuration file, when it 
718 exists@footnote{When it does not exist, it means the desklet does not need 
719 internationalization anyway}; users merely have to set the 'coding' line 
720 appropriately@footnote{See @weblink{http://python.fyxm.net/peps/pep-0263.html}
721 if you need details.}.
723 For instance, for using ISO Latin-1 characters, one should use something 
724 similar to:
726 @example
727 # -*- coding: ISO-8859-1 -*-
728 @end example
730 as the first or second line in the Python desklet configuration file@footnote{
731 Obviously, such a configuration file needs to be saved using ISO Latin-1 
732 encoding or any subset of it, such as @code{ASCII}.}. 
734 Finally, please note that if your platform does not support iconv,
735 you should always leave the coding parameter to @code{ASCII}, otherwise
736 you will get fatal errors such as @code{charset conversion not compiled in}
737 from the desklets.
739 @subsection Restore previously running desklets on new X session
740 Invoking @command{adesklets} without any arguments@footnote{A word of warning: 
741 by default on adesklets 0.4.11 and up, you @emph{need} to employ some flags if 
742 your Window Manager uses a fake root window. @xref{Frequently asked questions}.}:
744 @example
745 adesklets
746 @end example
748 @noindent is enough to restart all desklets that were running the
749 last time you killed the X server (in this mode, @command{adesklets}
750 will exit quickly by itself: there is no need to run it in the
751 background. adesklets does not use a daemon; each applet will fork a 
752 standalone @command{adesklets} interpreter as a child process). 
753 Invoking @command{adesklets} when desklets are already running
754 will cause them to be killed before the creation of new 
755 instances@footnote{Both @command{adesklets} process and their immediate parents
756 will be sent a @command{SIGKILL} signal.}.
758 @noindent If you plan on using desklets on a regular basis, you should put
759 the previous @code{adesklets} command somewhere in your X session
760 initialization.  I cannot tell you where with precision, as it varies greatly
761 from system to system. Have a look at: 
762 @weblink{http://www.google.ca/search?q=''x window''+startup} for general help.
764 Since adesklets 0.4.11, a more complete shell based frontend is available
765 to you, if you installed it (which is the default). It gives you a more
766 feature-complete set of options. Run
768 @example
769 adesklets --help
770 @end example
772 To see what is at your fingertips. Please note that since adesklets 0.4.11, you 
773 usually @strong{must} specify on the command line proper flags if you need 
774 fake root window detection (@xref{Frequently asked questions}.).
776 @section ... As a command-line graphic editor
778 You can also use adesklets as a command-oriented graphic editor.
779 If you type, in a console:
781 @example
782 adesklets :
783 @end example
785 @noindent You will get something similar to:
787 @anchor{prompt}
788 @example
789 adesklets 0.1.0 (Fri Jan 28 19:09:13 EST 2005), on Linux 2.6.10
790 [gcc 3.4.3 20041125 (Gentoo Linux 3.4.3-r1, ssp-3.4.3-0, pie-8.7.7)]
791 Press TAB for hints.
792 0 >>> _
793 @end example
795 @noindent The last line is a prompt. It tells you you are ready
796 to enter command number 0. As of adesklets @value{VERSION}, you have around
797 150 commands at your fingertips. Thanks to GNU readline, a lot of
798 autocompletion hooks are present, giving you an easy way to look around. 
799 Press TAB while typing a  command name or a command's first argument, and 
800 useful information will be displayed. @xref{primer,,an adesklets's primer}, 
801 for more info.
803 @node Programming adesklets
804 @chapter Programming adesklets
805 @section An adesklets' primer
806 @anchor{primer}
808 As previously stated (@xref{About adesklets}.), adesklets is basically an
809 interactive Imlib2 console, with one or two aditionnal features:
811 @itemize
812 @item
813 When an X display is present, automated management of a single window
814 @item
815 Automated support for pseudo-transparency
816 @item
817 Management of long-running applets
818 @end itemize
820 @noindent So let's start a typical interactive session to see what
821 happens. Under X, open a terminal, and type:
823 @example
824 adesklets :
825 @end example
827 @noindent As in last section (@xref{prompt,,'Using adesklets as a command-line
828 graphic editor'}.),
829 you will get a prompt. Now, enter the command '@code{images_info}'. You should
830 get on stdout:
832 @example
833 2 images
834 id 0 width 1 height 1 alpha 1 filename (null)
835 id 1 width 1 height 1 alpha 1 filename (null)
836 command 0 ok: images_info
837 @end example
839 @noindent This tells you that you have two images: image 0 and image 1, each
840 1x1 pixels. Those are the only images you can never destroy nor do any
841 operations you want with (resize them independently, flip them diagonaly, etc.)
842 Why is that?
844 @itemize
845 @item
846 Image 0 is the foreground image. By default, it is the only image that is
847 displayed on the single window that @command{adesklets} manages.
848 @item
849 Image 1 is the background image. By default, it always contains the content
850 of the root window (the desktop) directly below the window.  Unless we set it
851 to be otherwise, it is always updated when the user moves it, when you resize
852 it, when your wallpaper changes, etc.
853 @end itemize
855 @noindent But where is this window? Well, right know, it is only 1x1 pixels,
856 and it is not shown@footnote{``Mapped'' in X Window lingo} on the screen.
857 So let's resize it to 100x100 pixels: type '@code{window_resize 100 100}'.
858 Now, if you re-enter the command '@code{images_info}', you will get:
860 @example
861 2 images
862 id 0 width 100 height 100 alpha 1 filename (null)
863 id 1 width 100 height 100 alpha 1 filename (null)
864 command 2 ok: images_info
865 @end example
867 @noindent The foreground and background images have been resized to
868 100x100 pixels.  Moreover, the background image has been updated to contain
869 a new image of the background. Now, let's make this window visible. Type two 
870 commands: '@code{window_reset managed}' and then '@code{window_show}'.
872 @noindent The first command tell adesklets to let your window manager
873 ``manage'' your window (the default is not to); it means the window gets
874 decorated, and you can interactively change its visibility@footnote{An
875 ``unmanaged'' window is very useful for scripted desklets: it looks like
876 it is part of the root window as it can be made to never go on top, and to stay
877 mapped when workspaces are switched.}. The second command shows our 100x100 
878 window. So far, it's nothing too impressive--just a black 100x100 square with a
879 titlebar and fixed-size borders.
881 @noindent As mentioned above, only image 0 (the foreground) is displayed by
882 default. Now, type: '@code{window_set_transparency 1}'. Wow! We see the
883 root window below! With ``window transparency'' on, the image 1 (background)
884 is first copied onto the window, then image 0 (foreground) which is purely
885 transparent black, is blended onto it@footnote{Well...Not quite. Actually,
886 there is a buffer involved for performance, but the operation is logically
887 equivalent to this description.}.
889 @noindent It is time to say a word about colors. Remember, adesklets is an 
890 Imlib2 console. Thus, as with Imlib2@footnote{Keep your Imlib2 documentation 
891 nearby; it is very handy! @xref{Imlib2 documentation}.}, colors are 
892 always true 32 colors, RGBA encoded, with eight bits (0 to 255) per channel,
893 including an alpha channel for transparency. Palette conversion and such will 
894 automatically take place if your screen depth is less than that, so you do not
895 need to bother with that. If you type: '@code{context_get_color}', you will get:
897 @example
898 command 0 ok: context color 255 255 255 255
899 @end example
901 @noindent Imlib2 is a kind of state machine; as such, it comes with a
902 ``context'' that remembers a series of attributes it will use in its future 
903 operations. For instance, we now know the color it will use as long as we do not
904 modify it is opaque pure white (red=255, blue=255, green=255, alpha=255). 
905 If we type: '@code{context_get_image}', it returns:
907 @example
908 command 0 ok: context image 0
909 @end example
911 @noindent Which means all window operations we perform are made directly on
912 the forgeground image. So, let's draw a filled semi-transparent magenta 
913 rectangle on the foreground. Commands could be: 
914 '@code{context_set_color 255 0 0 200}' and 
915 '@code{image_fill_rectangle 25 25 50 50}'. Neat, isn't it?
917 @noindent If you are used to Imlib2 programming, you will have noticed
918 by now those last few commands look quite familiar. This is pretty normal;
919 most of Imlib2 C functions are presented as corresponding 'commands' in
920 adesklets. This way, adesklets' command '@code{image_fill_rectangle}'
921 follows the same semantic as Imlib2's '@code{imlib_image_fill_rectangle()}'
922 function, the command '@code{context_set_color}' functions just like
923 '@code{imlib_context_set_color()}', etc. The only two significant (and
924 systematic) differences are that whenever you would use an 
925 '@code{Imlib_Something}' object in C, you use an integer ID with adesklets,
926 and on the semantic of the '@code{imlib_free_something()}' functions that need
927 to be given an ID instead of freeing the context selected object of this type.
929 @noindent This is pretty easy to illustrate. Let's load the ``Vera'' font 
930 included with adesklets at a 20pt size, set it as default font, and write in 
931 pure opaque white ``Hello'' diagonally on the foreground image from the top left
932 corner before unloading the font. It would look like:
934 @example
935 6 >>> load_font Vera/20
936 command 6 ok: new font 0
937 7 >>> context_set_font 0
938 command 7 ok: context_set_font 0
939 8 >>> context_set_direction text_to_angle
940 command 8 ok: context_set_direction text_to_angle
941 9 >>> context_set_angle 45
942 command 9 ok: context_set_angle 45
943 10 >>> context_set_color 255 255 255 255
944 command 10 ok: context_set_color 255 255 255 255
945 11 >>> text_draw 0 0 Hello
946 command 11 ok: text_draw 0 0 Hello
947 12 >>> free_font 0
948 command 12 ok: free_font 0
949 @end example
951 @noindent If you look at your imlib2 documentation, you will immediatly notice
952 the two differences we just talked about:  all references to the font Vera/20
953 are made through an integer ID (0 here), and the '@code{free_font}' command, 
954 unlike the corresponding '@code{imlib_free_font()}' function, is called with
955 the font ID as an argument instead of the context font.
957 @noindent Now let's say you want to save you resulting image; not a problem!
958 Let us type: '@code{save_image out.png}', and the foreground is saved in the
959 file ``out.png'' in the current working directory@footnote{For this to work, 
960 you need to have your Imlib2 installation properly configured for using libpng,
961 or you could receive a ``no loader for file format'' error.}. Now, just for 
962 the sake of it, let us exit adesklets, and start another interactive session
963 to see if we can reload this image. Just type in the ``@code{quit}'' command or
964 press ^D (Control D: end of file). Then your new session should look 
965 something like:
967 @example
968 0 >>> window_resize 100 100
969 command 0 ok: window_resize 100 100
970 1 >>> window_reset managed
971 command 1 ok: window_reset managed
972 2 >>> window_set_transparency 1
973 command 2 ok: window_set_transparency 1
974 3 >>> load_image out.png
975 command 3 ok: new image 2
976 4 >>> blend_image_onto_image 2 1 0 0 100 100 0 0 100 100
977 command 4 ok: blend_image_onto_image 2 1 0 0 100 100 0 0 100 100
978 5 >>> window_show
979 command 5 ok: window_show
980 6 >>> free_image 2
981 command 6 ok: free_image 2
982 @end example
984 @noindent Of course, we wanted to visualize the result; this is why we
985 emitted commands '@code{window_reset}', '@code{window_set_transparency}'
986 and '@code{window_show}'; they are not otherwise useful. The command
987 '@code{blend_image_onto_image}' comes straight from Imlib2 once again;
988 it takes the newly created image 2 from the third command and blends it
989 onto the context image (image 0, foreground by default), for its coordinates
990 (0,0) to 100x100 pixels farther, and puts it on the rectangle starting at (0,0)
991 of size 100x100 pixels of image 0. It is finally good to note that, with
992 adesklets, there is always an image in Imlib2 context: whenever you try to
993 free the current image, the image context is always reset to the foreground 
994 image.
996 @noindent OK, so it is almost the end of this primer... From there you should
997 play around with adesklets.  It is pretty straightforward to use if you are 
998 already familiar with Imlib2. If you are not, your best resource is certainly 
999 having Imlib2 documentation not far away. :-)
1001 @noindent Some last tips:
1003 @itemize
1004 @item
1005 If you get tired of typing, and typing, do not forget you have autocompletion:
1006 'TAB' your problems away!
1007 @item
1008 If you want to have hints on how to do something, you have a built-in
1009 '@code{help}' command.
1010 @item
1011 If you are working out a series of commands, things are not working
1012 and all this interactive usage it getting tiresome:
1013 @enumerate
1014 @item
1015 Use the '@code{history}' command to output your current session to a
1016 file@footnote{For this to work, you need to have GNU history when
1017 building adesklets.}.
1018 @item
1019 Use the '-f' switch with adesklets to get commands from a file instead
1020 of the console tty.
1021 @item
1022 If you try to visualise something, insert a '@code{pause}' command at the
1023 end of the script to freeze the interpreter.
1024 @item
1025 All strings from a pound sign '#' to the end of a line will get discarded,
1026 allowing you to write comments.
1027 @end enumerate
1028 @end itemize
1030 @noindent Here is an example:
1032 @example
1033 #!/usr/bin/env adesklets -f
1035 # Make the window 'managed'
1037 window_reset managed
1039 # Resize the window to 100x100 pixels
1041 window_resize 100 100
1043 # Show the window, then freeze for 10 seconds before exiting
1045 window_show
1046 pause 10
1047 @end example
1049 @noindent You will just have to make this script executable and run it. As
1050 usual, output from the commands will get printed to stdout.
1052 @itemize
1053 @item You could also use the @code{play} command. This two-arguments command
1054 gives you a way to replay any sequence of commands from history, using the 
1055 command number of the first and last command as parameters.
1056 @end itemize
1058 @section Real programming with adesklets: writing desklet scripts
1060 When you are ready for real work@footnote{:-)}, you might want to use
1061 a real scripted language instead of the raw @command{adesklets} interpreter we
1062 used in the primer; you never know when just having variables could come in 
1063 handy.
1065 At the time of this writing (@value{UPDATED}), the Python package is included 
1066 @footnote{adesklets was written to be easily used from a variety of interpreted
1067 languages -- do not hesitate to propose your help if you want to bring support 
1068 for your language of choice!}.
1070 @subsection General tips for programmers
1072 A really useful feature of the @command{adesklets} interpreter 
1073 is its ability to produce a full trace of its session (commands, events and
1074 special messages), either on @code{stdeerr} or as a log file, independently
1075 of what is driving it. To have access to this feature, one must:
1077 @enumerate
1078 @item Configure the package from source, passing along the @code{--enable-debug}
1079 switch to @code{configure}.
1080 @item Export the @code{ADESKLETS_LOG} variable in the environment if 
1081 the session's output should to be stored in files instead of printed
1082 to @code{stderr}@footnote{Printing to @code{stderr} will break most bindings, 
1083 and should therefore be used mainly when invoking the interpreter directly 
1084 from the console.}. It should be an absolute filename prefix which the
1085 interpreter, inheriting from the environment, can use to create complete file
1086 names to write to.
1087 @end enumerate
1088 From there, it is possible to read complete chronological session logs;
1089 used correcly, it is very useful for debugging purposes. You can use 
1090 it in conjunction with the @code{echo} command to set easy to find log points.
1092 @subsection adesklets and Python 
1093 @unnumberedsubsubsec Python usage example
1094 From Python, things are not very different than from the interpreter.
1095 Commands have been wrapped into Python functions, and an @code{Events_handler} 
1096 class has been made public to handle asynchronous feedback from the
1097 interpreter.  Let's have a look at the @file{test/test.py} script from the
1098 source tarball of version @value{VERSION}:
1100 @verbatiminclude ../test/test.py
1102 That's it! Twenty-six lines of Python code, and we have a perfectly functionnal
1103 desklet. I think things are pretty self-explanatory; have a look at the
1104 Python online help for @code{adesklets}, @code{adesklets.commands} and 
1105 @code{adesklets.Events_handler} for a good, complete explanation
1106 @ifhtml
1107 (@xref{Python package documentation}.)
1108 @end ifhtml
1109 .  All we do here is:
1111 @enumerate
1112 @item
1113 Import the @code{adesklets} package:
1114 this automatically instantiates a child @command{adesklets} process and sets up
1115 all communications.  When the package initialization returns without raising
1116 any exception, it means the interpreter is up and ready to accept commands.
1117 @item
1118 Subclass @code{adesklets.Events_handler} and redefine the methods invoked
1119 for the events we are interested in (all other events are not just ignored,
1120 they are not generated).
1121 @item
1122 Instantiate an object of this class, and put it on hold indefinitely
1123 @footnote{This last step is not mandatory; the script may very well continue,
1124 but it should be written so that it supports signal interruptions. See
1125 @code{help(adesklets.Events_handler)} for further explanations}.
1126 @end enumerate 
1128 @unnumberedsubsubsec Gotchas: a bit more about object IDs
1130 All adesklets objects (fonts, images, color ranges, polygons, etc), are stored 
1131 in stacks (one stack per object type). Python's ID's are nothing more than the 
1132 initial position of given objects inside the relevant stack, and therefore 
1133 will become invalid if an object of the same type below them gets freed.
1135 For instance, if we start with a clean state, all we have in the stack of 
1136 images is the window's foreground (ID 0) and background (ID 1). 
1137 When someone creates two other images from Python like so: 
1138 @example
1139 im_1 = adesklets.create_image(10,10)
1140 im_2 = adesklets.create_image(10,10)
1141 @end example
1142 @noindent We get @code{im_1==2}, and @code{im_2==3}. Whenever someones does:
1143 @example
1144 adesklets.free_image(im_1) 
1145 @end example
1146 @noindent The stack starts collapsing, and what was once image 3 (@code{im_2}) 
1147 is now image 2, and @code{im_2} is now an invalid reference. This clearly means 
1148 that invoking:
1149 @example
1150 adesklets.free_image(im_2) 
1151 @end example
1152 @noindent would generate an @code{image out of range} error message.
1154 @unnumberedsubsubsec Special subject: animations
1156 @command{adesklets} now includes an indirect mode of execution and textual 
1157 variables (non-recursive textual replacements, to be precise) as well. 
1158 This means desklets writers have what is needed to create precisely-timed
1159 animations. You can find an easy-to-follow example in @file{test/fading.py}.
1160 A somewhat more involved use of these features is also made in the @code{yab}
1161 desklet. To realize an animation from Python, one should:
1163 @enumerate
1164 @item @strong{Record} a sequence of commands 
1165 (we will call it a macro command, or macro for now on). From Python, this
1166 involves toggling on indirect mode using the @code{adesklets.start_recording()}
1167 function, emitting an undetermined number of @command{adesklets} commands,
1168 then toggling back into normal mode (direct execution) with 
1169 @code{adesklets.stop_recording()}. Of course, no command is ever evaluated
1170 while the interpreter is in indirect mode; commands are only stored in the
1171 history for future replay.
1172 @item @strong{Set up} whether the to-be-replayed sequence of commands can be
1173 interrupted by events or not, using the @code{adesklets.play_set_abort_on_events()}
1174 function. The high-level @code{adesklets.Events_handler::set_events()} method
1175 can also be used to dynamicaly change what events are caught. See 
1176 @file{test/test_events.py} for an example.
1177 @item @strong{Set up} the variables used within the recorded macro using the 
1178 @code{adesklets.set()} function, very similar to its Bourne shell homonym.
1179 @item @strong{Play} the macro using the @code{adesklets.play()} function.
1180 @end enumerate
1182 Here are a few additional remarks:
1183 @itemize
1184 @item Precise timing during replay is achieved through the @code{time_gate}
1185 command. This works very simply: every time a macro replays, adesklets
1186 records its starting time, and whenever a @code{time_gate} command is
1187 encountered during the replay, it waits for the number of seconds given as
1188 an argument to @code{time_gate} to run out. For instance, specifing
1189 @code{time_gate 0.1} in a macro will make any subsequent commands within the
1190 macro not execute before the macro has run for at least a tenth of second.
1191 @item Variable expansion always occurs just before command execution, regardless
1192 of current interpreter mode (direct or indirect). All sequences of characters
1193 not containing spaces directly following a single '$' will get replaced with
1194 the corresponding variable content (previously configured using @code{set}).
1195 If no matching variable is found, the sequence is simply discarded.
1196 @item All macro commands replayed through the @code{play} command are always 
1197 atomic for the driving desklet, as are any other non-macro commands. 
1198 Simply put, it means no event will ever get generated while a macro is replayed;
1199 they will all get issued right after the @code{play} command returns.
1200 @item As usual, the adesklets interpreter is stateful for indirect mode related 
1201 states and variables. You do not have to set up the @code{set_abort_on_events}
1202 flags or variable every time you want to call a macro, only if something
1203 needs to be changed since the last call.
1204 @item The main use of high-level @code{adesklets.Events_handler::set_events()}
1205 is to stop the catching of specific events during macro playback, so the macro
1206 can be interrupted only in specific circumstances. Of course, all events
1207 generated before the call to the method will not be lost but queued, and
1208 appropriate event methods will be called later, provided the handlers are set 
1209 back once the macro playback completes.
1210 @item Did we mention that it is a bad idea to do any of this from an unprotected
1211 place? Well, it is. Don't forget to use @code{adesklets.Events_handler::block()}
1212 and @code{adesklets.Events_handler::unblock()} around all animation-related code
1213 if you have an object of a child class of @code{adesklets.Events_handler}
1214 instantiated.
1215 @end itemize
1217 @unnumberedsubsubsec Configuration and internationalization
1219 Let us just mention here that from @command{adesklets} 0.4.0, the
1220 @code{adesklets.utils} module now includes an optional 
1221 @code{ConfigFile} class that can be easily reused by desklets authors 
1222 to add an easily extendable configuration facility to their 
1223 code@footnote{You can look at any non-contributed configurable desklet for 
1224 example usage.}
1225 @ifhtml
1226 (@xref{Python package documentation}.)
1227 @end ifhtml
1228 . The class also handles internationalization automatically by default, 
1229 setting the charsets according to users' needs. Charset usage can of course 
1230 be determined or changed at any time using the @code{adesklets.get_charset()}
1231 and  @code{adesklets.set_charset()} functions. The 
1232 @code{adesklets.utils.ConfigFile} class also has a @code{charset} attribute one
1233 can examine to determine the user's preference. When using this class, one
1234 should  note that an 'ASCII' charset is considered the default, and will not 
1235 toggle any conversion. This way, users on platforms not supporting iconv will 
1236 always be able to use @command{adesklets} without internationalization support.
1238 @unnumberedsubsubsec Final words
1240 @noindent Finally, let us mention you may want to take a look at the 
1241 @file{weather} desklet source code from the
1242 @weblink2{SourceForge project web site,http://sourceforge.net/projects/adesklets/} 
1243 for a more substantial piece of Python code using adesklets. There are also a 
1244 few other test desklets under @file{test/} that may give you some ideas.
1245 @ifhtml
1246 You could also have a look at pydoc's autogenerated
1247 @command{adesklets} package help, included with this document
1248 (@xref{Python package documentation}.). Whenever you are happy enough with 
1249 your desklet, feel free to share it with the rest of us (this would be 
1250 much appreciated)--package it (@xref{Packaging GNU Makefile for desklets}.), 
1251 and then submit it (@xref{Submitting a desklet}.).
1252 @end ifhtml
1254 @node Extending adesklets
1255 @chapter Using adesklets from other language environments
1257 adesklets was made to be easily usable from a variety of langage
1258 environments@footnote{We use the term ``langage environment'' because the 
1259 problem is not the syntax or the paradigm used (should it be imperative, 
1260 functional, or anything else); it is the way you can handle basic POSIX-related
1261 operations with files, signals, etc. (@xref{Requirements}.). Thus, a Perl 5 
1262 user should use adesklets easily, while a Linux JDK user would probably 
1263 encounter more difficulties (no flames intended).}. This chapter explains 
1264 to programmers how the adesklets interpreter hooks itself into the system 
1265 in a language-neutral fashion.
1267 @noindent If you are not minimally used to POSIX systems or do not have basic 
1268 notions on operating system programming, this chapter is probably of no
1269 interest to you.
1271 @noindent Please note that the Python package under 
1272 @file{scripting/python/adesklets} 
1273 is a good complement for what you are about to read.
1275 @section Requirements 
1276 @anchor{Requirements}
1277 If you want to use the adesklets interpreter from your favorite language
1278 but it is not supported out of the box@footnote{As of adesklets
1279 @value{VERSION}, only Python is supported out of the box.}, you can still do
1280 it, provided your langague supports one of these features:
1282 @itemize
1283 @item Reading and writing in pipes; or
1284 @item Reading and writing from/to files unbuffered 
1285 @end itemize
1287 @noindent It should also be able to either@footnote{This said, having both IPC
1288 support and poll/select will make things both simplier and cleaner. Being able 
1289 to block signals is also very useful.}:
1291 @itemize
1292 @item Catch IPC reliable signals; or
1293 @item Read files in non-blocking mode; or
1294 @item Be able to perform a poll/select on files
1295 @end itemize
1297 @noindent Finally, it should also be able to start a child process. 
1299 @noindent Those a pretty light requirements from a POSIX point of view, but let
1300 us mention for the sake of completeness that if your language environment does
1301 not meet these requirements, you could still use it provided you can get your
1302 application to talk reliably with another program@footnote{This would be a
1303 wrapper, basically.} that meets them. Of course, this is not an ideal situation
1304 and it should be avoided as much as possible.
1306 @section Initialization mechanism
1308 As you probably know (@xref{Using adesklets}.), there are two modes of operation
1309 for @command{adesklets}, as it can be called:
1311 @enumerate
1312 @item as a desklets launcher--whenever you call @command{adesklets} without 
1313 arguments.
1314 @item as an interpreter--in all other cases (interactive command line use
1315 or a child process from a desklet).
1316 @end enumerate
1318 @subsection adesklets called as a desklets launcher - restarting all desklets 
1319 @noindent On a new X session, the typical startup sequence is:
1321 @enumerate
1322 @item @command{adesklets} gets called without arguments, somewhere 
1323 from the X session initialization scripts.
1324 @item From there, the new adesklets instance acts as a desklets launcher. 
1325 It parses the @file{$HOME/.adesklets file}, then forks as many times as there 
1326 are desklets to start.  The original launcher process then exits as there is
1327 no need for a daemon here.
1328 @item All forked processes set up the @code{ADESKLETS_ID} environment variable
1329 with a string representation of the proper integer ID, then execute
1330 @footnote{With a call from the execve* family; see @code{man 2 execve}.} 
1331 the associated script.
1332 @item Each desklet launches itself an @command{adesklets} instance as a child
1333 process, passing along the @code{ADESKLETS_ID} variable without altering it. 
1334 It is the desklet's duty to make sure that:
1335 @itemize
1336 @item the adesklets interpreter standard streams, 
1337 @code{stdin}, @code{stdout} and @code{stderr}, get separately redirected, 
1338 in a way that parent process can easily write to adesklets' @code{stdin}, 
1339 and read from @code{stdout} and @code{stderr}. Use of pipes, FIFOs or event
1340 regular files are all possible.
1341 @item the writes to @code{stdin} and reads to the two other streams are 
1342 all unbuffered.
1343 @item the first command argument given to @command{adesklets} is the absolute
1344 file name of the desklet script.
1345 @end itemize
1346 @item Each newly created @command{adesklets} interpreter process initializes 
1347 itself using the environment @code{ADESKLETS_ID} variable and the command
1348 line absolute desklet name given as its first argument to lookup its 
1349 unscriptable characteristics@footnote{They are, namely, its screen and 
1350 coordinates.} from @file{$HOME/.adesklets}. When this operation is over, 
1351 the @code{ready!} event is generated (@xref{Events}.), and the interpreter is 
1352 ready to process commands.
1353 @end enumerate
1355 @subsection adesklets called as an interpreter - registration of a new desklet
1357 When a new desklet gets called directly, the startup sequence described in
1358 the previous subsection is the same, except for the first, second and third
1359 steps which simply don't occur. This means that the environment 
1360 @code{ADESKLETS_ID} is not set; the new @command{adesklets} interpreter uses 
1361 this fact to detect this is a new desklet, parse the @file{$HOME/.adesklets}
1362 configuration file and allocate the first free ID to the desklet.
1364 @noindent It should be noted that if the desklet file name given as the first 
1365 argument to the child @command{adesklets} instance is relative or is not both
1366 readable and executable by the current user, the desklet will not get registered
1367 in @file{$HOME/.adesklets}, and therefore not automatically restarted in 
1368 subsequent new X sessions by the launcher. In case @code{stdin} is a 
1369 terminal@footnote{Which means the session is interactive}, the registration
1370 does not take place either.
1372 @subsection Consequences
1373 This way, from the scripted desklet perspective, both cases are identical, and
1374 no conditionnal treatment is needed. All the desklet initialization job 
1375 is synthesized in the fourth point in the subsection above.
1377 @noindent If needed later on, the desklet can use the @code{get_id} command 
1378 to determine its ID.
1380 @section Using streams
1382 As explained previously, a desklet communicates with its private adesklets 
1383 interpreter via redirected unbuffered streams. Here, let us see what information
1384 they convey.
1386 @subsection stdin: the commands
1388 On the interpreter's @code{stdin}, the desklet outputs the commands it wants to
1389 execute in the order in which it wants them to be executed, one command per 
1390 line@footnote{A '\n' character should be emitted after each command.}. Since 
1391 reading this stream is suspended while a command is processed, a desklet should
1392 generally wait for a command to be processed before emitting 
1393 another@footnote{This is to avoid process blocking by overflowing the stream 
1394 with arbitrarily long commands; of course, there is no problem sending three
1395 commands of a few hundred bytes in one shot!} (See the next section).
1397 @noindent The command format is pretty simple: it is a command name, followed 
1398 by arguments separated by spaces, all in plain text representation, including 
1399 numbers. adesklets does not care about the number of spaces between arguments,
1400 as long as there is at least one. In the special case of commands where the
1401 last argument is a string (@code{text_draw}, for instance), adesklets will
1402 choose its first non-space characters to be its beginning; the rest of the
1403 line, including spaces, are considered to be part of the string.
1405 @noindent Two files, automatically kept in sync with the source 
1406 (@file{scripting/prototypes} and  @file{scripting/enums}) from the base source
1407 distribution, provide in tab-separated plain text format the description of all
1408 the commands and numeric constants that can be made available to the 
1409 desklets@footnote{See @file{scripting/protoize.sh.in} and 
1410 @file{scripting/enums.sh} for details on the format of the two files.}. A good 
1411 binding for a specific language should come with some automation to
1412 auto-generate pertinent parts of its own codebase based on those files; for
1413 instance, the Python binding adds a @code{protoize} action to its 
1414 @file{setup.py} @code{distutils} script to do so. Ideally, this automation code
1415 should be redacted in the target language with a reasonable set of 
1416 libraries@footnote{The key idea being that most users of your binding should be
1417 able to run it more or less from their base installation of the language.}; 
1418 if it is not well suited to this task, you need to limit yourself to use:
1420 @itemize
1421 @item Portable Bourne shell, conforming to POSIX 1003.2 and 1003.2a, scripts
1422 @item A recent sed (Streaming Editor), compatible with GNU
1423 sed@footnote{Nowadays, there is no problem running GNU sed on practically any
1424 POSIX system.}
1425 @item Portable use of any bc for arithmetic
1426 @end itemize
1428 @noindent if you want your work to become part of the official package.
1430 @subsection stdout: the command results
1432 The @command{adesklets} interpreter frequently polls its @code{stdin} 
1433 for new characters, and reads from it as needed. Whenever it receives an
1434 End-Of-Line ('\n'), it stops reading from it and tries executing the command. 
1435 Once the command has been carried out (possibly emitting a few lines on
1436 @code{stdout}), it sends as its last entry on it a status message of the form:
1438 @example
1439 command RANK ok: MESSAGE_STRING
1440 @end example
1442 @noindent if the command was successful, or:
1444 @example
1445 command RANK error: ERROR_STRING
1446 @end example
1448 @noindent if an error occurred.
1450 @noindent @code{RANK} is the numerical ID of the command (an unsigned integer)
1451 that starts at zero when the interpreter is created, and then is automatically
1452 incremented by one for every subsquent line it receives. All commands are 
1453 guaranteed to be processed in the order they were submitted. 
1454 @code{ERROR_STRING} is a free-form message in human-readable form explaining the
1455 source of the error. @code{MESSAGE_STRING} is also in human-readable form, but
1456 is formatted in such a way that it can be used to retrieve algorithmically
1457 useful return values for any commands. Those return values can be:
1459 @enumerate
1460 @item an integer--the return value ID (@code{create_image} and such)
1461 @item a tuple of integers--the numerical command output 
1462 (for @code{context_get_color} and the like)
1463 @item a list of strings--the ordered list of output strings 
1464 (for @code{images_info} and the like) for commands that output multiple lines
1465 on @code{stdout}, with the last line being the status message 
1466 @item a description string--a one-line textual answer from the command
1467 @item nothing at all
1468 @end enumerate
1470 @noindent Algorithmically, your "return value retrieving routine" should first
1471 try to retrieve integers from 
1472 @code{MESSAGE_STRING}@footnote{All parameters from the @code{MESSAGE_STRING}
1473 are separated by single spaces.}. If there is one or more integers present, 
1474 it should verify that the message is not a mere copy of an emitted command;
1475 if it is, the return value follows the fifth case (see above); otherwise, 
1476 if only one integer is found, this is the first case; if more than one is
1477 found, the second one.  If no integers are found and there was a list of lines 
1478 sent to stdout before the status message of the command, and after the status
1479 message of the previous command, it then returns according to third case.
1480 In what's left, if the status message is different from the emitted command, it
1481 is the fourth case. All remaining conditions should be mapped to the fifth
1482 case. This retrieving algorithm is working for all commands listed in
1483 @file{scripting/prototypes}.
1485 @subsection stderr: the events
1486 @anchor{Events}
1488 All remaining asynchronous event reports are sent to the interpreter's
1489 @code{stderr}. They are asynchronous regarding the processing of commands;
1490 if they will never occur while a command is processed (in the time interval
1491 between the submission of the complete command on @code{stdin} and the output
1492 of its message status line on @code{stdout}), they can be sent at any other
1493 time@footnote{No event is ever lost anyway; its report is only delayed.}.
1495 @noindent Event reports are single lines of the form@footnote{All other outputs
1496 on @code{stderr} can safely be discarded.}:
1498 @example
1499 event: EVENT_MESSAGE
1500 @end example
1502 @noindent In a stylized Backus Naur form, the grammar for EVENT_MESSAGE would 
1505 @verbatim
1506 EVENT_MESSAGE :: ready! |
1507                  backgroundgrab |
1508                  menufire MENU_ID MENU_STR |
1509                  motionnotify X Y |
1510                  enternotify X Y | 
1511                  leavenotify X Y |
1512                  buttonpress X Y BUTTON_ID |
1513                  buttonrelease X Y BUTTON_ID
1515 @end verbatim
1517 @noindent where @code{MENU_ID}, @code{X}, @code{Y}, and @code{BUTTON_ID} are
1518 all integers greater than or equal to zero, and @code{MENU_STR} is a string of
1519 characters, possibly including spaces. Let us detail things a bit further:
1521 @itemize
1522 @item Ready event: sent only once, whenever the @command{adesklets} interpreter
1523 becomes ready to process commands.
1524 @item BackgroundGrab event: sent every time the background image (image 1) gets 
1525 regenerated.
1526 @item MenuFire event: sent every time the user select an item in a menu not
1527 managed internally by adesklets.
1528 @item MotionNotify event: sent whenever the pointer moves inside the adesklets 
1529 window.
1530 @item EnterNotify, LeaveNotify: sent whenever the cursor passes over a visible
1531 border of the interpreter window, either going in or out.
1532 @item ButtonPress, ButtonRelease: sent when a pointer button is clicked inside 
1533 the interpreter window.
1534 @end itemize
1536 @noindent All events but Ready! (namely: MotionNotify, EnterNotify, 
1537 LeaveNotify, ButtonPress, ButtonRelease, BackgroundGrab and MenuFire) are
1538 masquable by the desklet. In fact, @command{adesklets} provides the desklet
1539 with commands for specifically handling the generation and output of events.
1540 They are: 
1541 @code{event_catch}, @code{events_get_send_sigusr1}, @code{events_reset_all},
1542 @code{event_uncatch}, @code{events_info}, @code{events_set_echo}, 
1543 @code{events_get_echo}, @code{events_purge} and @code{events_set_send_sigusr1}.
1544 It should be noted that those functions are not listed in
1545 @file{scripting/prototypes} as you most probably do not want your users having
1546 access to them. You should probably start an interactive session and play with
1547 them to make sure you fully understand this. This is also the right time to
1548 mention the @file{src/adesklets_debug.sh} script, which comes in handy when
1549 interactively experimenting with events.
1551 @noindent Two last things are worth mentionning about events:
1553 @enumerate
1554 @item By default, events are not echoed, but stored internally, waiting 
1555 to be purged with @code{events_purge}. You can change this with
1556 @code{events_set_echo}.
1557 @item You can set the adesklet interpreter to send a SIGUSR1 signal every time
1558 an event is printed out to its parent process (the desklet). It is a very
1559 useful IPC, since the signal can be trapped, allowing the event management
1560 routine to run only when necessary. This is what the Python package uses within
1561 its @code{Events_handler} class.
1562 @end enumerate
1564 @section SIGCHLD signal handler
1566 Whenever your language allows it, you should install some kind of SIGCHILD
1567 handler, so you can at least be notified if the adesklets interpreter ever
1568 exists without a reason (child zombies notwithstanding)@footnote{@code{man 2
1569 signal} is a very good reference on signals.}.
1571 @section Textual variables
1573 @command{adesklets} also supports differed execution (indirect mode)
1574 and textual replacement of variables. Here how variables work in indirect mode:
1576 @enumerate
1577 @item Once a command is entered, it is stored untouched into the commands
1578 history list, if applicable (in non-interactive usage of the interpreter,
1579 when the command lies bethween calls to @code{start_recording} 
1580 and @code{stop_recording})
1581 @item When a macro command is played back (using the @code{play} command,
1582 @xref{Programming adesklets}.), variables get expanded in a single pass, and no
1583 indirect reference is possible.  Expansion is pretty straightforward. The stored
1584 command line is scanned for any non-empty sequence of non-space characters
1585 beginning with a single '$'.  Each such sequence is replaced with the 
1586 corresponding @code{$variable} value, or removed if no variable is found.
1587 @item Expanded command get executed.
1588 @end enumerate
1590 The same expansion mechanism also applies to the direct mode of execution. All
1591 this leads to the fact that, using the Python package for instance, these two
1592 code snippets are equivalent:
1594 @example
1595 adesklets.window_resize(100,100)
1596 @end example
1598 and:
1600 @example
1601 adesklets.set('dim',100)
1602 adesklets.window_resize('$dim','$dim')
1603 @end example
1605 This did not require any alteration of our Python code, since Python is a
1606 dynamic language, but some other languages will require further thinking.
1608 @section Final words
1610 You should now know pretty much everything needed for integrating adesklets with
1611 your language environment. It may appear to be a daunting task, but a very
1612 clean binding can be produced by one programmer in only a few days. Once again,
1613 have a look at @file{src/adesklets_debug.sh}; it is a (very lame) Bourne shell 
1614 binding for adesklets written in only fifty lines, including comments.
1616 If you ever need assistance, you are encouraged to post on the 
1617 @weblink2{adesklets-devel mailing list,https://lists.sourceforge.net/lists/listinfo/adesklets-devel}...
1619 Happy coding!
1621 @noindent 
1622 @node Help wanted!
1623 @chapter Contributing to adesklets
1625 Your help is wanted! You can valuably contribute to adesklets by:
1627 @itemize
1628 @item
1629 @strong{Posting your adesklets screenshots online}. You use adesklets and think
1630 you have a pretty cool desktop? Share it with the world by posting it online,
1631 and send us a link! This way, you will help people learn about the project.
1632 @item
1633 @strong{Contribute to the documentation}. You have very good written
1634 knowledge of German, Spanish, Portugese, Arab or Swahili? Translators are always 
1635 welcomed, proofreaders too, for all languages.
1636 @item
1637 @strong{Writing new desklets}. adesklets is still young: we crave
1638 talented desklets writers, and we would be more than willing to post or link
1639 to your work. Do not worry too much about interface changes; the author spent
1640 considerable effort to ensure that the interface would be fairly stable even
1641 in the earliest releases.  It's not frozen forever, but it shouldn't break your
1642 desklets without some warning.  At this point, the API is predominantly getting
1643 internal bug fixes and portability improvements.
1644 @item
1645 @strong{Adding bindings for your language of choice}. Contact the developers 
1646 beforehand so that you don't waste time on something that is already written;
1647 they will be glad to share code.  Subscribe to the
1648 @weblink2{adesklets-devel mailing
1649 list,https://lists.sourceforge.net/lists/listinfo/adesklets-devel} on
1650 SourceForge for quick access to them.
1651 @end itemize
1653 @noindent Contact me by email at @email{syfou@@users.sourceforge.net}.
1655 @node Frequently asked questions
1656 @appendix Frequently asked questions
1658 Last update: @value{UPDATED}
1659 @appendixsection Compiling adesklets
1661 @subheading The adesklets configure script says my Python install is too old, but it's not. What's the problem?
1663 Some platforms (NetBSD, Ubuntu Linux, probably others too) sometimes alter 
1664 the Python version, appending letters, prefixing minor numbers, etc., thus 
1665 preventing the configuration script from detecting it properly. If you know 
1666 @strong{for sure} that what you have installed is at least 2.3.0,
1667 you can pass the @code{--with-python-force-detection} switch to 
1668 @code{configure}; this will make the configuration script skip the version 
1669 detection.
1671 @appendixsection Installing desklets
1673 @subheading I find the default desklets installation method tedious: it there a simpler way to install them?
1675 From adesklets 0.5.0, you have a new @command{adesklets_installer} 
1676 script (@xref{Using adesklets}.). It can
1677 help you download and unpack new or updated desklets. 
1679 @subheading Well, that's kinda better, but it is still not fully automated (I hate reading and understanding new things, you know)...
1681 True. @command{adesklets_installer} just notify you of updates, download, 
1682 check and unpack desklets, but it is still your duty to see their README, 
1683 fulfill their requirements, start, stop and configure them.
1685 But frankly, it is @emph{that} difficult? Most people does not change their
1686 desklets settings very often anyway. This is was deliberate choice from our
1687 part: the goal of adesklets has always been to minimize overall code 
1688 complexity, leading to a leaner, tighter, more consistent package. Why solving
1689 in a long, tedious, hard to write and maintain software all the corner cases a 
1690 smart user can figure out in minutes with proper documentation?
1692 If full automation is what you crave, have a look at the alternatives 
1693 to adesklets (@xref{About adesklets}.).
1694 @appendixsection Starting and stopping desklets
1696 @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?
1698 It means what is written: @command{python} cannot find the @code{adesklets}
1699 package; maybe it did not get installed, or it did get installed in the wrong
1700 place.
1702 @itemize
1703 @item Restart from the beginning the installation procedure
1704 (@xref{Installing adesklets}.). Make sure you @strong{do not} select
1705 the @code{--without-python-support} configuration option.
1706 @item Retry starting the desklet. If it still does not work, verify that the
1707 installation directory, given by:@example
1708 sed -n '/PYTHON_SITE_PKG/p' Makefile
1709 @end example
1710 @noindent is included in :@example
1711 echo 'import sys; print sys.path' | python
1712 @end example
1714 @noindent If not, you can still manually move the adesklets directory 
1715 from @code{PYTHON_SITE_PKG} to any path displayed by this last command.
1716 @end itemize
1718 @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?
1720 This is a generic error telling you something is off with the low-level 
1721 interpreter, critical enough to cause it to exit. If  you are lucky, 
1722 you will have at the end of the line a dash, followed by 
1723 a descriptive message telling you what went wrong. In that case, if you have 
1724 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:
1725 @example
1726 echo x_status | adesklets :
1727 @end example
1728 You should normally get something similar to:
1729 @example
1730 event: ready!
1731 command 0 ok: x_status 1 (connected to ':0.0')
1732 @end example
1734 If you do, you are probably using a system
1735 (@weblink2{archlinux,http://www.archlinux.org/} for instance),
1736 on which the @code{PATH} variable for the Python interpreter differs from
1737 what is inherited from standard environment, which causes the Python package to
1738 fail to launch adesklets as a child process. On such systems, make sure
1739 to install @command{adesklets} using an appropriate @code{--prefix} switch at
1740 the configuration stage. For instance, on most recent Linux platforms, you 
1741 should use:
1743 @example
1744 ./configure --prefix=/usr
1745 @end example
1747 @subheading I cannot run any Python-based desklet: I get garbage collection errors!
1748 If you get errors similar to:
1750 @example
1751 python: Modules/gcmodule.c:275: visit_decref: Assertion `gc->gc.gc_refs != 0' failed.
1752 Aborted 
1753 @end example
1755 It means your installment of Python has a corrupted garbage collector; it is 
1756 often caused by incorrect or aggressive optimization during the compilation. 
1757 Just recompiling a stock python environment from 
1758 @weblink{http://python.org/} usually solves this.
1760 @subheading Desklets start fine as root, or as local user account, but just freeze or exit on NFS-mounted accounts
1762 adesklets needs to be able to lock some files under @code{$HOME} for working 
1763 reliably: most problems with network file systems are due to semi-functionning 
1764 installment failing to honour such locks. You have a short script under 
1765 @code{test/flock.py} in adesklets source tarball that provides a simple test 
1766 of fcntl locks; its normal behavior is to acquire a lock in the current working 
1767 directory, wait for the user to press a key, then release it and exit. 
1768 You can launch multiple instances of the script from the same directory to 
1769 verify that the locking is indeed working. If not, making it work will very likely
1770 make adesklets work too.
1772 @subheading Everything worked fine but then I tried upgrading a desklet, and I couldn't ever see the new one. What is wrong?
1774 There is a built-in lock mechanism in the interpreter that prevents a user from
1775 simultaneously running more than one desklet with the same @code{ID} and name,
1776 regardless of version.  Whenever you upgrade a given desklet, you should first
1777 cleanly quit the desklet (by using @code{Quit} from the context menu), then
1778 install the updated desklet by following the instructions provided in the 
1779 @file{README} file.
1781 @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!
1783 This is most probably related to the way you started the desklet
1784 (Please @pxref{Using adesklets}.). You need to invoke the desklet script
1785 @strong{only once}. Afterwards you just need to run the command:
1787 @example
1788 @command{adesklets}
1789 @end example
1791 and it will remember where you placed your desklets and which desklets 
1792 you had running. Do not forget the pass flags to @command{adesklets}, 
1793 as appropriate.
1795 @subheading This is exactly what I did, but the darn thing wouldn't restart anyway.
1797 Did you store the desklets under a @file{$HOME/.adesklets} directory?
1798 Please don't.
1799 @command{adesklets} need a @file{$HOME/.adesklets} file to store the various
1800 user settings on running desklets; setting up a directory of the same name 
1801 prevents it from doing its job right, so just move your directory some place 
1802 else (@file{$HOME/.desklets}, for instance).
1804 @subheading Starting the desklets works fine, but they continue running when I terminate the X session.
1806 Normally, the desklets are supposed to be automatically terminated on the dead of
1807 the session. If you have the frontend shell server installed (the default), 
1808 you can also kill them manually by invoking the 
1810 @example
1811 adesklets --killall
1812 @end example
1814 command somewhere from the session exit.
1816 @appendixsec Displaying desklets
1818 @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)!
1820 Try the command:
1822 @example
1823 python test/test.py
1824 @end example
1826 @noindent from the base source directory. If a 100x100 window appears when 
1827 testing the desklet, it most probably means you are using a window manager 
1828 that draws a big window (so called ``fake'' root window) over the root window; 
1829 your desklets are just drawn below it. Such window managers include Nautilus, 
1830 KDE, Xfce4, CDE or E17. As on adesklets @value{VERSION}, supported window 
1831 managers in that category are:
1833 @itemize
1834 @item @strong{KDE}: for versions >= 3.4.1 (earlier versions untested). 
1835 You need to turn on ``Control Center -> Desktop -> Show icons on desktop -> 
1836 Allow programs in desktop window'', or to turn off the ``Show icons on desktop'' 
1837 altogether@footnote{Thanks to Stefan Jungcurt for the hint.}.
1838 @item @strong{Nautilus}
1839 @item @strong{ROX-Filer}: only preliminary support for now
1840 @item @strong{Xfce4}
1841 @item @strong{xffm-desktop}: only preliminary support for now
1842 @end itemize
1844 From adesklets 0.4.11 and onward, the fake root window detection method had 
1845 changed: it is no longer part of the C code by 
1846 default@footnote{Although you can get back
1847 the old behavior if you wish by using
1848 @command{--enable-legacy-fake-root-window-detection} at configuration time.
1849 @xref{Installing adesklets}.}. The interpreter now expects 
1850 the ADESKLETS_ROOT environment variable to contain the correct fake root
1851 window hexadecimal ID, if any. You can of course set it manually, 
1852 but a shell frontend will be handling most common window managers for you 
1853 (see list above), as long as you instruct it to. Try invoking:
1855 @example
1856 adesklets --help
1857 @end example
1859 If the shell frontend is installed, you will get many options, including how to
1860 trigger window managers specific fake root window detection routines.
1861 You also have a ``generic'' fake root window detection under 
1862 the switch @command{--user}: it could work (or not) for you, depending on 
1863 the structure of your window manager. Finally, please note the frontend 
1864 is a simple sh-compatible script, installed by default under 
1865 @command{$prefix/share/adesklets} -- it should be pretty
1866 straighforward to modify by anyone wishing to implement other detection schemes.
1868 It is also good to remember that fake root window detection obviously requires
1869 such windows to exist. It is therefore important to invoke 
1870 @command{adesklets} @emph{after} 
1871 the window manager is reasonably initialized. To help you do this, you have at
1872 your disposal a @command{-w progname} switch in the shell frontend.
1874 @subheading What about enlightenment?
1875 adesklets works as expected with e16 as long as you do not enable features causing 
1876 the use of fake root windows (see previous question), hiding in some circumstances
1877 the desklets behind the Window Manager structure. In the author experimentation 
1878 with version 0.16.7.2, it is only possible to see the desklets in the first 
1879 virtual desktop. This said, in enlightenment lingo, virtual desktops can span 
1880 on many ``screens'' (four, horizontally aligned by default), making perfectly 
1881 possible multiple workspaces usage while keeping adesklets' desklets in sight.
1883 As for e17, it is unsupported. If you insist, you can find more hints on this in 
1884 @weblink2{enlightenment FAQ, http://www.get-e.org/Main/FAQs/#48}. This said, 
1885 e17 comes with something called ``e17 modules'' (engage, etc.), that work 
1886 great under this WM and fill the same niche.
1888 @subheading Now I see the desklets, but the transparency is screwed!
1890 Proper pseudo-transparency relies on the capacity to grab the background image 
1891 as well as getting notified when it changes. There is no entirely reliable 
1892 or even well established method to do this on anything but the real
1893 root window using the core X11 protocol (please read from the beginning of this 
1894 ``Displaying desklets'' section to full understand what follows). 
1896 Hence, even when using a fake root window, adesklets always grabs 
1897 the background from the real root window, no matter what: some windows managers
1898 are careful enough to ensure the synchronisation of the fake root window and 
1899 the real root window at all time, but not too many. adesklets does its best, 
1900 when portably possible, to synchronize @emph{on initial load} the background 
1901 of the real root window with the one of the fake root window, but in some 
1902 supported cases (ROX-Filer, xffm-desktop), this is not even possible. 
1903 Therefore, if you experience screwed-up backgrounds (no background at all, 
1904 incorrect backgroud or background not reflecting the latest change you made, 
1905 while you effectively see the new wallpaper in a fake root window), all you 
1906 need to do is to duplicate the wallpaper set on the real root window, preferably 
1907 using a wallpaper setter supporting the ad-hoc, widely supported
1908 @weblink2{enlightenment mechanism,http://gershwin.ens.fr/vdaniel/Doc-Locale/Outils-Gnu-Linux/Eterm-0.9/#trans} for wallpaper change notification -- any of 
1909 @command{Esetroot}, @command{wmsetbg}, @command{feh}, @command{hsetroot}, 
1910 @command{chbg} or @command{xsri} 
1911 should work fine. In fact, you can even use any wallpaper setter 
1912 to change the real root, but then you could have to rerun the adesklets 
1913 launcher afterwards to take advantage of a correct initial background grab 
1914 if no notification was sent.
1916 @subheading I cannot see smaller desklets such as xmms_bar or asimpleclock, while others work. What gives?
1918 New desklets are always started in the leftmost, upper corner of the screen, at
1919 the very bottom of the windows stack. Make sure you do not have some elements 
1920 (gnomebar, engage, etc) already masking this zone of the screen. Beware! Some 
1921 applications use pseudo-transparency, and can mask the root window seamlessly.
1923 @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!
1925 Go see the Fvwm faq: @weblink{http://www.fvwm.org/documentation/faq/#5.11}.
1926 This @code{BugOpts RaiseOverUnmanaged on} option was reported to work for many 
1927 Fvwm users.
1929 @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?
1931 Invoke the @command{--enable-control-on-context-menu} switch at configuration 
1932 time. This way, normal left click on a desklet should trigger your windows manager
1933 menu in most cases (tested on Xfce4 and *box derivatives). In all cases, you will 
1934 need to press control at the same time to trigger the desklet context menu.
1936 @section Running desklets
1937 @subheading The 'Configure' item from the context menu of many desklets doesn't work!
1938 For this to work--at least for all the demo desklets--you need to have
1939 @command{xterm} installed, and the @code{EDITOR} variable properly set in 
1940 your environment, as it is customary in UNIX. Please note this only launches a 
1941 text editor in a terminal. Editing the desklet's configuration file
1942 (usually @file{config.txt} from base desklet directory) has the same effect.
1944 @subheading Can the 'Configure' item from the context menu invoke a non console-based editor?
1946 Yes, why not? Since adesklets 0.5.0, there is a facilitating wrapper to 
1947 automate this in the shell frontend: see the @command{adesklets -e} (editor)
1948 switch.
1950 @subheading Do you plan including SVG support? I would like to use a SVG image in one of my desklets.
1951 No we do not, sorry. It is not
1952 that @weblink2{SVG,http://www.w3.org/Graphics/SVG/} is a bad format; in fact 
1953 it is quite good. But it is also a vector-oriented one (and rather complex), 
1954 while Imlib2, on which @command{adesklets} relies heavily, is completely 
1955 raster-oriented, and using Imlib2 is the main reason for @command{adesklets}'
1956 simplicity, relatively good speed and low resource usage. 
1958 That said, there is no reason for you not using SVG's with desklets, since 
1959 it is quite easy to convert images in SVG to high quality PNG's, 
1960 using programs such as @weblink2{sodipodi,http://www.sodipodi.com/}, 
1961 @weblink2{inkscape,http://www.inkscape.org/} or @weblink2{xsvg,http://xsvg.org/}. 
1962 In a directory full of SVG's, on a GNU system you can use a command such as:
1963 @example
1964 ls *.svg | sed 's/\(.*\).svg/-z --file=& --export-png=\1.png --export-width=128 --export-height=128/' | xargs --max-lines=1 sodipodi
1965 @end example
1966 to convert them all to 128x128 semi-transparent PNG's.
1968 @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?
1970 First, you need to have fontconfig support enabled in adesklets. See the
1971 config.log from the configuration phase to verify it. If you did not keep the
1972 log, you can also look at the dynamic libraries linked against the interpreter.
1973 On a system with GNU binutils, you can do something like:
1974 @example
1975 ldd `which adesklets` | grep fontconfig
1976 @end example
1977 If you get output similar to:
1978 @example
1979  libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x45c75000)
1980 @end example
1981 it means everything is fine. Otherwise, you should recompile 
1982 @command{adesklets} from source. From there, you can use the line:
1983 @example
1984 echo 'list_font_path' | adesklets :
1985 @end example
1986 to see all the font directories that adesklets will into look for TrueType
1987 fonts.  Consult your fontconfig documentation to learn how to change this
1988 (on up-to-date systems, @code{man 5 fonts-conf} is a good starting point).
1989 Similarily:
1990 @example
1991 echo 'list_fonts' | adesklets :
1992 @end example
1993 Will give you all the fonts that are currently found... Keep in mind when
1994 typing them that font names are case-sensitive.
1996 Alternatively, if you just cannot get fontconfig to work, a way to get around
1997 the problem would be to create symbolic links to the fonts you want to use
1998 inside any absolute font paths listed by the command
1999 @code{echo 'list_font_path' ...} above.
2000 @ifhtml
2001 @node Python package documentation
2002 @appendix Python package documentation
2004 Here are links to significant sections of the Python package documentation:
2006 @itemize
2007 @item @weblink2{adesklets,../pydoc/adesklets.html}
2008 @item @weblink2{adesklets.events_handler,../pydoc/adesklets.events_handler.html}
2009 @item @weblink2{adesklets.commands,../pydoc/adesklets.commands.html}
2010 @item @weblink2{adesklets.utils,../pydoc/adesklets.utils.html}
2011 @item @weblink2{adesklets.configfile,../pydoc/adesklets.configfile.html}
2012 @end itemize
2014 @end ifhtml
2016 @node Imlib2 documentation
2017 @appendix Imlib2 documentation
2019 Carsten Haitzler (@email{raster@@rasterman.com}) took the time to produce very
2020 nice cross-referenced documentation for Imlib2, but for some reason (size
2021 considerations most probably), it is not included in the Imlib2 source
2022 tarball@footnote{Although it can be quite easily regenerated using doxygen.}.
2023 You can
2024 @ifhtml
2025 have it @weblink2{here,../imlib2}.
2026 @end ifhtml
2028 @ifnothtml
2029 find it online at @weblink{http://adesklets.sf.net/doc/imlib2/}.
2030 @end ifnothtml
2032 Most functions of the Imlib2 API have corresponding, homonymic commands
2033 in @command{adesklets}. @xref{Programming adesklets}, for specific details
2034 on the transition from direct Imlib2 programming in C to adesklets.
2036 @node Packaging GNU Makefile for desklets
2037 @appendix Packaging GNU Makefile for desklets
2039 Here is a convenient Makefile that automates the packaging of new or 
2040 existing desklets on a GNU system. Just copy the Makefile below 
2041 into @file{GNUmakefile} from your base desklet directory to use it. 
2042 There is nothing at all to edit, provided you named your base directory
2043 in a proper 'NAME-MAJOR.MINOR.REVISION' fashion, such as @code{beast-0.666.0}.
2045 @verbatiminclude ../utils/GNUmakefile.desklet
2047 @node Submitting a desklet
2049 @appendix Submitting a desklet
2051 @section Desklet package requirements
2052 Requirements for ``official'' desklets packages are scarce; authors are free to
2053 do as they wish. There are only two things that should be enforced:
2054 @enumerate
2055 @item A meaningful @file{README} file should exist in the base source directory 
2056 of the desklet archive and be kept up to date. It should at least contain:
2057 @itemize
2058 @item the name and contact email adress of the author@footnote{It is probably 
2059 not a good idea to give away your private email adress here; 
2060 for spam-related reasons, you should probably open an account 
2061 on @weblink2{SourceForge,http://sourceforge.net/}, or at another similar place 
2062 with a serious spam containment infrastructure.}
2063 @item a short description of the desklet
2064 @item the requirements for running it
2065 @item how to run it
2066 @end itemize
2067 @item The package should be a bzip'ed tarball containing a single source
2068 directory of the form @code{NAME-MAJOR.MINOR.REVISION}, where @code{NAME} is 
2069 the desklet base name, and @code{MAJOR.MINOR.REVISION} the version. Please note
2070 that a makefile (@xref{Packaging GNU Makefile for desklets}.) is also provided
2071 to automate creation of such an archive on GNU systems.
2072 @end enumerate
2074 @section The @command{adesklets_submit} script
2076 Starting in @command{adesklets} 0.4.4, desklet authors are provided with a 
2077 Python script to automate the submission of their desklets: 
2078 @file{utils/adesklets_submit} from the source package. Use the 
2079 @code{--with-python-install-submission-scripts} option at configuration time
2080 to place it in your @code{bindir} directory upon installation.
2082 @file{adesklets_submit} can be used to:
2083 @itemize
2084 @item Submit a new or updated desklet description for inclusion on the
2085 @weblink2{adesklets web site,http://adesklets.sf.net/desklets.html};
2086 @item Submit a bzip'ed desklet archive for inclusion in SourceForge's desklets
2087 package (this is optional--you may choose to host it yourself).
2088 @end itemize
2090 @section Invoking @command{adesklets_submit}
2091 Desklet submission is initiated by sending a specially crafted email to 
2092 @email{adesklets@@mailworks.org}@footnote{It is useless to send anything else 
2093 to this address; all messages that cannot be parsed by the automatic reception
2094 script are just silently dropped. Write to @email{syfou@@users.sourceforge.net}
2095 instead if you want to get in touch with the maintainer.}.
2096 The @command{adesklets_submit} script assits you in the construction of
2097 such an email using the user configuration file @file{$HOME/.adesklets_submit}
2098 and the command line switches. Here is an example of a valid
2099 @file{$HOME/.adesklets_submit} configuration:
2101 @verbatiminclude ../utils/adesklets_submit.example
2103 This is pretty self-explanatory, but here are a few less obvious points:
2105 @itemize
2106 @item
2107 Try to avoid using pseudonyms and nicknames for the @code{author_name} as much
2108 as possible, unless, of course, you already have a pretty well-established
2109 online identity under this name.
2110 @item
2111 @code{send_confirmation} specifies if an email should be sent back to your 
2112 @code{author_email} address whenever your desklet is succesfully published. 
2113 If the submitted entry is rejected, you will always be written back anyway
2114 with an explanation. Usually, the maintainer will not try to make changes to
2115 problematic entries; it will only summarize back to the author what was not OK.
2116 @item
2117 @emph{Double check} your @code{author_email} address, since this is the only
2118 one the maintainer will try to use when contacting you, regardless of what 
2119 the headers say. Failing to supply a valid address will cause all messages to
2120 fail to be sent to you, and all new desklet entries will be rejected.
2121 @item
2122 You can very well use adesklets_submit without any prior contact with the adesklets
2123 maintainer (either via email, within the forum using this adress for
2124 registration, or through the mailing list), but some back and forth will be
2125 needed before publication just to assert your identity and its effective
2126 relation to the provided email address.
2127 @item
2128 @code{desklets} is a dictionary of dictionaries (one dictionary per desklet, 
2129 desklets' names being the keys); all the items referring to files (thumbnail,
2130 screenshot and download) could either be publicly accessible URI's (this is the
2131 preferred method), or local files, either absolute or relative to your $HOME
2132 directory. In that case, needed files will be attached to the generated
2133 multipart email.
2134 @item
2135 All images will always be fetched and integrated on the adesklets.sf.net
2136 web site; you can safely remove them from your online location afterwards 
2137 if you provided live URI's.
2138 @item
2139 When updating already included desklets, there is no need to submit back
2140 the @code{thumbnail} or @code{screenshot} images if they did not change;
2141 you can just as easily reference the already installed images on SourceForge:
2142 @itemize
2143 @item The @code{thumbnail} is always stored under 
2144 @code{http://adesklets.sf.net/images/NAME_thumb.[jpg|png]}
2145 @item The @code{screenshot} is always stored under 
2146 @code{http://adesklets.sf.net/images/NAME_screen.[jpg|png]}
2147 where @code{NAME} is the name of the desklet.
2148 @end itemize
2149 @item
2150 Using the @code{host_on_sourceforge} value, you can choose to have 
2151 your desklet package either hosted on SourceForge or just referenced 
2152 on your site if you provided a URI. Of course, choosing this last 
2153 alternative also means you will need to keep it in place.
2154 @item
2155 The @code{thumbnail} image should be a JPG (preferably) or PNG (if you 
2156 @emph{really} need higher resolutions) of dimensions lying between 190x35 and 
2157 230x110 pixels.
2158 @item
2159 The @code{screenshot} image should be a 640x480 JPG (preferably) or PNG.
2160 It should put your desklet in evidence, and thus contain no other ones.  
2161 @item
2162 You can choose not to submit thumbnails and/or screenshots. In that case,
2163 default, generic images will be used instead.
2164 @item
2165 @code{Category} is unused for now, and just ignored.
2166 @item
2167 All emails weighing more than 300 KB will be rejected by the maintainer's
2168 email server; thus, adesklets_submit will refuse to generate them. Instead of
2169 submitting such big entries, use the URI facility described above to trim
2170 them down.
2171 @item @command{adesklets_submit} does not enforce the requirements above; it only
2172 checks what is strictly required to build a compliant submission email:
2173 the existence of dictionary entries, availability of files, the validity 
2174 of file types if they are local... It is your duty to make sure the entries
2175 meet the other requirements if you want to avoid rejection.
2176 @end itemize
2178 For example, Belial Leviathan would fisrt check his @code{beast} desklet's
2179 entry by doing something similar to:
2180 @example
2181 adesklets_submit beast
2182 @end example
2184 If everything goes fine, it will output the resulting submission email 
2185 on @code{stdout}. From there, Belial can either:
2186 @itemize
2187 @item Pipe it to his favorite MTA (mail transfert agent) to send it to
2188 @email{adesklets@@mailworks.org}.
2189 @item Make @command{adesklets_submit} send it itself by SMTP, using the
2190 @code{smtp_host} and @code{smtp_port} parameters in its 
2191 @file{$HOME/.adesklets_submit}. For this, Belial would use:
2192 @end itemize
2193 @example
2194 adesklets_submit --send beast
2195 @end example
2197 One last thing: you should try to avoid sending minor corrections multiple
2198 times, especially if you use local files.  It both adds to the workload of the
2199 maintainer's email server and to the management work. Please try to create a
2200 valid entry @emph{then} send it, not the other way around.
2202 @appendixsubsec Further submission validation using @command{adesklets_checkin}
2203 From @command{adesklets} 0.4.5, you now have access to the 
2204 @command{adesklets_checkin} script as well. This is the Python 
2205 script that the maintainer uses for checking in all submissions.
2206 @emph{Be aware that this script is only provided to desklet authors as a
2207 convenience, to lower their submission rejection count--developers are in no
2208 way forced to use it, and may even be unable to do so, since the script was not
2209 written with portability in mind as adesklets_submit was. Look at the script 
2210 header for a complete list of requirements.}
2212 @command{adesklets_checkin} has two modes of operation: interactive and 
2213 non-interactive. Only the non-interactive mode will interest desklet authors.
2214 In this mode, usage is fairly simple. Belial, for instance, would do:
2215 @example
2216 adesklets_submit beast | adesklets_checkin
2217 @end example
2219 If everything goes fine, an output similar to this will be produced:
2220 @example
2221 Validation started. Please wait.
2222 Everything seems fine, but keep in mind a few things cannot be
2223 verified without human intervention. See documentation for details.
2224 @end example
2226 If not, you will get an exception trace with some (hopefully) meaningful 
2227 explanations. 
2229 @appendixsubsec Limitations of @command{adesklets_checkin} in non-interactive mode
2231 Here are the remaining problems that @command{adesklets_checkin} 
2232 cannot detect and thus must absolutely be solved manually
2233 (the maintainer would interactively catch most of them, and you would have to
2234 resubmit anyway):
2235 @itemize
2236 @item
2237 Incomplete README file in base directory (Does it contain all the details
2238 enumerated above?).
2239 @item
2240 Out-of-date README file (Does its content reflect the current state
2241 of the desklet?).
2242 @item
2243 Desklet fails to run out-of-the-box (i.e. with or without minimal
2244 configuration) when requirements in the README file are met and special
2245 instructions are followed.
2246 @end itemize
2248 @node Copying This Manual
2249 @appendix Copying This Manual
2251 @menu
2252 * GNU General Public License::  License for copying this manual.
2253 @end menu
2255 @include gpl.texi
2257 @node Open PGP Public Key
2258 @appendix Open PGP Public Key
2260 @verbatiminclude syfou.asc
2262 @noindent You can also get this certificate from many public key servers on 
2263 the internet, such as @weblink{http://www.keyserver.net/}, or
2264 @weblink{http://pgp.mit.edu/}. Contact its rightful owner,
2265 Sylvain Fourmanoit, by email at @email{syfou@@users.sourceforge.net} 
2266 to arrange further key validation if you need any.
2268 @bye