aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Yakushev <yakushev.alex@gmail.com>2011-09-15 20:34:02 +0300
committerAlexander Yakushev <yakushev.alex@gmail.com>2011-09-15 20:34:02 +0300
commit183a0dc5a9daabc6f1527bf0d71f267de319db66 (patch)
treef60b04af05fbcd1e535c2d4105de03244bc58a43
parentc2dc42baa4dc4a66dfd0f04f287898368bc60a54 (diff)
downloadawesompd-183a0dc5a9daabc6f1527bf0d71f267de319db66.tar.gz
awesompd-183a0dc5a9daabc6f1527bf0d71f267de319db66.tar.bz2
Load submodules from either .config/awesome or .config/awesome/awesompd folder
-rw-r--r--awesompd.lua34
1 files 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)