diff --git a/homedir/.config/moltenbar/mod/bspwm_pager b/homedir/.config/moltenbar/mod/bspwm_pager new file mode 120000 index 0000000..cd36461 --- /dev/null +++ b/homedir/.config/moltenbar/mod/bspwm_pager @@ -0,0 +1 @@ +/home/fbt/git/moltenbar/mod/bspwm_pager \ No newline at end of file diff --git a/homedir/.config/moltenbar/mod/bspwm_taskbar b/homedir/.config/moltenbar/mod/bspwm_taskbar new file mode 120000 index 0000000..6a685f7 --- /dev/null +++ b/homedir/.config/moltenbar/mod/bspwm_taskbar @@ -0,0 +1 @@ +/home/fbt/git/moltenbar/mod/bspwm_taskbar \ No newline at end of file diff --git a/homedir/.config/moltenbar/mod/date b/homedir/.config/moltenbar/mod/date new file mode 120000 index 0000000..e7374c9 --- /dev/null +++ b/homedir/.config/moltenbar/mod/date @@ -0,0 +1 @@ +/home/fbt/git/moltenbar/mod/date \ No newline at end of file diff --git a/homedir/.config/moltenbar/mod/load_average b/homedir/.config/moltenbar/mod/load_average new file mode 120000 index 0000000..2aa647a --- /dev/null +++ b/homedir/.config/moltenbar/mod/load_average @@ -0,0 +1 @@ +/home/fbt/git/moltenbar/mod/load_average \ No newline at end of file diff --git a/homedir/.config/moltenbar/mod/memory b/homedir/.config/moltenbar/mod/memory new file mode 120000 index 0000000..9c5be2a --- /dev/null +++ b/homedir/.config/moltenbar/mod/memory @@ -0,0 +1 @@ +/home/fbt/git/moltenbar/mod/memory \ No newline at end of file diff --git a/homedir/.config/moltenbar/mod/network b/homedir/.config/moltenbar/mod/network new file mode 100644 index 0000000..53cfa11 --- /dev/null +++ b/homedir/.config/moltenbar/mod/network @@ -0,0 +1,39 @@ +# vim: ft=ruby + +class Network < Worker + require 'open3' + + def mainloop() + self.write "checking..." + + while true do + self.write network_status + sleep(10) + end + end + + def network_status + hosts = @my_config['hosts'] + + net_fail = 0 + Open3.popen2("fping", "-u", *hosts) do |i,o,t| + hosts_down = o.each_line.count + hosts_up = hosts.count - hosts_down + + if hosts_down == 0 + fg_colour = @my_config['ok_colour'] + elsif hosts_down == hosts.count + fg_colour = @my_config['crit_colour'] + else + fg_colour = @my_config['warn_colour'] + end + + @rstr = "%%{F%s}%s/%s%%{F-}" % [ fg_colour, hosts_up, hosts.count ] + end + + return @rstr + end +end + +Modules.add("network", "Network") +Modules.add("warp", "Network")