I've just moved to Awesome WM from OpenBox. I like that it's very extensible, customizable and I have huge control about window layout. I like structured and organized things and I'd like to separate that huge .config/awesome/rc.lua configuration into multiple files.

2 Answers 2


You can simply place code in a separate file and include it with


Note: The working directory is $HOME. To specify a file relative to rc.lua you can use

dofile(awful.util.getdir("config") .. "/" .. "somefile.lua")

If it's more than just some code and it might be used by others as well, it might make sense to create a lua module which can be included with

somemodule = require("somemodule")
  • It works at 50%, I have to specify full path instead of relative path
    – kravemir
    Commented Oct 28, 2012 at 21:32
  • @Miro fixed, see update.
    – Marco
    Commented Oct 28, 2012 at 22:17
  • On Ubuntu, Awesome's require function looks automatically in .config/awesome/, so you can make a require of any file you put there.
    – wdev
    Commented Dec 22, 2013 at 1:35

To move code into a different file, you create a module and require the module in the rc.lua.

To create a module, you simply call module (name [, ···]) in the script that has the code you pulled out of the original script. Lua reference - module.

To use the module you created, you just call require (modname). Lua reference - require.

There is an excellent tutorial on the Lua wiki that explains this with examples. And if you want to see how module() really works, there is an article on Play With Lua that starts by writing an implementation of module().

  • 1
    Note that starting with awesome-3.5 the lua version was updated to 5.2, where the module() function is deprecated. Therefore the module must be assigned to a variable, like modname = require ("modname")
    – crater2150
    Commented Jan 9, 2013 at 12:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .