Changeset

32:cda6a004ff79

clix.lua: Report when config file couldn't be found, change name to .clixrc and comply with fd.o's base directory specifications (now usually ~/.config/.clixrc)
author Matthew Wild
date Sat, 29 May 2010 20:58:27 +0100
parents 31:7f649b0ba94d
children 33:f1901c9de891
files clix.lua
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/clix.lua	Tue Jan 12 02:35:47 2010 +0000
+++ b/clix.lua	Sat May 29 20:58:27 2010 +0100
@@ -48,7 +48,17 @@
 
 local accounts = { default = {} };
 local current_account;
-for line in io.lines(os.getenv("HOME").."/.clix") do
+
+local config_path = (os.getenv("XDG_CONFIG_HOME") or (os.getenv("HOME").."/.config");
+local config_file, err = io.open(config_path.."/.clixrc") or io.open(config_path.."/.clix");
+
+if not config_file then
+	print("Unable to open config file... looked for "..config_path.."/.clixrc");
+	if err then print(err); end
+	os.exit(1);
+end
+
+for line in config_file:lines() do
 	line = line:match("^%s*(.-)%s*$");
 	if line:match("^%[") then
 		current_account = line:match("^%[(.-)%]");