diff --git a/mod/bspwm_taskbar b/mod/bspwm_taskbar new file mode 100644 index 0000000..d95552f --- /dev/null +++ b/mod/bspwm_taskbar @@ -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() diff --git a/mod/date b/mod/date index 883be98..2bf9cce 100644 --- a/mod/date +++ b/mod/date @@ -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 diff --git a/mod/load_average b/mod/load_average new file mode 100644 index 0000000..4e4723b --- /dev/null +++ b/mod/load_average @@ -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() diff --git a/mod/network b/mod/network new file mode 100644 index 0000000..093765c --- /dev/null +++ b/mod/network @@ -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() diff --git a/rc.yaml b/rc.yaml index 26b96dc..e738789 100644 --- a/rc.yaml +++ b/rc.yaml @@ -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"