A config file location option
This commit is contained in:
parent
fcc9550fd5
commit
64e1442d93
27
moltenbar
27
moltenbar
|
@ -61,12 +61,6 @@ class DoSystem < Worker
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class ::String
|
|
||||||
def erb
|
|
||||||
return ERB.new(self).result
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module Modules
|
module Modules
|
||||||
@modules = {}
|
@modules = {}
|
||||||
|
|
||||||
|
@ -88,7 +82,7 @@ class Template
|
||||||
@config = config
|
@config = config
|
||||||
@panel_data = data
|
@panel_data = data
|
||||||
|
|
||||||
return ERB.new(@template).result(binding)
|
return ERB.new(@template).result(binding())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -107,9 +101,19 @@ end
|
||||||
|
|
||||||
require 'erb'
|
require 'erb'
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
require 'optparse'
|
||||||
|
|
||||||
workers = []
|
workers = []
|
||||||
panel_data = {}
|
panel_data = {}
|
||||||
|
options = {}
|
||||||
|
|
||||||
|
OptionParser.new do |opts|
|
||||||
|
opts.banner = "Usage: moltenvar [-c]"
|
||||||
|
|
||||||
|
opts.on("-cCONFIG", "--config=CONFIG") do |v|
|
||||||
|
options[:config_file] = v
|
||||||
|
end
|
||||||
|
end.parse!
|
||||||
|
|
||||||
if ENV["XDG_CONFIG_HOME"] == nil
|
if ENV["XDG_CONFIG_HOME"] == nil
|
||||||
conf_dir = ENV["HOME"] + "/.config/moltenbar"
|
conf_dir = ENV["HOME"] + "/.config/moltenbar"
|
||||||
|
@ -117,15 +121,14 @@ else
|
||||||
conf_dir = ENV["XDG_CONFIG_HOME"] + "/moltenbar"
|
conf_dir = ENV["XDG_CONFIG_HOME"] + "/moltenbar"
|
||||||
end
|
end
|
||||||
|
|
||||||
config_file = conf_dir + "/rc.yaml"
|
options[:config_file] ||= conf_dir + "/rc.yaml"
|
||||||
mod_dir = conf_dir + "/mod"
|
|
||||||
|
|
||||||
puts config_file
|
config = YAML.load_file(options[:config_file])
|
||||||
|
|
||||||
config = YAML.load_file(config_file)
|
config['mod_dir'] ||= conf_dir + "/mod"
|
||||||
|
|
||||||
for m in config['modules'] do
|
for m in config['modules'] do
|
||||||
load("#{mod_dir}/#{m}")
|
load("#{config['mod_dir']}/#{m}")
|
||||||
end
|
end
|
||||||
|
|
||||||
pipe_r, pipe_w = IO.pipe
|
pipe_r, pipe_w = IO.pipe
|
||||||
|
|
Loading…
Reference in New Issue
Block a user