1 <?xml version="1.0" encoding="utf-8"?>
2 <section id="GuideReferenceLua">
5 </title><para>Lua scripts allow the functionality of Geeqie to be extended. Lua scripts may only be used in conjunction with the Overlay Screen Display.
7 <para>Some knowledge of the Lua programming language is required.</para>
8 <section id="Requirements"><title>Requirements</title><para>Use of Lua within Geeqie requires Lua 5.1 to be installed. If you are compiling from sources, Lua functionality will be available if the development files dependencies are met.</para>
9 <para>If you are using a pre-compiled distribution, availability depends on the package maintainer.</para></section>
10 <section id="HowToUseLua"><title>How to use Lua</title><para>Lua scripts must be stored in a single folder:<programlisting>
11 ~/.config/geeqie/lua/</programlisting></para>
12 <para>A link to a Lua script must be inserted into the overlay template. Refer to the Overlay Screen Display section of <link linkend="GuideOptionsWindow">Window Options</link>.</para>
13 <para>The full extent of the Lua language is available.</para></section>
14 <section id="GeeqieBuiltIn Functions"><title>Geeqie Lua built-in functions
15 </title><para>The following functions are built in to Geeqie:</para><para>
16 <informaltable><tgroup cols="2"><tbody><row><entry>
17 <emphasis role="strong">Function</emphasis>
19 <emphasis role="strong">Returns</emphasis>
24 The full path of the file, including filename and extension
29 The full filename including extension
34 The file extension including preceeding dot
39 The file date in Unix timestamp format.
44 The file size in bytes
49 A data structure containing the entire exif data
52 <exif_str>:get_datum("<exif_tag>")
54 A single exif tag extracted from a structure output by the above command
56 </tbody></tgroup></informaltable>
57 </para><para>The keyword "Image" refers to the file currently being displayed by Geeqie.</para></section>
58 <section id="Examples"><title>Examples
59 </title><para>The following example, which outputs the jpeg comment of a file, demonstrates the use of a built-in function and how to call a system command from a Lua script:<programlisting>
60 --Retrieve the jpeg comment of a file
62 commentfile=io.popen("exiv2 -p c \"" .. path .. "\"" )
63 comment = commentfile:read("*a")
65 return (comment)</programlisting></para>
66 <para>Note that it is necessary to have escape characters surrounding path and filenames.</para>
67 <para>The following example demonstrates how to extract exif data from a file:<programlisting>
68 --Retrieve the DateTimeDigitized exif tag
69 exif_structure = Image:get_exif();
70 DateTimeDigitized = exif_structure:get_datum("Exif.Photo.DateTimeDigitized");
71 return (os.date(DateTimeDigitized))
72 </programlisting></para></section>
73 <section id="Warning"><title>Warning
74 </title><para>Lua is a powerful programming language. Errors in script files, besides having undesirable side-effects, may cause Geeqie to crash.</para></section>