Skip to content

How To Compile Conky And Its Lua Bindings From Source

Antonio Malcolm edited this page Nov 25, 2015 · 5 revisions

If you find yourself needing to compile Conky from source, either because you want to use the latest version, or because, like me, you found that your Linux distro did not have Conky with the Lua bindings necessary to display data curves (often referred to as "conky rings"), here is a quick description of how to do so.

In order to use Conky with Lua, Conky must be built with Lua bindings for Cairo and imlib2.

(This is in addition to any packages necessary to build conky without Lua bindings, as well as to support the other various configurable options listed for conky via ccmake: libglib-devel, libxml2-devel, libXft-devel, libXdamage-devel, imlib2-devel, wireless_tools-devel, libcurl-devel, and ncurses-devel, to name a few.)

To begin, we'll need to install the current lua development package and the lua 5.1 development package. For many of us, these will both be available from our distro's package manager (named something akin to lua-devel and lua5.1-devel).

We'll likely need to compile the next two dependencies from source.
tolua and tolua++ (also referred to as toluapp) are used by Conky, for its Lua bindings.

Links to the source code for the two dependencies, as well as for the latest version of Conky, are repeated at the bottom of this page.

Here's a breakdown of the requirements, with side notes (from higher to lower level):

Conky (requires tolua++, tolua, MUST use lua51-devel to build the lua-bindings)
tolua++ (aka, toluapp, requires tolua and lua51-devel)
tolua (requires lua-devel)
lua-devel
lua51-devel

And, here's a bit of a diagram:

          conky  
        /   |   \  
 tolua++ ---|---> tolua                
    |       |       |  
    |       |   lua-devel  
    |       |                 
   lua51-devel  

To make this work, we'll edit three configuration files files-
In the tolua++ (toluapp) project source, we'll need to replace the contents of config_linux.py, like so:

## This is the linux configuration file
# use 'scons -h' to see the list of command line options available

# Compiler flags (based on Debian's installation of lua)
CCFLAGS = ['-I/usr/include/lua5.1', '-ansi', '-Wall', '-fPIC']

# this is the default directory for installation. Files will be installed on
# <prefix>/bin, <prefix>/lib and <prefix>/include when you run 'scons install'
#
# You can also specify this directory on the command line with the 'prefix'
# option
#
# You can see more 'generic' options for POSIX systems on config_posix.py

prefix = '/usr/local'
LIBS = ['lua5.1', 'dl', 'm']

Additionally, similarly, we'll edit custom-5.1.py, and point correctly to our lua5.1 lib path:

CCFLAGS = ['-I/usr/include/lua5.1', '-ansi', '-Wall', '-fPIC']
LIBPATH = ['/usr/lib']
LIBS = ['lua5.1', 'dl', 'm']
prefix = '/mingw'
#build_dev=1
tolua_bin = 'tolua++5.1'
tolua_lib = 'tolua++5.1'
TOLUAPP = 'tolua++5.1'

In the conky project source, we'll edit cmake/ConkyPlatformChecks.cmake, line 254, like so:

pkg_search_module(LUA REQUIRED lua5.1 lua-5.1)

Configuration options for conky can be viewed and modified via ccmake. I enabled the following options, in addition to what was already enabled:

BUILD_IMLIB2
BUILD_LUA_CAIRO                                                                                                                                                                                                
BUILD_LUA_IMLIB2                                                                                                                                                                                             
BUILD_LUA_RSVG
BUILD_XDBE
BUILD_XSHAPE

One more thing to note: as of the most recent version of Conky, the config file (conkyrc) uses lua syntax.

Conky source is here: https://github.com/brndnmtthws/conky
tolua source is here: https://github.com/LuaDist/tolua
tolua++ source is here: https://github.com/LuaDist/toluapp

Clone this wiki locally