Add kcube 0.61, another cpu load kicker applet for KDE.

PR:		ports/62535
Submitted by:	Michael Ranner <mranner@inode.at>
Approved by:	arved (mentor)
This commit is contained in:
Markus Brueffer 2004-02-29 23:28:23 +00:00
parent c10d036994
commit 4e7bd06dec
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=102582
8 changed files with 166 additions and 0 deletions

View File

@ -167,6 +167,7 @@
SUBDIR += jdiskreport
SUBDIR += k3b
SUBDIR += kcpuload
SUBDIR += kcube
SUBDIR += kdeadmin3
SUBDIR += kdirstat
SUBDIR += kkbswitch

28
sysutils/kcube/Makefile Normal file
View File

@ -0,0 +1,28 @@
# New ports collection makefile for: kcube
# Date created: 05 January 2004
# Whom: Michael Ranner
#
# $FreeBSD$
#
PORTNAME= kcube
PORTVERSION= 0.61
CATEGORIES= sysutils kde
MASTER_SITES= http://www.tuxed.de/kcube/download/
MAINTAINER= mranner@inode.at
COMMENT= Another cpu load kicker applet for KDE
USE_KDELIBS_VER=3
GNU_CONFIGURE= yes
USE_GMAKE= yes
USE_REINPLACE= yes
USE_LIBTOOL= yes
INSTALLS_SHLIB= yes
post-patch:
@${REINPLACE_CMD} -e 's|-O2||g' ${WRKSRC}/${CONFIGURE_SCRIPT}
.include <bsd.port.pre.mk>
.include "${PORTSDIR}/x11/kde3/Makefile.kde"
.include <bsd.port.post.mk>

1
sysutils/kcube/distinfo Normal file
View File

@ -0,0 +1 @@
MD5 (kcube-0.61.tar.gz) = 98735371ce2e3838cc498c35a47488e4

View File

@ -0,0 +1,11 @@
--- configure.orig Wed Feb 25 17:47:43 2004
+++ configure Wed Feb 25 17:50:20 2004
@@ -22088,7 +22088,7 @@
kde_styledir='\${libdir}/kde3/plugins/styles'
fi
if test -z "$kde_widgetdir"; then
- kde_widgetdir='\${libdir}/kde3/plugins/designer'
+ kde_widgetdir='\${kde_libraries}/kde3/plugins/designer'
fi

View File

@ -0,0 +1,93 @@
--- kcube/kcube.cpp.orig Thu Feb 13 22:12:49 2003
+++ kcube/kcube.cpp Wed Feb 25 03:59:17 2004
@@ -33,9 +33,19 @@
#include <qslider.h>
#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <nlist.h>
#include "kcube.h"
+struct nlist nl[] = {
+#define X_CP_TIME 0
+ { "_cp_time" },
+ { "" },
+};
+
extern "C"
{
KPanelApplet* init( QWidget *parent, const QString configFile)
@@ -64,7 +74,7 @@
// timer
cpu_timer = new QTimer();
- cpu_timer->start(500, false);
+ cpu_timer->start(1000, false);
connect (cpu_timer, SIGNAL ( timeout() ), this, SLOT ( cpu_timer_event() ) );
draw_timer = new QTimer();
draw_timer->start(50, false);
@@ -82,6 +92,7 @@
prefform = new PrefForm(this);
prefform->setFixedSize( prefform->width(), prefform->height() );
loadConfig();
+
}
Kcube::~Kcube()
@@ -119,14 +130,42 @@
int Kcube::calc_cpu_total()
{
int use_nice = 0, t=0;
- int total, used;
+ long total, used;
char cpuid[6];
- int cpu,nice,system,idle;
+ long cpu,nice,system,idle;
+#ifdef Q_OS_BSD4
+ static int name2oid[2] = { 0, 3 };
+ static int oidCpuTime[CTL_MAXNAME + 2];
+ static size_t oidCpuTimeLen = sizeof(oidCpuTime);
+ long cpuTime[CPUSTATES];
+ size_t cpuTimeLen = sizeof(cpuTime);
+ static char *name = "kern.cp_time";
+ static int initialized = 0;
+#endif
+#ifdef Q_OS_LINUX
FILE *fp;
fp = fopen("/proc/stat","rt");
fscanf(fp,"%s %d %d %d %d",cpuid,&cpu,&nice,&system,&idle);
fclose(fp);
+#endif
+
+#ifdef Q_OS_BSD4
+ if (! initialized) {
+ if (sysctl(name2oid, 2, oidCpuTime, &oidCpuTimeLen, name, strlen(name)) < 0)
+ return 0;
+ oidCpuTimeLen /= sizeof(int);
+ initialized = 1;
+ }
+
+ if (sysctl(oidCpuTime, oidCpuTimeLen, cpuTime, &cpuTimeLen, 0, 0) < 0)
+ return 0;
+
+ idle = cpuTime[CP_IDLE];
+ cpu = cpuTime[CP_USER];
+ nice = cpuTime[CP_NICE];
+ system = cpuTime[CP_SYS];
+#endif
used = cpu + system + nice;
total = used + idle + (1-use_nice)*nice;
@@ -148,7 +187,7 @@
if ( load > prefform->high_color_cpu->text().toInt() ) setColors("high");
else setColors("low");
- draw_timer->changeInterval( 51 - load/2 );
+ draw_timer->changeInterval( 61 - load/2 );
label_load->setText( QString("%1%").arg(load) );
}

View File

@ -0,0 +1,21 @@
--- kcube/kcube.h.orig Thu Feb 13 19:25:29 2003
+++ kcube/kcube.h Wed Feb 25 03:59:17 2004
@@ -37,6 +37,18 @@
#include "PrefForm.h"
+#ifdef Q_OS_BSD4
+#include <sys/param.h>
+#if defined(__FreeBSD__) && __FreeBSD_version >= 500101
+#include <sys/resource.h>
+#else
+#include <sys/dkstat.h>
+#endif
+#include <sys/sysctl.h>
+#include <string.h>
+#include <kvm.h>
+#endif
+
class Kcube : public KPanelApplet
{
Q_OBJECT

5
sysutils/kcube/pkg-descr Normal file
View File

@ -0,0 +1,5 @@
Kcube is a kicker-application that displays a realtime rotating
3d-object and the current cpu-load. The cpu-load also makes the
object spin faster/slower.
WWW: http://www.tuxed.de/kcube/

6
sysutils/kcube/pkg-plist Normal file
View File

@ -0,0 +1,6 @@
lib/libkcube.la
lib/libkcube.so
lib/libkcube.so.1
share/apps/kicker/applets/kcube.desktop
@unexec rmdir %D/share/apps/kicker/applets 2>/dev/null || true