]> gitweb.fluxo.info Git - awesompd.git/commitdiff
Load submodules from either .config/awesome or .config/awesome/awesompd folder
authorAlexander Yakushev <yakushev.alex@gmail.com>
Thu, 15 Sep 2011 17:34:02 +0000 (20:34 +0300)
committerAlexander Yakushev <yakushev.alex@gmail.com>
Thu, 15 Sep 2011 17:34:02 +0000 (20:34 +0300)
awesompd.lua

index 2ba1473d03267de5fe7db6009e7f714e32adfaa3..e770b56bbb9bfa9ede652775d23758e4bc33e1c4 100644 (file)
@@ -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)