panel. You could customise colours, refresh rate. It also allows to execute some command on click. After start it puts itself in the docking area on the panel. If session support is enabled, it will restart itself next time user logs in. Pressing righ mouse button shows menu. Pressing left mouse button executes configured command.
59 lines
1.6 KiB
Text
59 lines
1.6 KiB
Text
$NetBSD: patch-ab,v 1.1.1.1 1999/11/06 15:57:41 hubertf Exp $
|
|
|
|
--- klavg.cc.orig Mon Jun 28 08:44:35 1999
|
|
+++ klavg.cc Fri Nov 5 14:38:09 1999
|
|
@@ -33,7 +33,9 @@
|
|
|
|
#include "klavg.h"
|
|
|
|
+#ifdef __linux__
|
|
#define LAVG_FILE "/proc/loadavg"
|
|
+#endif
|
|
|
|
KLavg::KLavg()
|
|
{
|
|
@@ -70,13 +72,13 @@
|
|
KConfig *kconfig = kapp->getConfig();
|
|
|
|
kconfig->setGroup("General");
|
|
- cfg.refresh_rate = kconfig->readNumEntry("RefreshRate",1 );
|
|
- cfg.cmd = kconfig->readEntry("Command" ,"ktop");
|
|
+ cfg.refresh_rate = kconfig->readNumEntry("RefreshRate",5 );
|
|
+ cfg.cmd = kconfig->readEntry("Command" ,"xterm -e top");
|
|
|
|
kconfig->setGroup("Colours");
|
|
- cfg.bg_colour = kconfig->readColorEntry ("Background",&black );
|
|
- cfg.fg_colour = kconfig->readColorEntry ("Foreground",&yellow);
|
|
- cfg.grid_colour = kconfig->readColorEntry ("Grid" ,&red );
|
|
+ cfg.bg_colour = kconfig->readColorEntry ("Background",&gray );
|
|
+ cfg.fg_colour = kconfig->readColorEntry ("Foreground",&black);
|
|
+ cfg.grid_colour = kconfig->readColorEntry ("Grid" ,&cyan );
|
|
}
|
|
|
|
void KLavg::saveCfg()
|
|
@@ -167,6 +169,14 @@
|
|
|
|
float KLavg::getLAVG()
|
|
{
|
|
+#if defined(__NetBSD__)
|
|
+
|
|
+ double res;
|
|
+ getloadavg(&res, 1); // Mmm, abstract OS interfaces :-)
|
|
+ return (float)res;
|
|
+
|
|
+#elif defined(__linux__)
|
|
+
|
|
FILE *f=fopen(LAVG_FILE,"r");
|
|
if(!f)
|
|
return 0.0;
|
|
@@ -177,6 +187,10 @@
|
|
|
|
//fprintf(stderr,"LAVG=%f\n",res);
|
|
return res;
|
|
+
|
|
+#else
|
|
+#error Sorry, no load gathering available.
|
|
+#endif
|
|
}
|
|
|
|
int main(int ac, char **av)
|