Software /
code /
clix
Diff
clix.lua @ 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 |
parent | 28:c2998f70dfd4 |
child | 33:f1901c9de891 |
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("^%[(.-)%]");