From c7443642859ab3aa4f13aa2b19c25bec7fe82b88 Mon Sep 17 00:00:00 2001 From: fbt Date: Tue, 11 Oct 2016 04:54:00 +0300 Subject: [PATCH] style fix Signed-off-by: fbt --- moltenbar | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/moltenbar b/moltenbar index 73d94d7..9c98be4 100755 --- a/moltenbar +++ b/moltenbar @@ -37,16 +37,16 @@ class Worker def kill() begin if Process.getpgid(@wpid) == Process.getpgid($$) - puts "Killing pid: #{@wpid}" + printf("Killing pid: %s\n", @wpid) Process.kill("HUP", @wpid) end rescue Errno::ESRCH => err - puts "#{err}: #{@wpid}" + printf("%s: %s\n", err, @wpid) end end def write(data) - @pipe_in.puts @name + "\0" + data + @pipe_in.printf("%s\0%s\n", @name, data) end end @@ -70,7 +70,7 @@ module Modules @modules[name] = class_name end - def self.get + def self.get() return @modules end end @@ -97,7 +97,7 @@ def cleanup(workers) exit(0) end -def get_x_dims +def get_x_dims() return `xrandr`.scan(/current (\d+) x (\d+)/).flatten end @@ -115,6 +115,11 @@ OptionParser.new do |opts| opts.on("-cCONFIG_PATH", "--config=CONFIG_PATH", "Specify and alternative config location") do |v| options[:config_file] = v end + + opts.on("-h", "--help", "Show this message") do + printf("%s", opts) + exit(0) + end end.parse! if ENV["XDG_CONFIG_HOME"] == nil @@ -156,7 +161,7 @@ if config['geometry'] == nil config['width'] = y.to_i - (gap * 2) end - config['geometry'] = "#{config['width']}x#{config['height']}+#{gap}+#{gap}" + config['geometry'] = sprintf("%sx%s+%s+%s", config['width'], config['height'], gap, gap) end lemonbar_cmd = [ @@ -169,7 +174,7 @@ lemonbar_cmd = [ "-B", config['colours']['bg'] ] -puts "Launching lemonbar as: " + lemonbar_cmd.join(" ") +printf("Launching lemonbar as:\n %s\n", lemonbar_cmd.join(" ")) IO.popen(lemonbar_cmd, "w+") do |pipe_lb| pipe_lb.sync = true @@ -183,6 +188,6 @@ IO.popen(lemonbar_cmd, "w+") do |pipe_lb| panel_data[mod_name] = data t = Template.new(config['format']) - pipe_lb.puts t.render(config, panel_data) + pipe_lb.printf("%s\n", t.render(config, panel_data)) end end