new modules

This commit is contained in:
Jack L. Frost 2016-09-27 11:13:42 +03:00
parent 1304907829
commit b97d52cce5
5 changed files with 99 additions and 2 deletions

16
mod/bspwm_taskbar Normal file
View File

@ -0,0 +1,16 @@
# vim: ft=ruby
class ModBspwmTaskbar < ModBasic
@@mod_name = 'bspwm_taskbar'
def data_loop()
while true do
IO.popen("xtitle -s -f '%s'").each do |line|
$panel_data[@@mod_name.to_sym] = line.chomp
$queue << 1
end
end
end
end
ModBspwmTaskbar.new.mainloop()

View File

@ -7,7 +7,7 @@ class ModDate < ModBasic
while true do
$panel_data[@@mod_name.to_sym] = Time.now.strftime($config['mod']['date']['format'])
$queue << 1
sleep 1
sleep(1)
end
end
end

26
mod/load_average Normal file
View File

@ -0,0 +1,26 @@
# vim: ft=ruby
class ModLoadAverage < ModBasic
@@mod_name = 'load_average'
def data_loop()
while true do
file = File.open("/proc/loadavg", "r")
la_m = file.gets.split[0]
if la_m.to_i > $config['mod']['load_average']['crit_value']
fg_colour = $config['mod']['load_average']['crit_colour']
elsif la_m.to_i > $config['mod']['load_average']['warn_value']
fg_colour = $config['mod']['load_average']['warn_colour']
else
fg_colour = $config['mod']['load_average']['ok_colour']
end
$panel_data[@@mod_name.to_sym] = "%{F#{fg_colour}}#{la_m}%{F-}"
$queue << 1
sleep(5)
end
end
end
ModLoadAverage.new.mainloop()

41
mod/network Normal file
View File

@ -0,0 +1,41 @@
# vim: ft=ruby
class ModNetwork < ModBasic
@@mod_name = 'network'
def data_loop()
$panel_data[@@mod_name.to_sym] = "checking..."
while true do
$panel_data[@@mod_name.to_sym] = network_status.chomp
$queue << 1
sleep(10)
end
end
def network_status
hosts = $config['mod']['network']['hosts']
net_ok = 0
hosts.each do |h|
if system("ping -c 1 #{h} > /dev/null")
net_ok += 1
end
end
if net_ok == 0
status = "CRIT"
fg_colour = $config['mod']['network']['crit_colour']
elsif net_ok < hosts.length
status = "WARN"
fg_colour = $config['mod']['network']['warn_colour']
else
status = "ok"
fg_colour = $config['mod']['network']['ok_colour']
end
return "%{F#{fg_colour}}#{status}%{F-}"
end
end
ModNetwork.new.mainloop()

16
rc.yaml
View File

@ -4,7 +4,7 @@ geometry: '1902x14+9+9'
fontspec: '-*-terminesspowerline-medium-*-normal-*-14-*-*-*-*-*-iso10646-*'
window_name: 'moltenbar'
active_areas: '128'
format: "<%= $panel_data[:bspwm_pager] %>%{r}%{F<%= $config['colours']['bg_focused'] %>}%{F-}%{B<%= $config['colours']['bg_focused'] %>} <%= $panel_data[:date] %> %{B-}"
format: "<%= $panel_data[:bspwm_pager] %>%{F<%= $config['colours']['bg'] %>}%{B<%= $config['colours']['bg_focused'] %>}%{F-} <%= $panel_data[:bspwm_taskbar] %>%{F<%= $config['colours']['bg_focused'] %>} %{B-} %{r}%{F<%= $config['colours']['bg_focused'] %>}%{F-}%{B<%= $config['colours']['bg_focused'] %>} LA: <%= $panel_data[:load_average] %> Network: <%= $panel_data[:network] %> <%= $panel_data[:date] %> %{B-}"
colours:
fg: '#f9f9f9'
fg_focused: '#f9f9f9'
@ -18,3 +18,17 @@ mod:
-h
date:
format: '%A, %Y.%m.%d %H:%M:%S'
load_average:
warn_value: 3
crit_value: 4
ok_colour: "#00FF00"
warn_colour: "#FFFF00"
crit_colour: "#FF0000"
network:
hosts:
- de-ber-as20647.anchors.atlas.ripe.net
- nl-ams-as1101.anchors.atlas.ripe.net
- uk-boh-as196745.anchors.atlas.ripe.net
ok_colour: "#00FF00"
warn_colour: "#FFFF00"
crit_colour: "#FF0000"