#!/usr/bin/perl -w IRC::register("RitBits", "0.1", "", ""); IRC::print "\cC2\cBRitBits loaded!\003 Commands are: /about /gfx /os /desk /cpu /disk /uptime /client"; IRC::add_command_handler("about", "about"); IRC::add_command_handler("gfx", "gfx"); IRC::add_command_handler("os", "os"); IRC::add_command_handler("client", "client"); IRC::add_command_handler("desk", "desk"); IRC::add_command_handler("cpu", "cpu"); IRC::add_command_handler("disk", "disk"); IRC::add_command_handler("ram", "ram"); IRC::add_command_handler("uptime", "uptime"); sub about { IRC::command("\cC2\cBRitBits\cB\003 - A n00b script by Jen, version 0.1 (\cBhttp://caffeinated-dreams.net\cB)"); return 1; } sub gfx { $xorg = `xdpyinfo | grep X.Org"."version`; chop ($xorg); $res = `xdpyinfo | grep dimensions | awk '{print \$2}'`; chop ($res); $vid = `sysctl dev.drm.0.\%desc | cut -d : -f 2`; chop ($vid); @bits = `xwininfo -root`; foreach (@bits) { if (/^ +?Depth: (.+)/i) {$bits = $1;} } IRC::command("(\cC2\ \cB\Graphics\cB\ \003) \cB $vid \cB,\cB\ $xorg \cB\ (\cC2\ \cB\Resolution\cB\ \003) \cB $res \cB (\cC2\ \cB\Bits\cB\ \003) \cB $bits \cB "); return 1; } sub os { $os =`uname -srm`; chop ($os); IRC::command("(\cC2\ \cB\Operating System\cB\ \003) \cB $os \cB"); return 1; } sub desk { $desk =`kde-config -version | grep KDE`; chop ($desk); #TODO Make it detect any desktop... flux, gnome, kde... etc... -.- IRC::command("(\cC2\ \cB\Desktop Environment\cB\ \003) \cB $desk \cB"); return 1; } sub cpu { $model = `sysctl hw.model | cut -d : -f 2`; chop ($model); #TODO Find something that works for BSD! $freq = `cat /proc/cpuinfo | grep 'cpu MHz' | head -1 | sed -e 's/^.*: //'`; chop ($freq); IRC::command("( \cC2\cB\CPU\cB\003 ) \cB $model \cB (\cC2 \cB\Frequency\cB\ \003 ) \cB $freq \cB"."MHz"); return 1; } sub disk { $hdd1 = `df -h | grep /usr | awk '{ print $3"\\"$2 }'`; chop ($hdd1); $hdd2 = `df -h | grep /usr2 | awk '{ print $3"\\"$2 }'`; #Comment out if you don't have a second hard drive; otherwise change /usr2 to wherever the HD is mounted. chop ($hdd2); IRC::command("( \cC2\cB\Hardrives\cB\003 ) \cC2/usr\003: \cB $hdd1 \cB \cC2/usr2\003: \cB $hdd2 \cB"); return 1; } sub uptime { $uptime =`uptime`; chop ($uptime); IRC::command("(\cC2\ \cB\Current Uptime\cB\ \003) \cB $uptime \cB"); return 1; } sub client { $client = IRC::get_info(0); chop ($client); IRC::command("(\cC2\ \cB\IRC Client\cB\ \003) \cB X-Chat $client \cB"); return 1; }