# # Copyright (c) 2008 by FlashCode # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Display uptime in a bar. # # History: # 2009-05-10, FlashCode : # version 0.1-dev-20090510: sync with last API changes # 2008-07-10, FlashCode : # version 0.1-dev-20080923: development snapshot use strict; my $version = "0.1-dev-20090510"; sub build_uptime { my $uptime = `uptime`; $uptime =~ s/\n//; return weechat::color(weechat::config_string(weechat::config_get("weechat.color.status_delimiters")))."[" .weechat::color(weechat::config_string(weechat::config_get("weechat.color.status")))."Uptime:".$uptime .weechat::color(weechat::config_string(weechat::config_get("weechat.color.status_delimiters")))."]"; } sub my_timer { weechat::bar_item_update("uptime"); return weechat::WEECHAT_RC_OK; } weechat::register("uptime", "FlashCode ", $version, "GPL", "Uptime demo bar for WeeChat 0.2.7, enjoy!", "", ""); weechat::bar_item_new("uptime", "build_uptime", ""); weechat::bar_new("uptime", "0", "0", "root", "", "bottom", "horizontal", "vertical", "1", "0", weechat::config_string(weechat::config_get("weechat.color.status")), weechat::config_string(weechat::config_get("weechat.color.status_delimiters")), weechat::config_string(weechat::config_get("weechat.color.status_bg")), "0", "uptime"); weechat::hook_timer(1000, 1, 0, "my_timer", "");