lua - Awesome WM 3.5 seperate config files -
i'm not sure if ok ask things here tell me if not :) . have no idea else ask.
i have problem awesome wm. try separate rc.lua different files (because starts long) , load them in rc.lua.
i have function changing xrandr layout. code works fine, when inserted directly rc.lua.
-- xrandr settings switcher -- -- active outputs local function outputs() local outputs = {} local xrandr = io.popen("xrandr -q") if xrandr line in xrandr:lines() output = line:match("^([%w-]+) connected ") if output outputs[#outputs + 1] = output end end xrandr:close() end return outputs end local function arrange(out) -- need enumerate way combinate output. assume -- want horizontal layout. local choices = {} local previous = { {} } = 1, #out -- find permutation of length `i`: take permutation -- of length `i-1` , each of them, create new -- permutations adding each output @ end of if -- not present. local new = {} _, p in pairs(previous) _, o in pairs(out) if not awful.util.table.hasitem(p, o) new[#new + 1] = awful.util.table.join(p, {o}) end end end choices = awful.util.table.join(choices, new) previous = new end return choices end -- build available choices local function menu() local menu = {} local out = outputs() local choices = arrange(out) _, choice in pairs(choices) local cmd = "xrandr" -- enabled outputs i, o in pairs(choice) cmd = cmd .. " --output " .. o .. " --auto" if > 1 cmd = cmd .. " --right-of " .. choice[i-1] end end -- disabled outputs _, o in pairs(out) if not awful.util.table.hasitem(choice, o) cmd = cmd .. " --output " .. o .. " --off" end end local label = "" if #choice == 1 label = 'only <span weight="bold">' .. choice[1] .. '</span>' else i, o in pairs(choice) if > 1 label = label .. " + " end label = label .. '<span weight="bold">' .. o .. '</span>' end end menu[#menu + 1] = { label, cmd, "/usr/share/icons/tango/32x32/devices/display.png"} end return menu end -- display xrandr notifications choices local state = { iterator = nil, timer = nil, cid = nil } local function xrandr() -- stop previous timer if state.timer state.timer:stop() state.timer = nil end -- build list of choices if not state.iterator state.iterator = awful.util.table.iterate(menu(), function() return true end) end -- select 1 , display appropriate notification local next = state.iterator() local label, action, icon if not next label, icon = "keep current configuration", "/usr/share/icons/tango/32x32/devices/display.png" state.iterator = nil else label, action, icon = unpack(next) end state.cid = naughty.notify({ text = label, icon = icon, timeout = 4, screen = mouse.screen, -- important, not screens may visible font = "free sans 18", replaces_id = state.cid }).id -- setup timer state.timer = timer { timeout = 4 } state.timer:connect_signal("timeout", function() state.timer:stop() state.timer = nil state.iterator = nil if action awful.util.spawn(action, false) end end) state.timer:start() end
i save xrandr.lua , paste folder awesome/rc.
then have function in rc.lua loading files "rc" folder (from here):
function loadrc(name, mod) local success local result -- file? in rc/ or in lib/? local path = awful.util.getdir("config") .. "/" .. (mod , "lib" or "rc") .. "/" .. name .. ".lua" -- if module loaded, don't load again if mod , package.loaded[mod] return package.loaded[mod] end -- execute rc/module file success, result = pcall(function() return dofile(path) end) if not success naughty.notify({ title = "error while loading rc file", text = "when loading `" .. name .. "`, got following error:\n" .. result, preset = naughty.config.presets.critical }) return print("e: error loading rc file '" .. name .. "': " .. result) end -- module? if mod return package.loaded[mod] end return result end
then pasted ' loadrc("xrandr") ' rc.lua, nothing happens. tried different files (for example simple widget , loadrc widget file), pack of errors , doesnt work.
i tried just: "require("xrandr")" still same.
i tried google, awesome 3.4 , i'm not experienced in lua code. help
basically, require("xrandr")
in ~/.config/awesome/rc.lua
tells lua around file called xrandr.lua
in ~/.config/awesome/
while storing in ~/.config/awesome/rc/
. that's why can't find anything. should trick:
require("rc.xrandr")