diff options
author | Julien Louis <ptitlouis@sysif.net> | 2006-09-16 20:48:42 +0000 |
---|---|---|
committer | Julien Louis <ptitlouis@sysif.net> | 2006-09-16 20:48:42 +0000 |
commit | 0493cb89eb404e4c7c7e31cbeef71606b8461317 (patch) | |
tree | 2109942ea83bd8ec9e8dec272a671e0c283a3802 /scripts/lua | |
parent | cb95bfc8464ef37165ee9d900554a98a87ac68e6 (diff) | |
download | weechat-0493cb89eb404e4c7c7e31cbeef71606b8461317.zip |
Initial import
Diffstat (limited to 'scripts/lua')
-rw-r--r-- | scripts/lua/loadavg.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/lua/loadavg.lua b/scripts/lua/loadavg.lua new file mode 100644 index 000000000..e56e814ff --- /dev/null +++ b/scripts/lua/loadavg.lua @@ -0,0 +1,27 @@ +-- Author: Julien Louis <ptitlouis@sysif.net> +-- License: GPLv2 +-- Description: This lua script prints in the infobar the machine load average +-- +weechat.register("loadavg", "0.1", "unload", "Print the load average in infobar") + +local refresh = weechat.get_config("loadavg_refresh") + +if refresh == "" then + refresh = 5 + weechat.set_config("loadavg_refresh", 5) +end + +weechat.add_timer_handler(refresh, "loadavg") + +function loadavg() + local load = io.open("/proc/loadavg"):read() + load = string.gsub(load, "^([%w.]+) ([%w.]+) ([%w.]+).*", "%1 %2 %3") + weechat.print_infobar(refresh, "load: "..load) + return weechat.PLUGIN_RC_OK; +end + +function unload() + weechat.remove_timer_handler("loadavg") + return weechat.remove_infobar(1) +end + |