Skip to content

Commit 749fc81

Browse files
committed
Initial commit
0 parents  commit 749fc81

26 files changed

+3135
-0
lines changed

COPYING

+339
Large diffs are not rendered by default.

Makefile.am

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
if HAVE_XFCE4
2+
XFCE4_DIRS = xfce4
3+
endif
4+
if HAVE_LXPANEL
5+
#LXPANEL_DIRS = lxpanel
6+
endif
7+
SUBDIRS = \
8+
multiload \
9+
$(XFCE4_DIRS) \
10+
$(LXPANEL_DIRS) \
11+
po
12+
13+
distclean-local:
14+
rm -rf *.cache *~
15+
16+
rpm: dist
17+
rpmbuild -ta $(PACKAGE)-$(VERSION).tar.gz
18+
@rm -f $(PACKAGE)-$(VERSION).tar.gz
19+
20+
.PHONY: ChangeLog
21+
22+
ChangeLog: Makefile
23+
(GIT_DIR=$(top_srcdir)/.git git log > .changelog.tmp \
24+
&& mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) \
25+
|| (touch ChangeLog; echo 'Git directory not found: installing possibly empty changelog.' >&2)
26+
27+
dist-hook: ChangeLog
28+
29+
EXTRA_DIST = \
30+
intltool-extract.in \
31+
intltool-merge.in \
32+
intltool-update.in
33+
34+
DISTCLEANFILES = \
35+
intltool-extract \
36+
intltool-merge \
37+
intltool-update
38+
39+
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:

autogen.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# Doesn't work with intltoolize
4+
# autoreconf --force --install || exit 1
5+
6+
set -x
7+
8+
aclocal || exit 1
9+
autoheader --force || exit 1
10+
libtoolize --copy --automake --force || exit 1
11+
intltoolize --copy --automake --force || exit 1
12+
automake --add-missing --copy --include-deps || exit 1
13+
autoconf || exit 1
14+
autoheader || exit 1
15+

configure.ac

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
AC_PREREQ(2.50)
2+
AC_INIT([xfce4-multiload-plugin], [0.1], [nandhp@gmail.com])
3+
AC_CONFIG_AUX_DIR([build-aux])
4+
AM_INIT_AUTOMAKE([1.8 -Wall -Werror dist-bzip2])
5+
# AM_CONFIG_HEADER([config.h])
6+
AM_MAINTAINER_MODE()
7+
8+
LT_PREREQ([2.2.6])
9+
LT_INIT([disable-static])
10+
11+
AC_PROG_CC()
12+
# Compiling sources with per-target flags requires AM_PROG_CC_C_O
13+
AM_PROG_CC_C_O()
14+
AC_PROG_LD()
15+
AC_PROG_INSTALL()
16+
AC_PROG_LIBTOOL()
17+
AC_PROG_INTLTOOL(, [no-xml])
18+
19+
# Environment checks from autoscan
20+
# AC_HEADER_STDC()
21+
# AC_CHECK_HEADERS([stdlib.h unistd.h locale.h stdio.h errno.h time.h string.h \
22+
# math.h sys/types.h sys/wait.h memory.h signal.h sys/prctl.h \
23+
# libintl.h])
24+
# AC_CHECK_FUNCS([bind_textdomain_codeset])
25+
AC_CHECK_HEADERS([fcntl.h libintl.h string.h unistd.h])
26+
AC_CHECK_FUNCS([memset rint strchr])
27+
AC_TYPE_SIZE_T()
28+
29+
# Misc checks
30+
AC_MSG_CHECKING(whether compiler understands -Wall)
31+
old_CFLAGS="$CFLAGS"
32+
CFLAGS="$CFLAGS -Wall"
33+
AC_TRY_COMPILE([],[],
34+
AC_MSG_RESULT(yes),
35+
AC_MSG_RESULT(no)
36+
CFLAGS="$old_CFLAGS")
37+
38+
# I18n
39+
rm -f $srcdir/po/LINGUAS
40+
for po_file in `ls $srcdir/po/*.po | sort`;
41+
do
42+
lang=`echo "$po_file" | sed "s|.*/po/\(.*\)\.po|\1|g"`
43+
echo $lang >> $srcdir/po/LINGUAS
44+
done
45+
46+
GETTEXT_PACKAGE=lxpanel
47+
#AM_GNU_GETTEXT([external])
48+
AM_GNU_GETTEXT_VERSION(0.14.1)
49+
AC_SUBST(GETTEXT_PACKAGE)
50+
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
51+
52+
AM_GLIB_GNU_GETTEXT
53+
54+
# Dependencies
55+
AM_PATH_GTK_2_0([2.10.0],,AC_MSG_ERROR([Gtk+ 2.10.0 or higher required.]))
56+
PKG_CHECK_MODULES(LIBGTOP, [libgtop-2.0 >= 2.11.92])
57+
AC_SUBST(LIBGTOP_CFLAGS)
58+
AC_SUBST(LIBGTOP_LIBS)
59+
60+
# Xfce
61+
AC_ARG_WITH([xfce4], AS_HELP_STRING([--with-xfce4], [Build plugin for xfce4-panel]),
62+
[], [with_xfce4=check])
63+
AS_IF([test "x$with_xfce4" != "xno"], [
64+
pkg_modules="libxfce4ui-1 >= 4.6.0 \
65+
libxfce4util-1.0 >= 4.6.0
66+
libxfce4panel-1.0 >= 4.6.0"
67+
PKG_CHECK_MODULES(XFCE4, [$pkg_modules],
68+
[
69+
AC_DEFINE([HAVE_XFCE4], [1], [Support for xfce4-panel])
70+
with_xfce4=yes
71+
],[
72+
if test "x$with_xfce4" != xcheck; then
73+
AC_MSG_FAILURE(
74+
[--with-xfce4 was given, but test failed])
75+
fi
76+
with_xfce4=no
77+
])
78+
])
79+
AM_CONDITIONAL([HAVE_XFCE4], [test x$with_xfce4 = xyes])
80+
AC_SUBST(XFCE4_CFLAGS)
81+
AC_SUBST(XFCE4_LIBS)
82+
83+
# lxpanel
84+
AC_ARG_WITH([lxpanel], AS_HELP_STRING([--with-lxpanel], [Build plugin for lxpanel]),
85+
[], [with_lxpanel=check])
86+
AS_IF([test "x$with_lxpanel" != "xno"], [
87+
pkg_modules="lxpanel"
88+
PKG_CHECK_MODULES(LXPANEL, [$pkg_modules],
89+
[
90+
AC_DEFINE([HAVE_LXPANEL], [1], [Support for lxpanel])
91+
with_lxpanel=yes
92+
],[
93+
if test "x$with_lxpanel" != xcheck; then
94+
AC_MSG_FAILURE(
95+
[--with-lxpanel was given, but test failed])
96+
fi
97+
with_lxpanel=no
98+
])
99+
])
100+
AM_CONDITIONAL(HAVE_LXPANEL, test x$with_lxpanel = xyes)
101+
AC_SUBST(LXPANEL_CFLAGS)
102+
AC_SUBST(LXPANEL_LIBS)
103+
104+
# Output files
105+
AC_CONFIG_HEADERS([config.h])
106+
AC_CONFIG_FILES([
107+
Makefile
108+
multiload/Makefile
109+
xfce4/Makefile
110+
po/Makefile.in
111+
])
112+
AC_OUTPUT
113+
114+
echo
115+
echo "Build Configuration:"
116+
echo
117+
echo "* xfce4-panel : $with_xfce4"
118+
echo
119+
echo "* lxpanel : $with_lxpanel"
120+
echo

multiload/Makefile.am

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# INCLUDES =
2+
AM_CPPFLAGS = \
3+
-I$(top_srcdir) \
4+
-I$(top_srcdir)/multiload \
5+
-DG_LOG_DOMAIN=\"multiload-core\" \
6+
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
7+
$(PLATFORM_CPPFLAGS)
8+
9+
#
10+
# multiload plugin
11+
#
12+
noinst_LTLIBRARIES = \
13+
multiload-core.la
14+
15+
multiload_core_la_SOURCES = \
16+
multiload.c global.h \
17+
linux-proc.c linux-proc.h \
18+
load-graph.c load-graph.h \
19+
netspeed.c netspeed.h \
20+
autoscaler.c autoscaler.h \
21+
properties.c properties.h
22+
23+
multiload_core_la_CFLAGS = \
24+
$(GTK_CFLAGS) \
25+
$(LIBGTOP_CFLAGS)
26+
27+
multiload_core_la_LDFLAGS = \
28+
-avoid-version \
29+
-module \
30+
-no-undefined \
31+
-export-symbols-regex '^xfce_panel_module_(preinit|init|construct)' \
32+
$(PLATFORM_LDFLAGS)
33+
34+
multiload_core_la_LIBADD = \
35+
$(GTK_LIBS) \
36+
$(LIBGTOP_LIBS)
37+
38+
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:

multiload/autoscaler.c

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <time.h>
2+
#include <glib.h>
3+
4+
#include "autoscaler.h"
5+
6+
/* i wish i could have used C99 initializers instead of writing this function */
7+
void autoscaler_init(AutoScaler *that, unsigned interval, unsigned floor)
8+
{
9+
that->update_interval = interval;
10+
that->floor = floor;
11+
that->max = 0;
12+
that->count = 0;
13+
that->last_update = 0;
14+
that->sum = 0.0f;
15+
that->last_average = 0.0f;
16+
}
17+
18+
19+
unsigned autoscaler_get_max(AutoScaler *that, unsigned current)
20+
{
21+
time_t now;
22+
23+
that->sum += current;
24+
that->count++;
25+
time(&now);
26+
27+
if((float)difftime(now, that->last_update) > that->update_interval)
28+
{
29+
float new_average = that->sum / that->count;
30+
float average;
31+
32+
if(new_average < that->last_average)
33+
average = ((that->last_average * 0.5f) + new_average) / 1.5f;
34+
else
35+
average = new_average;
36+
37+
that->max = average * 1.2f;
38+
39+
that->sum = 0.0f;
40+
that->count = 0;
41+
that->last_update = now;
42+
that->last_average = average;
43+
}
44+
45+
that->max = MAX(that->max, current);
46+
that->max = MAX(that->max, that->floor);
47+
#if 0
48+
printf("%p max = %u, current = %u, last_average = %f\n", that, that->max, current, that->last_average);
49+
#endif
50+
return that->max;
51+
}

multiload/autoscaler.h

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifndef __AUTOSCALER_H__
2+
#define __AUTOSCALER_H__
3+
4+
#include <glib.h>
5+
#include <time.h>
6+
7+
typedef struct _AutoScaler AutoScaler;
8+
9+
struct _AutoScaler
10+
{
11+
/* const */ unsigned update_interval;
12+
/* const */ unsigned floor;
13+
unsigned max;
14+
unsigned count;
15+
time_t last_update;
16+
float sum;
17+
float last_average;
18+
};
19+
20+
21+
G_GNUC_INTERNAL void autoscaler_init(AutoScaler *that, unsigned interval, unsigned floor);
22+
23+
G_GNUC_INTERNAL unsigned autoscaler_get_max(AutoScaler *that, unsigned current);
24+
25+
26+
#endif /* __AUTOSCALER_H__ */

0 commit comments

Comments
 (0)