66 lines
1008 B
Ruby
Executable File
66 lines
1008 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
require 'yaml'
|
|
require 'erb'
|
|
|
|
$queue = Queue.new
|
|
$workers = []
|
|
$panel_data = Hash.new("")
|
|
|
|
class ModBasic
|
|
def mainloop()
|
|
thread = Thread.new {
|
|
self.data_loop()
|
|
}
|
|
|
|
return thread
|
|
end
|
|
|
|
def data_loop()
|
|
while true do
|
|
t = Time.new
|
|
$panel_data[:dummy] = "#{t}: I am a dummy!"
|
|
$queue << 1
|
|
sleep(1)
|
|
end
|
|
end
|
|
end
|
|
|
|
argv = ARGV
|
|
while argv[0] != nil
|
|
case argv[0]
|
|
when "-h", "--help"
|
|
puts "HELP"
|
|
end
|
|
|
|
argv.shift()
|
|
end
|
|
|
|
$config = YAML.load_file('./rc.yaml')
|
|
|
|
Dir["./mod/*"].each do |file|
|
|
load file
|
|
end
|
|
|
|
lemonbar_cmd = [
|
|
"lemonbar",
|
|
"-g", $config['geometry'],
|
|
"-f", $config['fontspec'],
|
|
"-n", $config['window_name'],
|
|
"-a", $config['active_areas'],
|
|
"-F", $config['colours']['fg'],
|
|
"-B", $config['colours']['bg']
|
|
]
|
|
|
|
puts "Launching lemonbar as: " + lemonbar_cmd.join(" ")
|
|
|
|
trap("SIGINT") { exit 0 }
|
|
trap("SIGUSR1") { $queue << 1 }
|
|
|
|
IO.popen(lemonbar_cmd, "w") do |pipe|
|
|
while true do
|
|
data = $queue.pop
|
|
pipe.puts ERB.new($config['format']).result
|
|
end
|
|
end
|