volume: move volume functions into a lib

Also add some notification when changing the volume. Also move
sharetags to the `lib/` directory. And modify `loadrc` to be able to
load modules.
This commit is contained in:
Vincent Bernat 2012-07-14 16:29:19 +02:00
parent 5d55609657
commit 3415d39992
6 changed files with 79 additions and 11 deletions

19
rc.lua
View file

@ -5,10 +5,19 @@ require("beautiful")
require("naughty")
-- Simple function to load additional LUA files from rc/.
function loadrc(name)
function loadrc(name, mod)
local success
local result
local path = awful.util.getdir("config") .. "/rc/" .. name .. ".lua"
-- Which file? In rc/ or in lib/?
local path = awful.util.getdir("config") .. "/" ..
(mod and "lib" or "rc") ..
"/" .. name .. ".lua"
-- If the module is already loaded, don't load it again
if mod and package.loaded[mod] then return package.loaded[mod] end
-- Execute the RC/module file
success, result = pcall(function() return dofile(path) end)
if not success then
naughty.notify({ title = "Error while loading an RC file",
@ -18,6 +27,12 @@ function loadrc(name)
})
return print("E: error loading RC file '" .. name .. "': " .. result)
end
-- Is it a module?
if mod then
return package.loaded[mod]
end
return result
end