Fuck erb
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
32a0422f7f
commit
8544bb8cd4
|
@ -9,8 +9,7 @@ class BspwmTaskbar < Worker
|
|||
if line == ""
|
||||
self.write ""
|
||||
else
|
||||
tmpl = Template.new(@my_config['begin'] + line + @my_config['end'])
|
||||
self.write tmpl.render(@config, nil)
|
||||
self.write @my_config['begin'] + line + @my_config['end']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,9 +11,9 @@ class ModMemory < Worker
|
|||
|
||||
used_part = 100 - (mem["MemAvailable:"]/(mem["MemTotal:"]/100))
|
||||
|
||||
if used_part < @my_config['crit_value']
|
||||
if used_part > @my_config['crit_value']
|
||||
fg_colour = @my_config['crit_colour']
|
||||
elsif used_part < @my_config['warn_value']
|
||||
elsif used_part > @my_config['warn_value']
|
||||
fg_colour = @my_config['warn_colour']
|
||||
else
|
||||
fg_colour = @my_config['ok_colour']
|
||||
|
|
24
moltenbar
24
moltenbar
|
@ -81,16 +81,21 @@ module Modules
|
|||
end
|
||||
end
|
||||
|
||||
class Template
|
||||
class Panel
|
||||
attr_accessor :modData
|
||||
|
||||
def initialize(template)
|
||||
@modData = {}
|
||||
@template = template
|
||||
end
|
||||
|
||||
def render(config, data)
|
||||
@config = config
|
||||
@panel_data = data
|
||||
def render
|
||||
panel = @template
|
||||
@modData.each do |modName, modData|
|
||||
panel = panel.gsub(/@{#{modName}}/, modData)
|
||||
end
|
||||
|
||||
return ERB.new(@template).result(binding())
|
||||
return panel
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -107,7 +112,6 @@ def get_x_dims()
|
|||
return `xrandr`.scan(/current (\d+) x (\d+)/).flatten
|
||||
end
|
||||
|
||||
require 'erb'
|
||||
require 'yaml'
|
||||
require 'optparse'
|
||||
|
||||
|
@ -182,6 +186,7 @@ lemonbar_cmd = [
|
|||
|
||||
printf("Launching lemonbar as:\n %s\n", lemonbar_cmd.join(" "))
|
||||
|
||||
p = Panel.new(config['format'])
|
||||
IO.popen(lemonbar_cmd, "w+") do |pipe_lb|
|
||||
pipe_lb.sync = true
|
||||
|
||||
|
@ -189,9 +194,8 @@ IO.popen(lemonbar_cmd, "w+") do |pipe_lb|
|
|||
|
||||
pipe_r.each do |line|
|
||||
mod_name, data = line.chomp.split("\0")
|
||||
panel_data[mod_name] = data
|
||||
|
||||
t = Template.new(config['format'])
|
||||
pipe_lb.printf("%s\n", t.render(config, panel_data))
|
||||
data ||= ""
|
||||
p.modData[mod_name] = data
|
||||
pipe_lb.printf("%s\n", p.render())
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ modules:
|
|||
- load_average
|
||||
- network
|
||||
- memory
|
||||
format: "<%= @panel_data['bspwm_pager'] %><%= @panel_data['bspwm_taskbar'] %>%{r}%{F<%= @config['colours']['bg_focused'] %>} %{F-}%{B<%= @config['colours']['bg_focused'] %>} LA: <%= @panel_data['load_average'] %> Mem (used): <%= @panel_data['memory'] %>% Internet: <%= @panel_data['network'] %> Warp: <%= @panel_data['warp'] %> <%= @panel_data['date'] %> %{B-}"
|
||||
format: "@{bspwm_pager}@{bspwm_taskbar}%{r}%{F#467EC2} %{F-}%{B#467EC2} LA: @{load_average} Mem (used): @{memory} Internet: @{network} Warp: @{warp} XNT: @{xnt} @{date} %{B-}"
|
||||
colours:
|
||||
fg: '#f9f9f9'
|
||||
fg_focused: '#f9f9f9'
|
||||
|
@ -30,10 +30,11 @@ mod:
|
|||
#monitors:
|
||||
# - "main"
|
||||
blacklist:
|
||||
-h
|
||||
-0
|
||||
-p
|
||||
bspwm_taskbar:
|
||||
begin: "%{F<%= @config['colours']['bg'] %>}%{B<%= @config['colours']['bg_focused'] %>}%{F-} "
|
||||
end: "%{F<%= @config['colours']['bg_focused'] %>} %{B-} "
|
||||
begin: "%{F#001f1f1f}%{B#467EC2}%{F-} "
|
||||
end: "%{F#467EC2} %{B-} "
|
||||
date:
|
||||
format: '%A, %Y.%m.%d %H:%M:%S'
|
||||
load_average:
|
||||
|
@ -70,5 +71,5 @@ mod:
|
|||
ok_colour: "#00FF00"
|
||||
warn_colour: "#FFFF00"
|
||||
crit_colour: "#FF0000"
|
||||
warn_value: 25
|
||||
crit_value: 10
|
||||
warn_value: 75
|
||||
crit_value: 90
|
||||
|
|
Loading…
Reference in New Issue
Block a user