好吧 終於我也投奔到kde了
Tag Archives: linux
Sysinfo plugin for xchat2 on linux
It’s my first time writing something in perl, the code is not very efficient and for now it can only display info of cpu, memory, bandwidth and uptime.
# Configuration
$eth = "eth0";
# Script
Xchat::register("Sysinfo", "0.1", "System Information Displayer");
Xchat::print("Sysinfo 0.1 Loaded.");
Xchat::hook_command("uptime", "uptime");
Xchat::hook_command("os", "os");
Xchat::hook_command("bw", "bw");
Xchat::hook_command("cpu", "cpu");
Xchat::hook_command("mem", "mem");
sub uptime {
$uptime = `cat /proc/uptime | awk '{printf \$1}'`;
$_day = 60 * 60 * 24;
$_hour = 60 * 60;
$_minute = 60;
$day = int($uptime/$_day);
$uptime %= $_day;
$hour = int($uptime/$_hour);
$uptime %= $_hour;
$minute = int($uptime/$_minute);
$uptime %= $_minute;
$second = int($uptime);
$uptime = "";
if($day != 0) {
$uptime .= $day;
if($day == 1) {
$uptime .= " day ";
} else {
$uptime .= " days ";
}
}
if($hour != 0) {
$uptime .= $hour;
if($hour == 1) {
$uptime .= " hour ";
} else {
$uptime .= " hours ";
}
}
if($minute != 0) {
$uptime .= $minute;
if($minute == 1) {
$uptime .= " minute ";
} else {
$uptime .= " minutes ";
}
}
$uptime .= $second;
if($second == 1) {
$uptime .= " second";
} else {
$uptime .= " seconds";
}
Xchat::command("SAY \002[UPTIME]\002 $uptime");
Xchat::EAT_ALL;
}
sub os {
$_kernel_release = `uname -r`;
$_operating_system = `uname -o`;
chomp($_kernel_release);
chomp($_operating_system);
$os = $_operating_system . " " . $_kernel_release;
Xchat::command("SAY \002[OS]\002 $os");
Xchat::EAT_ALL;
}
sub bw {
$old = `cat /proc/net/dev | grep $eth | cut -d ":" -f 2 | tr -s " "| cut -d " " -f 1,9`;
sleep(1);
$new = `cat /proc/net/dev | grep $eth | cut -d ":" -f 2 | tr -s " "| cut -d " " -f 1,9`;
@ary_old = split(/\s/, $old);
@ary_new = split(/\s/, $new);
$down = $ary_new[0] - $ary_old[0];
$up = $ary_new[1] - $ary_old[1];
$bw = "";
if($down < 1000) {
$bw .= $down . " B/s Down ";
} else {
$bw .= sprintf("%.02f", $down / 1000) . " KB/s Down ";
}
if($up < 1000) {
$bw .= $up . " B/s Up";
} else {
$bw .= sprintf("%.02f", $up / 1000) . " KB/s Up";
}
Xchat::command("SAY \002[BW]\002 $bw");
Xchat::EAT_ALL;
}
sub cpu {
$model_name = `cat /proc/cpuinfo | grep "model name" | tail -1 | cut -d ":" -f 2 | tr -s " "`;
$number_cores = `cat /proc/cpuinfo | grep "model name" -c`;
$freq = `cat /proc/cpuinfo | grep "cpu MHz" | tail -1 | cut -d ":" -f 2 | tr -s " "`;
$idle = `vmstat | tail -1 | awk '{printf \$15}'`;
$load = 100 - $idle;
chomp($model_name);
chomp($number_cores);
chomp($freq);
$cpuinfo = $number_cores . " CPU";
if($number_cores > 1) {
$cpuinfo .= "'s";
}
$cpuinfo .= " -" . $model_name;
$cpuinfo .= " @ " . int($freq) . " MHz" . " (" . $load . "% Load)";
Xchat::command("SAY \002[CPU]\002 $cpuinfo");
Xchat:EAT_ALL;
}
sub mem {
$mem_total = `free -m | grep Mem | awk '{printf \$2}'`;
$mem_used = `free -m | grep - | awk '{printf \$3}'`;
$swap_total = `free -m| grep Swap | awk '{printf \$2}'`;
$swap_used = `free -m| grep Swap | awk '{printf \$3}'`;
$meminfo = "\002[MEM]\002 " . $mem_used . "/" . $mem_total . " MB \002[SWAP]\002 " . $swap_used . "/" . $swap_total . " MB";
Xchat::command("SAY $meminfo");
Xchat::EAT_ALL;
}
Get rid of unwanted output from bash command
I used to redirect the output to /dev/null, but sometimes it’s not good enough. It’s much better to just turn off stdout and stderr.
$ command 1>&- 2>&- &
msn-pecan 0.0.17
I am so sick of the msn plugin that comes with pidgin, it takes years to login every time
with msn-pecan the login process took me less than 1sec, which IMO is much better.
you can grab the debian installer package here if you are using 64bits linux and don’t feel like to compile it yourself
msn-pecan_0.0.17-21-g83bf5f4-1_amd64.deb (104.0 KiB, 400 hits)
Yasm 0.7.2
compiled from official stable tarball
yasm_0.7.2-1_i386.deb (1.2 MiB, 1,260 hits)
x264 svn20081031
x264_10.svn20081031-1_i386.deb (749.1 KiB, 483 hits)
KMess 2.0alpha svn3689
It’s been a while since the last build, coz I was pretty occupied by a lot of things lately
Last Changed Rev: 3689
Last Changed Date: 2008-09-05 02:03:39 +0200 (Fri, 05 Sep 2008)
kmess_2.0alpha-3_i386.deb (3.4 MiB, 1,003 hits)
stunnel 4.25 deb package
stunnel_94.25-1_i386.deb (198.6 KiB, 480 hits)
I just don’t understand why nobody is updating the debian repository :/
nylon 1.21 deb package
nylon_1.21-1_i386.deb (18.7 KiB, 417 hits)
a lightweight but powerful enough to use socks proxy
xvid 1.1.3 stable for debian based linux
libxvidcore_1.1.3-1_i386.deb (465.9 KiB, 513 hits)
it’s just for archiving so that i won’t have to compile it again next time when i have to reinstall the system.

