You are not logged in.

#1 2015-11-16 12:12:43

esa
Member
Registered: 2011-12-29
Posts: 143
Website

[lua] AwesomeWM - Loading files

Heyas

I'm having my rc.lua for quite a while, and started to think a little re-structure.
For that i wanted to split seperate sections into files, and load them "in order" from the rc.lua.

As i have not changed much, and the first reload attempt went well (the line with the 'functions-file' loading), i tried with the 'config-variables' and 'config-apps' files.
But just there it starts to fail, logout to LXDM.

rc.lua (related snippet)

-- 
-- 	Variables
--	For internal configuration use, my new configuration files are placed here
--
	DIR_RC = "/rc.new"
-- 
-- 	Functions
--	Load external/custom functions
--
	beautiful.init(awful.util.getdir("config") .. DIR_RC .. "/functions")
--
--	Theme
--
	--beautiful.init("/usr/share/awesome/themes/gray/theme.lua")
	beautiful.init(awful.util.getdir("config") .. "/themes/sea/theme.lua")
	-- Load 'distro specific' icon
	os_icon = wibox.widget.imagebox()
	os_icon:set_image( beautiful.icon_os ) 
--
--	Load apps and variables
--
	--beautiful.init(awful.util.getdir("config") .. DIR_RC .. "/config-variables")
	--my_load_file "config-variables"

If i uncomment any of the last two lines of the ccode above, i get the "quit to login manager".

The files i try to 'load', contain just the code i've copy-pasted from the rc.lua.

./rc.new/functions

-- Functions
-- Its just a workaround for an 'unstable' 'hwmon/hwmon[12]' definition of Fedora21 - Rawhide
-- Function (only) from: http://stackoverflow.com/questions/4990990/lua-check-if-a-file-exists

	function file_exists(name)
		local f=io.open(name,"r")
		if f~=nil then io.close(f) return true else return false end
	end
	
	function my_load_file(name)
		--local thisdir = awful.util.getdir("config") .. DIR_RC .. "/" 
		--beautiful.init( thisdir .. name )
		beautiful.init( awful.util.getdir("config") .. DIR_RC .. "/"  .. name )
	end

./rc.new/config-variables

-- What is your wifi device name - see: "ip addr"
wifi = "wlp3s0"

-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- If you do not like this or do not have such a key,
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod4"

Also note, the loading of the theme works well, also the loading of the functions, as that is verified since the function 'file_exists' of the 'function-file' is used within the theme, which is inited just after and has the proper icon displayed.

Any ideas/thoughts?
Thank you in advance


Author of: TUI (Text User Interface for scripts), VHS (Video Handler Script, using ffmpeg) and YASSI (Yet Another Simple Script Installer)

Offline

#2 2015-11-16 15:39:44

esa
Member
Registered: 2011-12-29
Posts: 143
Website

Re: [lua] AwesomeWM - Loading files

Should have read about lua, rather than beeing fixed on AwesomeWM...

Solutiuon:

load(awful.util.getdir("config") .. DIR_RC .. "/config-variables")

EDIT:
un/solved
Regardless of which line is run, as soon the hardcoded variables (forgot in previous attempt) are removed, it fails as it doesnt find the variables provided by that file.

	--load(awful.util.getdir("config") .. DIR_RC .. "/config-variables")
	--f, err = loadfile (awful.util.getdir("config") .. DIR_RC .. "/config-variables")
	loadfile (awful.util.getdir("config") .. DIR_RC .. "/config-variables")

Any ideas please?

EDIT2:
None of the lines produce any errors as long the variables are stored within the rc.lua itself too.  (as in: before they are removed)

Last edited by esa (2015-11-16 16:00:15)


Author of: TUI (Text User Interface for scripts), VHS (Video Handler Script, using ffmpeg) and YASSI (Yet Another Simple Script Installer)

Offline

Board footer

Powered by FluxBB