You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
425 lines
12 KiB
425 lines
12 KiB
--- src/aapm.cc.orig Sat Jan 4 01:25:45 2003 |
|
+++ src/aapm.cc Mon Jan 6 19:00:50 2003 |
|
@@ -26,6 +26,13 @@ |
|
#include <string.h> |
|
#include <stdio.h> |
|
|
|
+#ifdef __FreeBSD__ |
|
+#include <sys/file.h> |
|
+#include <sys/ioctl.h> |
|
+#include <sys/types.h> |
|
+#include <machine/apm_bios.h> |
|
+#endif |
|
+ |
|
YColor *YApm::apmBg = 0; |
|
YColor *YApm::apmFg = 0; |
|
YFont *YApm::apmFont = 0; |
|
@@ -47,8 +54,12 @@ |
|
|
|
|
|
void ApmStr(char *s, bool Tool) { |
|
+#ifdef __FreeBSD__ |
|
+ struct apm_info ai; |
|
+#else |
|
char buf[80]; |
|
- int len, i, fd = open("/proc/apm", O_RDONLY); |
|
+#endif |
|
+ int len, i, fd = open(APMDEV, O_RDONLY); |
|
char driver[16]; |
|
char apmver[16]; |
|
int apmflags; |
|
@@ -60,9 +71,27 @@ |
|
char units[16]; |
|
|
|
if (fd == -1) { |
|
+ static int error = 0; |
|
+ if (!error) |
|
+ perror("Can't open the apm device"); |
|
+ error = 1; |
|
return ; |
|
} |
|
- |
|
+#ifdef __FreeBSD__ |
|
+ if (ioctl(fd,APMIO_GETINFO, &ai) == -1) |
|
+ { |
|
+ static int error = 0; |
|
+ if (!error) |
|
+ perror("Can't ioctl the apm device"); |
|
+ error = 1; |
|
+ close(fd); |
|
+ return; |
|
+ } |
|
+ close(fd); |
|
+ BATlife = ai.ai_batt_life; |
|
+ ACstatus = ai.ai_acline ; |
|
+ BATflag = ai.ai_batt_stat == 3 ? 8 : 0; |
|
+#else |
|
len = read(fd, buf, sizeof(buf) - 1); |
|
close(fd); |
|
|
|
@@ -76,10 +105,11 @@ |
|
static int error = 1; |
|
if (error) { |
|
error = 0; |
|
- warn(_("/proc/apm - unknown format (%d)"), i); |
|
+ warn(_("%s - unknown format (%d)"), APMDEV, i); |
|
} |
|
return ; |
|
} |
|
+#endif |
|
if (BATlife == -1) |
|
BATlife = 0; |
|
|
|
--- src/apppstatus.cc.orig Sat Mar 17 00:17:37 2001 |
|
+++ src/apppstatus.cc Thu Apr 5 22:45:29 2001 |
|
@@ -270,6 +270,7 @@ |
|
return isUpIsdn(); |
|
#endif |
|
|
|
+#ifndef __FreeBSD__ |
|
char buffer[32 * sizeof(struct ifreq)]; |
|
struct ifconf ifc; |
|
struct ifreq *ifr; |
|
@@ -301,6 +302,38 @@ |
|
} |
|
|
|
close(s); |
|
+ |
|
+#else // __FreeBSD__ |
|
+ // FreeBSD code by Ronald Klop <ronald@cs.vu.nl> |
|
+ struct ifmibdata ifmd; |
|
+ size_t ifmd_size=sizeof(ifmibdata); |
|
+ int nr_network_devs; |
|
+ size_t int_size=sizeof(int); |
|
+ int name[6]; |
|
+ name[0] = CTL_NET; |
|
+ name[1] = PF_LINK; |
|
+ name[2] = NETLINK_GENERIC; |
|
+ name[3] = IFMIB_IFDATA; |
|
+ name[5] = IFDATA_GENERAL; |
|
+ |
|
+ if(sysctlbyname("net.link.generic.system.ifcount",&nr_network_devs, |
|
+ &int_size,(void*)0,0) == -1) { |
|
+ printf("%s@%d: %s\n",__FILE__,__LINE__,strerror(errno)); |
|
+ } else { |
|
+ for(int i=1;i<=nr_network_devs;i++) { |
|
+ name[4] = i; /* row of the ifmib table */ |
|
+ |
|
+ if(sysctl(name, 6, &ifmd, &ifmd_size, (void *)0, 0) == -1) { |
|
+ printf(_("%s@%d: %s\n"),__FILE__,__LINE__,strerror(errno)); |
|
+ continue; |
|
+ } |
|
+ |
|
+ if (strcmp(ifmd.ifmd_name, netDevice) == 0 && (ifmd.ifmd_flags & IFF_RUNNING)) { |
|
+ return true; |
|
+ } |
|
+ } |
|
+ } |
|
+#endif // __FreeBSD__ |
|
return false; |
|
#endif // if 0 |
|
} |
|
--- src/sysdep.h.orig Tue Oct 9 23:54:03 2001 |
|
+++ src/sysdep.h Wed Feb 20 15:22:43 2002 |
|
@@ -57,7 +57,9 @@ |
|
|
|
#ifdef CONFIG_I18N |
|
#include <locale.h> |
|
+#if __FreeBSD__ >= 5 |
|
#include <langinfo.h> |
|
+#endif |
|
#endif |
|
|
|
#endif |
|
--- src/acpustatus.cc.orig Sun Mar 9 04:37:52 2003 |
|
+++ src/acpustatus.cc Thu Apr 24 05:09:50 2003 |
|
@@ -26,7 +26,16 @@ |
|
|
|
#include "intl.h" |
|
|
|
-#if (defined(linux) || defined(HAVE_KSTAT_H)) |
|
+#if (defined(linux) || defined(HAVE_KSTAT_H) || defined(__FreeBSD__)) |
|
+ |
|
+#ifdef __FreeBSD__ |
|
+#include <fcntl.h> |
|
+#include <kvm.h> |
|
+#include <nlist.h> |
|
+#include <sys/dkstat.h> |
|
+#include <sys/resource.h> |
|
+#include <devstat.h> |
|
+#endif |
|
|
|
#define UPDATE_INTERVAL 500 |
|
|
|
@@ -49,13 +58,42 @@ |
|
color[IWM_SYS] = new YColor(clrCpuSys); |
|
color[IWM_IDLE] = *clrCpuIdle |
|
? new YColor(clrCpuIdle) : NULL; |
|
- |
|
+#ifdef __FreeBSD__ |
|
+ color[IWM_INTR] = new YColor(clrCpuIntr); |
|
+ for (unsigned int i = 0; i < taskBarCPUSamples; i++) { |
|
+ cpu[i][IWM_USER] = cpu[i][IWM_NICE] = |
|
+ cpu[i][IWM_SYS] = cpu[i][IWM_INTR] = 0; |
|
+ cpu[i][IWM_IDLE] = 1; |
|
+ } |
|
+ setSize(taskBarCPUSamples, 20); |
|
+ last_cpu[IWM_USER] = last_cpu[IWM_NICE] = last_cpu[IWM_SYS] = |
|
+ last_cpu[IWM_IDLE] = last_cpu[IWM_INTR] = 0; |
|
+ if( setegid( 2 ) == 0 ) { |
|
+ char errbuf[_POSIX2_LINE_MAX]; |
|
+ kd = kvm_openfiles( NULL, NULL, NULL, O_RDONLY, errbuf ); |
|
+ setegid( getgid() ); |
|
+ if( kd == NULL ) |
|
+ fprintf( stderr, "kvm_openfiles: %s\n", errbuf ); |
|
+ else { |
|
+ memset( namelist, 0, sizeof(namelist) ); |
|
+ namelist[0].n_name = (char*)("_cp_time"); |
|
+ if( kvm_nlist( kd, namelist ) != 0 ) { |
|
+ kvm_close( kd ); |
|
+ kd = NULL; |
|
+ } |
|
+ } |
|
+ } else { |
|
+ fprintf( stderr, "can't setegid(2), I'm not a setgid exec ?\n" ); |
|
+ kd = NULL; |
|
+ } |
|
+#else |
|
for (int i(0); i < taskBarCPUSamples; i++) { |
|
cpu[i][IWM_USER] = cpu[i][IWM_NICE] = cpu[i][IWM_SYS] = 0; |
|
cpu[i][IWM_IDLE] = 1; |
|
} |
|
setSize(taskBarCPUSamples, 20); |
|
last_cpu[IWM_USER] = last_cpu[IWM_NICE] = last_cpu[IWM_SYS] = last_cpu[IWM_IDLE] = 0; |
|
+#endif |
|
getStatus(); |
|
updateStatus(); |
|
updateToolTip(); |
|
@@ -70,6 +108,13 @@ |
|
delete color[IWM_NICE]; color[IWM_NICE] = 0; |
|
delete color[IWM_SYS]; color[IWM_SYS] = 0; |
|
delete color[IWM_IDLE]; color[IWM_IDLE] = 0; |
|
+#ifdef __FreeBSD__ |
|
+ delete color[IWM_INTR]; color[IWM_INTR] = 0; |
|
+ if( kd != NULL ) { |
|
+ kvm_close( kd ); |
|
+ kd = NULL; |
|
+ } |
|
+#endif |
|
} |
|
|
|
void CPUStatus::paint(Graphics &g, const YRect &/*r*/) { |
|
@@ -80,13 +125,34 @@ |
|
int nice = cpu[i][IWM_NICE]; |
|
int sys = cpu[i][IWM_SYS]; |
|
int idle = cpu[i][IWM_IDLE]; |
|
+#ifdef __FreeBSD__ |
|
+ int intr = cpu[i][IWM_INTR]; |
|
+ int total = user + sys + intr + nice + idle; |
|
+ int totald = total; |
|
+#else |
|
int total = user + sys + nice + idle; |
|
+#endif |
|
|
|
int y = height() - 1; |
|
|
|
if (total > 0) { |
|
+#ifdef __FreeBSD__ |
|
+ if (intr) { |
|
+ totald -= intr; |
|
+ n = (h * totald) / total; // check rounding |
|
+ if (n >= y) n = y; |
|
+ g.setColor(color[IWM_INTR]); |
|
+ g.drawLine(i, y, i, n); |
|
+ y = n - 1; |
|
+ } |
|
+#endif |
|
if (sys) { |
|
+#ifdef __FreeBSD__ |
|
+ totald -= nice; |
|
+ n = (h * totald)/ total; |
|
+#else |
|
n = (h * (total - sys)) / total; // check rounding |
|
+#endif |
|
if (n >= y) n = y; |
|
g.setColor(color[IWM_SYS]); |
|
g.drawLine(i, y, i, n); |
|
@@ -102,7 +168,12 @@ |
|
} |
|
|
|
if (user) { |
|
+#ifdef __FreeBSD__ |
|
+ totald -= user; |
|
+ n = (h * totald)/ total; |
|
+#else |
|
n = (h * (total - sys - nice - user))/ total; |
|
+#endif |
|
if (n >= y) n = y; |
|
g.setColor(color[IWM_USER]); |
|
g.drawLine(i, y, i, n); |
|
@@ -152,6 +223,14 @@ |
|
sprintf(load, _("CPU Load: %3.2f %3.2f %3.2f, %d processes."), |
|
l1, l5, l15, sys.procs); |
|
setToolTip(load); |
|
+#elif defined(__FreeBSD__) |
|
+ char load[31]; // enough for "CPU Load: 999.99 999.99 999.99\0" |
|
+ double loadavg[3]; |
|
+ if( kd != NULL && kvm_getloadavg( kd, loadavg, 3 ) != 3 ) |
|
+ return; |
|
+ snprintf(load, sizeof(load), "CPU Load: %3.2f %3.2f %3.2f", |
|
+ loadavg[0], loadavg[1], loadavg[2]); |
|
+ setToolTip(load); |
|
#endif |
|
} |
|
|
|
@@ -169,13 +248,43 @@ |
|
cpu[i - 1][IWM_NICE] = cpu[i][IWM_NICE]; |
|
cpu[i - 1][IWM_SYS] = cpu[i][IWM_SYS]; |
|
cpu[i - 1][IWM_IDLE] = cpu[i][IWM_IDLE]; |
|
+#ifdef __FreeBSD__ |
|
+ cpu[i - 1][IWM_INTR] = cpu[i][IWM_INTR]; |
|
+#endif |
|
} |
|
getStatus(), |
|
repaint(); |
|
} |
|
|
|
void CPUStatus::getStatus() { |
|
-#ifdef linux |
|
+#ifdef __FreeBSD__ |
|
+ |
|
+ cpu[taskBarCPUSamples-1][IWM_USER] = 0; |
|
+ cpu[taskBarCPUSamples-1][IWM_NICE] = 0; |
|
+ cpu[taskBarCPUSamples-1][IWM_SYS] = 0; |
|
+ cpu[taskBarCPUSamples-1][IWM_INTR] = 0; |
|
+ cpu[taskBarCPUSamples-1][IWM_IDLE] = 0; |
|
+ |
|
+ if( kd == NULL ) return; |
|
+ |
|
+ long cp_time[CPUSTATES]; |
|
+ int c = sizeof( cp_time ); |
|
+ if (kvm_read(kd, namelist[0].n_value, &cp_time, c) != c) |
|
+ return; |
|
+ |
|
+ long cur[IWM_STATES]; |
|
+ cur[IWM_USER] = cp_time[CP_USER]; |
|
+ cur[IWM_NICE] = cp_time[CP_NICE]; |
|
+ cur[IWM_SYS] = cp_time[CP_SYS]; |
|
+ cur[IWM_INTR] = cp_time[CP_INTR]; |
|
+ cur[IWM_IDLE] = cp_time[CP_IDLE]; |
|
+ |
|
+ for (int i = 0; i < IWM_STATES; i++) { |
|
+ cpu[taskBarCPUSamples-1][i] = cur[i] - last_cpu[i]; |
|
+ last_cpu[i] = cur[i]; |
|
+ } |
|
+ |
|
+#elif defined(linux) |
|
char *p, buf[128]; |
|
long cur[IWM_STATES]; |
|
int len, fd = open("/proc/stat", O_RDONLY); |
|
@@ -209,8 +318,8 @@ |
|
cpu[taskBarCPUSamples-1][IWM_USER], cpu[taskBarCPUSamples-1][IWM_NICE], |
|
cpu[taskBarCPUSamples-1][IWM_SYS], cpu[taskBarCPUSamples-1][IDLE]); |
|
#endif |
|
-#endif /* linux */ |
|
-#ifdef HAVE_KSTAT_H |
|
+ |
|
+#elif defined(HAVE_KSTAT_H) |
|
#ifdef HAVE_OLD_KSTAT |
|
#define ui32 ul |
|
#endif |
|
--- src/acpustatus.h.orig Sun Mar 9 04:37:52 2003 |
|
+++ src/acpustatus.h Sun Apr 13 12:02:47 2003 |
|
@@ -1,19 +1,29 @@ |
|
#ifndef __CPUSTATUS_H |
|
#define __CPUSTATUS_H |
|
|
|
-#if defined(linux) || defined(HAVE_KSTAT_H) |
|
+#if (defined(linux) || defined(HAVE_KSTAT_H)) || defined (__FreeBSD__) |
|
|
|
#ifdef HAVE_KSTAT_H |
|
#include <kstat.h> |
|
#include <sys/sysinfo.h> |
|
#endif /* have_kstat_h */ |
|
|
|
+#ifdef __FreeBSD__ |
|
+#include <kvm.h> |
|
+#include <nlist.h> |
|
+#endif |
|
|
|
#define IWM_USER (0) |
|
#define IWM_NICE (1) |
|
#define IWM_SYS (2) |
|
+#ifdef __FreeBSD__ |
|
+#define IWM_INTR (3) |
|
+#define IWM_IDLE (4) |
|
+#define IWM_STATES (5) |
|
+#else |
|
#define IWM_IDLE (3) |
|
#define IWM_STATES (4) |
|
+#endif |
|
|
|
#include "ywindow.h" |
|
#include "ytimer.h" |
|
@@ -38,6 +48,10 @@ |
|
long last_cpu[IWM_STATES]; |
|
YColor *color[IWM_STATES]; |
|
YTimer *fUpdateTimer; |
|
+#ifdef __FreeBSD__ |
|
+ struct nlist namelist[2]; |
|
+ kvm_t *kd; |
|
+#endif |
|
}; |
|
#else |
|
#undef CONFIG_APPLET_CPU_STATUS |
|
--- src/default.h.orig Thu May 16 14:00:02 2002 |
|
+++ src/default.h Tue May 28 04:44:02 2002 |
|
@@ -455,6 +455,7 @@ |
|
XSV(const char *, clrLabelText, "rgb:00/00/00") |
|
XSV(const char *, clrCpuUser, "rgb:00/FF/00") |
|
XSV(const char *, clrCpuSys, "rgb:FF/00/00") |
|
+XSV(const char *, clrCpuIntr, "rgb:FF/FF/00") |
|
XSV(const char *, clrCpuNice, "rgb:00/00/FF") |
|
XSV(const char *, clrCpuIdle, "rgb:00/00/00") |
|
XSV(const char *, clrNetSend, "rgb:FF/FF/00") |
|
@@ -837,6 +838,7 @@ |
|
#ifdef CONFIG_APPLET_CPU_STATUS |
|
OSV("ColorCPUStatusUser", &clrCpuUser, "User load on the CPU monitor"), |
|
OSV("ColorCPUStatusSystem", &clrCpuSys, "System load on the CPU monitor"), |
|
+ OSV("ColorCPUStatusInterrupts", &clrCpuIntr, "Interrupts on the CPU monitor"), |
|
OSV("ColorCPUStatusNice", &clrCpuNice, "Nice load on the CPU monitor"), |
|
OSV("ColorCPUStatusIdle", &clrCpuIdle, "Idle (non) load on the CPU monitor, leave empty to force transparency"), |
|
#endif |
|
--- src/wmapp.cc.orig Sun Mar 9 04:37:52 2003 |
|
+++ src/wmapp.cc Sun Apr 13 00:09:19 2003 |
|
@@ -1503,6 +1503,9 @@ |
|
#endif |
|
|
|
int main(int argc, char **argv) { |
|
+#ifdef __FreeBSD__ |
|
+ setegid( getgid() ); |
|
+#endif |
|
YLocale locale; |
|
|
|
#ifndef NO_CONFIGURE |
|
--- src/wmclient.h.orig Tue Mar 26 14:29:05 2002 |
|
+++ src/wmclient.h Tue Mar 26 14:29:13 2002 |
|
@@ -5,6 +5,8 @@ |
|
#include "ymenu.h" |
|
#include "MwmUtil.h" |
|
|
|
+#include <X11/Xutil.h> |
|
+ |
|
class YFrameWindow; |
|
class WindowListItem; |
|
|
|
--- src/icetray.cc.orig 2003-09-30 16:18:18.000000000 +0200 |
|
+++ src/icetray.cc 2003-09-30 16:19:00.000000000 +0200 |
|
@@ -6,6 +6,7 @@ |
|
#include "base.h" |
|
#include "debug.h" |
|
|
|
+#include <stdio.h> |
|
#include <stdlib.h> |
|
#include <string.h> |
|
|
|
|