From 183a0dc5a9daabc6f1527bf0d71f267de319db66 Mon Sep 17 00:00:00 2001 From: Alexander Yakushev Date: Thu, 15 Sep 2011 20:34:02 +0300 Subject: Load submodules from either .config/awesome or .config/awesome/awesompd folder --- awesompd.lua | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/awesompd.lua b/awesompd.lua index 2ba1473..e770b56 100644 --- a/awesompd.lua +++ b/awesompd.lua @@ -4,8 +4,28 @@ -- @release v1.0.7 --------------------------------------------------------------------------- -require('awesompd/utf8') -require('awesompd/jamendo') +awesompd = {} + +-- Function for checking icons and modules. Checks if a file exists, +-- and if it does, returns the path to file, nil otherwise. +function awesompd.try_load(file) + if awful.util.file_readable(file) then + return file + end +end + +-- Function for loading modules. +function awesompd.try_require(module) + if awesompd.try_load(awful.util.getdir("config") .. + "/awesompd/" .. module .. ".lua") then + return require('awesompd/' .. module) + else + return require(module) + end +end + +awesompd.try_require("utf8") +awesompd.try_require("jamendo") local beautiful = require('beautiful') local naughty = naughty local awful = awful @@ -20,8 +40,6 @@ local function dbg (...) end end -awesompd = {} - -- Constants awesompd.MOUSE_LEFT = 1 awesompd.MOUSE_MIDDLE = 2 @@ -44,14 +62,6 @@ awesompd.ESCAPE_MENU_SYMBOL_MAPPING["&"] = "'n'" -- /// Helper functions /// --- Function for loading icons. Checks if an icon exists, and --- if it does, returns the path to icon, nil otherwise. -function awesompd.try_load(file) - if awful.util.file_readable(file) then - return file - end -end - -- Just like awful.util.pread, but takes an argument how to read like -- "*line" or "*all". function awesompd.pread(com, mode) -- cgit v1.2.3