-
Notifications
You must be signed in to change notification settings - Fork 21
/
starter.rb
executable file
·44 lines (37 loc) · 950 Bytes
/
starter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env ruby
class Starter
def initialize
@conf_dir = './configs/'
@base_settings = File.readlines "#{@conf_dir}base_settings.conf"
@configs = %w/sys info data_storage network weather nvidia/
if Dir.exist?('/sys/class/power_supply/BAT0')
@configs << 'battery'
end
end
def run
sleep 20
remove_old_configs
generate_new_configs
execute
end
def remove_old_configs
@configs.each do |config_name|
file = "./#{config_name}.conf"
File.delete(file) if File.exist?(file)
end
end
def generate_new_configs
@configs.each do |config_name|
current_config = File.readlines "#{@conf_dir}#{config_name}.conf"
file = File.new "#{config_name}.conf", 'w'
file.puts(@base_settings + current_config)
file.close
end
end
def execute
@configs.each do |config_name|
system("conky -c ./#{config_name}.conf")
end
end
end
Starter.new.run