mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-24 11:55:43 +00:00
Conky 1.5.0 -- client/server prototype
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@818 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
c42fe7b6ab
commit
1c35f432e5
25
ChangeLog
25
ChangeLog
@ -1,5 +1,30 @@
|
||||
# $Id$
|
||||
|
||||
2006-12-22
|
||||
* client/server infrastructure and prototype for linux only (so far):
|
||||
- requires libdexter (http://sourceforge.net/projects/libdexter)
|
||||
and the dxt-sysinfo plugin (svn only at the moment).
|
||||
* new config items:
|
||||
- dexter_client yes/no
|
||||
- dexter_server yes/no
|
||||
- dexter_config /path/to/libdexter/config (default: $HOME/.dexterrc)
|
||||
- own_window_class <WM Class Name> (default: Conky)
|
||||
- replaces wm_class_name
|
||||
- own_window_title <Window Title> (default: <hostname> - conky)
|
||||
* removed config items:
|
||||
- wm_class_name (use own_window_class, same function)
|
||||
* configure changes:
|
||||
--disable-network (default=yes) with auto-detection for libdexter.
|
||||
- remove useless --enable-proc-uptime (PROC_UPTIME never referenced).
|
||||
HAVE_SYSINFO and others determine if /proc/uptime is used.
|
||||
- silently disable xft, double-buffer and xdamage if no x11.
|
||||
- change enable/disable labels to reflect defaults accurately.
|
||||
- simplified compile-based checks for sysinfo/getloadavg and by moving
|
||||
them into AC_CHECK_FUNCS.
|
||||
* allow decorated, own_window=yes windows to be given input focus by WM:
|
||||
- do not pass button clicks through to desktop in this scenario as conky
|
||||
immediately loses focus.
|
||||
|
||||
2006-12-13
|
||||
* Clarify LGPL license on timed_thread modules.
|
||||
* Update NEWS files.
|
||||
|
58
README
58
README
@ -43,10 +43,10 @@ COMPILING
|
||||
|
||||
./configure --prefix=/usr --mandir=/usr/share/man --in-
|
||||
fodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --local-
|
||||
statedir=/var/lib --enable-xft --enable-own-window --enable-proc-uptime
|
||||
--enable-audacious --enable-bmpx --enable-hddtemp --enable-mpd --en-
|
||||
able-xmms2 --enable-imlib2 --enable-portmon --enable-debug --en-
|
||||
able-double-buffer --enable-xdamage --enable-x11
|
||||
statedir=/var/lib --disable-own-window --enable-audacious --enable-bmpx
|
||||
--disable-hddtemp --disable-mpd --enable-xmms2 --disable-portmon --dis-
|
||||
able-network --enable-debug --disable-x11 --disable-double-buffer
|
||||
--disable-xdamage --disable-xft
|
||||
|
||||
make
|
||||
|
||||
@ -176,6 +176,20 @@ CONFIGURATION SETTINGS
|
||||
Default shading color and border's shading color
|
||||
|
||||
|
||||
dexter_client
|
||||
Act as client and connect to libdexter server for remote moni-
|
||||
toring?
|
||||
|
||||
|
||||
dexter_config
|
||||
Full path to libdexter configuration file (default search order:
|
||||
$HOME/.dexterrc; /etc/libdexter/dexter.conf)
|
||||
|
||||
|
||||
dexter_server
|
||||
Act as server for libdexter services?
|
||||
|
||||
|
||||
double_buffer
|
||||
Use the Xdbe extension? (eliminates flicker) It is highly recom-
|
||||
mended to use own window with this one so double buffer won't be
|
||||
@ -271,18 +285,8 @@ CONFIGURATION SETTINGS
|
||||
Boolean, create own window to draw?
|
||||
|
||||
|
||||
own_window_transparent
|
||||
Boolean, set pseudo-transparency?
|
||||
|
||||
|
||||
own_window_type
|
||||
if own_window is yes, you may specify type normal, desktop or
|
||||
override (default: normal). Desktop windows are special windows
|
||||
that have no window decorations; are always visible on your
|
||||
desktop; do not appear in your pager or taskbar; and are sticky
|
||||
across all workspaces. Override windows are not under the con-
|
||||
trol of the window manager. Hints are ignored. This type of win-
|
||||
dow can be useful for certain situations.
|
||||
own_window_class
|
||||
Manually set the WM_CLASS name. Defaults to "Conky".
|
||||
|
||||
|
||||
own_window_colour colour
|
||||
@ -299,6 +303,24 @@ CONFIGURATION SETTINGS
|
||||
no meaning and are ignored.
|
||||
|
||||
|
||||
own_window_title
|
||||
Manually set the window name. Defaults to "<hostname> - conky".
|
||||
|
||||
|
||||
own_window_transparent
|
||||
Boolean, set pseudo-transparency?
|
||||
|
||||
|
||||
own_window_type
|
||||
if own_window is yes, you may specify type normal, desktop or
|
||||
override (default: normal). Desktop windows are special windows
|
||||
that have no window decorations; are always visible on your
|
||||
desktop; do not appear in your pager or taskbar; and are sticky
|
||||
across all workspaces. Override windows are not under the con-
|
||||
trol of the window manager. Hints are ignored. This type of win-
|
||||
dow can be useful for certain situations.
|
||||
|
||||
|
||||
out_to_console
|
||||
Print text to stdout.
|
||||
|
||||
@ -340,10 +362,6 @@ CONFIGURATION SETTINGS
|
||||
Use Xft (anti-aliased font and stuff)
|
||||
|
||||
|
||||
wm_class_name
|
||||
Manually set the WM_CLASS name. Defaults to "conky".
|
||||
|
||||
|
||||
xftalpha
|
||||
Alpha of Xft font. Must be a value at or between 1 and 0.
|
||||
|
||||
|
@ -11,7 +11,7 @@ HOMEPAGE="http://conky.sf.net"
|
||||
LICENSE="BSD"
|
||||
SLOT="0"
|
||||
KEYWORDS="~alpha ~amd64 ~ppc ~ppc64 ~sparc ~x86"
|
||||
IUSE="truetype X ipv6 audacious bmpx hddtemp mpd vim-syntax"
|
||||
IUSE="truetype X ipv6 audacious bmpx hddtemp mpd network vim-syntax"
|
||||
|
||||
DEPEND_COMMON="
|
||||
virtual/libc
|
||||
@ -31,6 +31,9 @@ DEPEND_COMMON="
|
||||
bmpx? ( media-sound/bmpx
|
||||
>=sys-apps/dbus-0.35
|
||||
)
|
||||
network? ( net-libs/libdexter
|
||||
net-libs/dxt-plugins-sysinfo
|
||||
)
|
||||
!ipv6? ( >=dev-libs/glib-2.0 )
|
||||
)"
|
||||
|
||||
@ -66,7 +69,7 @@ src_compile() {
|
||||
mymake="MPD_NO_IPV6=noipv6"
|
||||
fi
|
||||
local myconf
|
||||
myconf="--enable-own-window --enable-proc-uptime"
|
||||
myconf="--enable-own-window"
|
||||
use X && myconf="${myconf} --enable-x11 --enable-double-buffer --enable-xdamage"
|
||||
econf \
|
||||
${myconf} \
|
||||
@ -74,6 +77,7 @@ src_compile() {
|
||||
$(use_enable audacious) \
|
||||
$(use_enable bmpx) \
|
||||
$(use_enable hddtemp ) \
|
||||
$(use_enable network ) \
|
||||
$(use_enable mpd) \
|
||||
$(use_enable !ipv6 portmon) || die "econf failed"
|
||||
emake ${mymake} || die "compile failed"
|
||||
|
@ -23,5 +23,5 @@ sed -e "s/@REVISION@/${revision}/g" \
|
||||
echo Running $ACLOCAL ... && $ACLOCAL
|
||||
echo Running $LIBTOOLIZE --force ... && $LIBTOOLIZE --force
|
||||
echo Running $AUTOHEADER ... && $AUTOHEADER
|
||||
echo Running $AUTOMAKE -a ... && $AUTOMAKE -a
|
||||
echo Running $AUTOMAKE --add-missing ... && $AUTOMAKE --add-missing
|
||||
echo Running $AUTOCONF ... && $AUTOCONF
|
||||
|
140
configure.ac.in
140
configure.ac.in
@ -2,8 +2,8 @@ dnl $Id$
|
||||
|
||||
dnl major, minor and micro version macros.
|
||||
m4_define([conky_version_major], [1])
|
||||
m4_define([conky_version_minor], [4])
|
||||
m4_define([conky_version_micro], [6])
|
||||
m4_define([conky_version_minor], [5])
|
||||
m4_define([conky_version_micro], [0])
|
||||
m4_define([conky_version_tag], [svn]) dnl [] for releases
|
||||
m4_define([conky_version_revision],[r@REVISION@])
|
||||
m4_define([conky_version],
|
||||
@ -16,9 +16,6 @@ AC_INIT([Conky], [conky_version()], [brenden1@users.sourceforge.net])
|
||||
|
||||
AM_INIT_AUTOMAKE(conky, conky_version())
|
||||
AM_CONFIG_HEADER(src/config.h)
|
||||
dnl
|
||||
dnl C Compiler
|
||||
dnl
|
||||
|
||||
dnl prevent libtool setting LTCFLAGS to default of -g -O2 when CFLAGS unset.
|
||||
dnl libtool must be deleted with make distclean to see this fix.
|
||||
@ -26,10 +23,19 @@ if test x"$CFLAGS" = x""; then
|
||||
AC_SUBST(CFLAGS, [ ])
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Tools
|
||||
dnl
|
||||
AC_PROG_CC
|
||||
AC_PROG_LD
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LIBTOOL
|
||||
PKG_PROG_PKG_CONFIG([0.17.2])
|
||||
|
||||
AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, yes, no)
|
||||
if test x"$HAVE_PKGCONFIG" = x"no"; then
|
||||
AC_MSG_ERROR([pkg-config is required!])
|
||||
fi
|
||||
PKG_PROG_PKG_CONFIG([0.17.2])
|
||||
|
||||
AC_CONFIG_FILES(
|
||||
Makefile
|
||||
@ -87,25 +93,14 @@ dnl OWN_WINDOW option
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE([own_window],
|
||||
AC_HELP_STRING([--enable-own-window], [enable if you want support for creating own window @<:@default=yes@:>@]),
|
||||
AC_HELP_STRING([--disable-own-window],
|
||||
[disable if you do not want support for creating own window @<:@default=yes@:>@]),
|
||||
[dah="$enableval"], [dah=yes])
|
||||
|
||||
if test $dah != "no"; then
|
||||
AC_DEFINE(OWN_WINDOW, 1, [Define if you want support for window creating])
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl PROC_UPTIME option
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE([proc_uptime],
|
||||
AC_HELP_STRING([--enable-proc-uptime], [enable using /proc/uptime for uptime @<:@default=yes@:>@]),
|
||||
[dah="$enableval"], [dah=yes])
|
||||
|
||||
if test $dah = "yes"; then
|
||||
AC_DEFINE(PROC_UPTIME, 1, [Define if you want to use /proc/uptime for uptime])
|
||||
fi
|
||||
|
||||
|
||||
dnl
|
||||
dnl Audacious Media Player
|
||||
@ -146,7 +141,8 @@ dnl Hddtemp
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE([hddtemp],
|
||||
AC_HELP_STRING([--enable-hddtemp], [enable if you want hddtemp support @<:@default=yes@:>@]),
|
||||
AC_HELP_STRING([--disable-hddtemp],
|
||||
[disable if you do not want hddtemp support @<:@default=yes@:>@]),
|
||||
[want_hddtemp="$enableval"], [want_hddtemp=yes])
|
||||
|
||||
AM_CONDITIONAL(BUILD_HDDTEMP, test x$want_hddtemp = xyes)
|
||||
@ -159,7 +155,7 @@ dnl MPD
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE([mpd],
|
||||
AC_HELP_STRING([--enable-mpd], [enable if you want MPD support @<:@default=yes@:>@]),
|
||||
AC_HELP_STRING([--disable-mpd], [disable if you do not want MPD support @<:@default=yes@:>@]),
|
||||
[want_mpd="$enableval"], [want_mpd=yes])
|
||||
|
||||
AM_CONDITIONAL(BUILD_MPD, test x$want_mpd = xyes)
|
||||
@ -201,12 +197,14 @@ dnl LIBS="$LIBS $Imlib2_LIBS"
|
||||
dnl AC_DEFINE(IMLIB2, 1, [Define if you want Imlib2 support])
|
||||
dnl fi
|
||||
|
||||
|
||||
dnl
|
||||
dnl PORT_MONITORS
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE([portmon],
|
||||
AC_HELP_STRING([--enable-portmon], [enable if you want tcp (ip4) port monitoring @<:@default=yes@:>@]),
|
||||
AC_HELP_STRING([--disable-portmon],
|
||||
[disable if you do not want tcp (ip4) port monitoring @<:@default=yes@:>@]),
|
||||
[want_portmon="$enableval"], [want_portmon=yes])
|
||||
|
||||
AM_CONDITIONAL(BUILD_PORT_MONITORS, test x$want_portmon = xyes)
|
||||
@ -228,6 +226,30 @@ if test x$want_portmon = xyes; then
|
||||
fi
|
||||
|
||||
|
||||
dnl
|
||||
dnl Network-based monitoring
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE([network],
|
||||
AC_HELP_STRING([--disable-network],
|
||||
[disable if you do not want distributed monitoring @<:@default=yes@:>@]),
|
||||
[want_network="$enableval"], [want_network=yes])
|
||||
if test x"$want_network" = x"yes"; then
|
||||
PKG_CHECK_MODULES([LIBDEXTER], [dexter], [], [AC_MSG_RESULT([no]); want_network=no])
|
||||
if test x"$want_network" = x"yes"; then
|
||||
dnl need GNU string stream extensions
|
||||
AC_CHECK_FUNCS([fmemopen open_memstream flockfile funlockfile putc_unlocked], [], [want_network=no])
|
||||
if test x"$want_network" = x"yes"; then
|
||||
CFLAGS="$CFLAGS $LIBDEXTER_CFLAGS"
|
||||
LIBS="$LIBS $LIBDEXTER_LIBS"
|
||||
AC_DEFINE([HAVE_LIBDEXTER], 1, [Define if using Libdexter])
|
||||
dnl _GNU_SOURCE needed for fmemopen, open_memstream
|
||||
AC_DEFINE([_GNU_SOURCE], [], [Define for GNU source and extensions])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
dnl
|
||||
dnl ICONV
|
||||
dnl
|
||||
@ -249,6 +271,7 @@ AC_ARG_ENABLE([debug],
|
||||
|
||||
if test "x$want_debug" = "xyes" -a $ac_cv_c_compiler_gnu != no; then
|
||||
CFLAGS="$CFLAGS -g3"
|
||||
AC_DEFINE([DEBUG], [], [Define for debugging])
|
||||
fi
|
||||
|
||||
dnl
|
||||
@ -256,7 +279,7 @@ dnl X11
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE([x11],
|
||||
AC_HELP_STRING([--enable-x11], [enable if you want X11 support @<:@default=yes@:>@]),
|
||||
AC_HELP_STRING([--disable-x11], [disable if you do not want X11 support @<:@default=yes@:>@]),
|
||||
[want_x11="$enableval"], [want_x11=yes])
|
||||
|
||||
AM_CONDITIONAL(BUILD_X11, test x$want_x11 = xyes)
|
||||
@ -286,13 +309,15 @@ dnl Xext Double-buffering Extension
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE([double_buffer],
|
||||
AC_HELP_STRING([--enable-double-buffer], [enable for flicker-free operation @<:@default=yes@:>@]),
|
||||
AC_HELP_STRING([--disable-double-buffer],
|
||||
[disable for no Xdbe double-buffering support @<:@default=yes@:>@]),
|
||||
[want_double_buffer="$enableval"], [want_double_buffer=yes])
|
||||
|
||||
if test "x$want_double_buffer" = "xyes"; then
|
||||
if test "x$want_x11" != "xyes"; then
|
||||
AC_MSG_ERROR([--enable-x11 is required for double-buffering])
|
||||
fi
|
||||
dnl silently disable if no x11
|
||||
want_double_buffer=no
|
||||
else
|
||||
if $PKG_CONFIG --exists xext; then
|
||||
PKG_CHECK_MODULES([XEXT],[xext])
|
||||
CFLAGS="$CFLAGS $XEXT_CFLAGS"
|
||||
@ -304,6 +329,7 @@ if test "x$want_double_buffer" = "xyes"; then
|
||||
fi
|
||||
AC_DEFINE(HAVE_XDBE, 1, [Define for X11 double-buffering])
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
dnl
|
||||
@ -311,13 +337,15 @@ dnl Xdamage Extension
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE([xdamage],
|
||||
AC_HELP_STRING([--enable-xdamage], [enable if you want Xdamage support @<:@default=yes@:>@]),
|
||||
AC_HELP_STRING([--disable-xdamage],
|
||||
[disable if you do not want Xdamage support @<:@default=yes@:>@]),
|
||||
[want_xdamage="$enableval"], [want_xdamage=yes])
|
||||
|
||||
if test "x$want_xdamage" = "xyes"; then
|
||||
if test "x$want_x11" != "xyes"; then
|
||||
AC_MSG_ERROR([--enable-x11 is required for xdamage])
|
||||
fi
|
||||
dnl silently disable if no x11
|
||||
want_xdamage=no
|
||||
else
|
||||
if $PKG_CONFIG --exists xdamage; then
|
||||
PKG_CHECK_MODULES([XDAMAGE],[xdamage])
|
||||
CFLAGS="$CFLAGS $XDAMAGE_CFLAGS"
|
||||
@ -329,6 +357,7 @@ if test "x$want_xdamage" = "xyes"; then
|
||||
fi
|
||||
AC_DEFINE(HAVE_XDAMAGE, 1, [Define for X11 Xdamage extension])
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
dnl
|
||||
@ -336,18 +365,20 @@ dnl Xft
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE([xft],
|
||||
AC_HELP_STRING([--enable-xft], [enable if you want to use Xft @<:@default=yes@:>@]),
|
||||
AC_HELP_STRING([--disable-xft], [disable if you do not want to use Xft @<:@default=yes@:>@]),
|
||||
[want_xft="$enableval"], [want_xft=yes])
|
||||
|
||||
if test x$want_xft = "xyes"; then
|
||||
if test "x$want_x11" != "xyes"; then
|
||||
AC_MSG_ERROR([--enable-x11 is required for xft])
|
||||
fi
|
||||
dnl silently disable if no x11
|
||||
want_xft=no
|
||||
else
|
||||
PKG_CHECK_MODULES(XFT, [xft])
|
||||
CFLAGS="$CFLAGS $XFT_CFLAGS"
|
||||
LIBS="$LIBS $XFT_LIBS"
|
||||
AC_DEFINE(XFT, 1, [Define for Xft support])
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
dnl
|
||||
@ -398,7 +429,7 @@ dnl
|
||||
dnl Some functions
|
||||
dnl
|
||||
|
||||
AC_CHECK_FUNCS([calloc malloc free popen])
|
||||
AC_CHECK_FUNCS([calloc malloc free popen sysinfo getloadavg])
|
||||
AC_SEARCH_LIBS(clock_gettime, [rt], [], AC_MSG_ERROR([clock_gettime() not found]))
|
||||
|
||||
|
||||
@ -415,24 +446,6 @@ else
|
||||
AM_CONDITIONAL(HAVE_DOCSTUFF, true)
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Check sysinfo()
|
||||
dnl
|
||||
|
||||
if test x$WANT_SYSINFO = xyes; then
|
||||
dah=no
|
||||
AC_MSG_CHECKING(for sysinfo)
|
||||
AC_TRY_COMPILE(
|
||||
[#include <sys/types.h>
|
||||
#include <sys/sysinfo.h>],
|
||||
[struct sysinfo s; sysinfo(&s); (void) s.uptime; ],
|
||||
[AC_MSG_RESULT(yes); dah=yes],
|
||||
[AC_MSG_RESULT(not usable); dah=no])
|
||||
|
||||
if test x$dah = xyes; then
|
||||
AC_DEFINE(HAVE_SYSINFO, 1, [Define if you have sysinfo (Linux)])
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl kstat in Solaris
|
||||
@ -462,17 +475,20 @@ AC_DEFUN([AM_LANGINFO_CODESET],
|
||||
fi
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Check getloadavg
|
||||
dnl
|
||||
|
||||
AC_MSG_CHECKING(for getloadavg)
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>],
|
||||
[double v[3]; getloadavg(v, 3);],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_GETLOADAVG, 1, [Define if you have getloadavg])],
|
||||
[AC_MSG_RESULT(no)])
|
||||
dnl ************************
|
||||
dnl * Linker optimizations *
|
||||
dnl ************************
|
||||
AC_MSG_CHECKING([if $LD accepts -O1])
|
||||
case `$LD -O1 -v 2>&1 </dev/null` in
|
||||
*GNU* | *BSD*)
|
||||
LDFLAGS="$LDFLAGS -Wl,-O1"
|
||||
AC_MSG_RESULT([yes])
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT([no])
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
dnl
|
||||
@ -513,5 +529,5 @@ $PACKAGE $VERSION configured successfully:
|
||||
* general:
|
||||
hddtemp: $want_hddtemp
|
||||
portmon: $want_portmon
|
||||
|
||||
network: $want_network
|
||||
EOF
|
||||
|
@ -55,6 +55,27 @@
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>dexter_client</option></command></term>
|
||||
<listitem>
|
||||
Act as client and connect to libdexter server for remote monitoring?
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>dexter_config</option></command></term>
|
||||
<listitem>
|
||||
Full path to libdexter configuration file (default search order: $HOME/.dexterrc; /etc/libdexter/dexter.conf)
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>dexter_server</option></command></term>
|
||||
<listitem>
|
||||
Act as server for libdexter services?
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>double_buffer</option></command></term>
|
||||
<listitem>
|
||||
@ -219,20 +240,9 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>own_window_transparent</option></command></term>
|
||||
<term><command><option>own_window_class</option></command></term>
|
||||
<listitem>
|
||||
Boolean, set pseudo-transparency?
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>own_window_type</option></command></term>
|
||||
<listitem>
|
||||
if own_window is yes, you may specify type normal, desktop or override (default: normal).
|
||||
Desktop windows are special windows that have no window decorations; are always visible
|
||||
on your desktop; do not appear in your pager or taskbar; and are sticky across all workspaces.
|
||||
Override windows are not under the control of the window manager. Hints are ignored. This type
|
||||
of window can be useful for certain situations.
|
||||
Manually set the WM_CLASS name. Defaults to "Conky".
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
@ -256,6 +266,31 @@
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>own_window_title</option></command></term>
|
||||
<listitem>
|
||||
Manually set the window name. Defaults to "<hostname> - conky".
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>own_window_transparent</option></command></term>
|
||||
<listitem>
|
||||
Boolean, set pseudo-transparency?
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>own_window_type</option></command></term>
|
||||
<listitem>
|
||||
if own_window is yes, you may specify type normal, desktop or override (default: normal).
|
||||
Desktop windows are special windows that have no window decorations; are always visible
|
||||
on your desktop; do not appear in your pager or taskbar; and are sticky across all workspaces.
|
||||
Override windows are not under the control of the window manager. Hints are ignored. This type
|
||||
of window can be useful for certain situations.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>out_to_console</option></command>
|
||||
</term>
|
||||
@ -319,13 +354,6 @@
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>wm_class_name</option></command></term>
|
||||
<listitem>
|
||||
Manually set the WM_CLASS name. Defaults to "conky".
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>xftalpha</option></command></term>
|
||||
<listitem>
|
||||
|
46
doc/conky.1
46
doc/conky.1
@ -44,7 +44,7 @@ Example to compile and run Conky with all optional components (note that some co
|
||||
.TP
|
||||
\fB\*(T<\fBsh autogen.sh\fR\*(T>\fR \*(T<\fB# Only required if building from Svn\fR\*(T>
|
||||
.TP
|
||||
\fB\*(T<\fB\&./configure \fR\*(T>\fR\*(T<\fB\-\-prefix=/usr \-\-mandir=/usr/share/man \-\-infodir=/usr/share/info \-\-datadir=/usr/share \-\-sysconfdir=/etc \-\-localstatedir=/var/lib \-\-enable\-xft \-\-enable\-own\-window \-\-enable\-proc\-uptime \-\-enable\-audacious \-\-enable\-bmpx \-\-enable\-hddtemp \-\-enable\-mpd \-\-enable\-xmms2 \-\-enable\-imlib2 \-\-enable\-portmon \-\-enable\-debug \-\-enable\-double\-buffer \-\-enable\-xdamage \-\-enable\-x11\fR\*(T>
|
||||
\fB\*(T<\fB\&./configure \fR\*(T>\fR\*(T<\fB\-\-prefix=/usr \-\-mandir=/usr/share/man \-\-infodir=/usr/share/info \-\-datadir=/usr/share \-\-sysconfdir=/etc \-\-localstatedir=/var/lib \-\-disable\-own\-window \-\-enable\-audacious \-\-enable\-bmpx \-\-disable\-hddtemp \-\-disable\-mpd \-\-enable\-xmms2 \-\-disable\-portmon \-\-disable\-network \-\-enable\-debug \-\-disable\-x11 \-\-disable\-double\-buffer \-\-disable\-xdamage \-\-disable\-xft\fR\*(T>
|
||||
.TP
|
||||
\fB\*(T<\fBmake\fR\*(T>\fR
|
||||
.TP
|
||||
@ -167,6 +167,18 @@ Default outline color
|
||||
\fB\*(T<\fBdefault_shade_color\fR\*(T>\fR
|
||||
Default shading color and border's shading color
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBdexter_client\fR\*(T>\fR
|
||||
Act as client and connect to libdexter server for remote monitoring?
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBdexter_config\fR\*(T>\fR
|
||||
Full path to libdexter configuration file (default search order: $HOME/.dexterrc; /etc/libdexter/dexter.conf)
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBdexter_server\fR\*(T>\fR
|
||||
Act as server for libdexter services?
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBdouble_buffer\fR\*(T>\fR
|
||||
Use the Xdbe extension? (eliminates flicker) It is highly recommended to use own window with this one so double buffer won't be so big.
|
||||
@ -259,16 +271,8 @@ Force UTF8? requires XFT
|
||||
Boolean, create own window to draw?
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBown_window_transparent\fR\*(T>\fR
|
||||
Boolean, set pseudo-transparency?
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBown_window_type\fR\*(T>\fR
|
||||
if own_window is yes, you may specify type normal, desktop or override (default: normal).
|
||||
Desktop windows are special windows that have no window decorations; are always visible
|
||||
on your desktop; do not appear in your pager or taskbar; and are sticky across all workspaces.
|
||||
Override windows are not under the control of the window manager. Hints are ignored. This type
|
||||
of window can be useful for certain situations.
|
||||
\fB\*(T<\fBown_window_class\fR\*(T>\fR
|
||||
Manually set the WM_CLASS name. Defaults to "Conky".
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBown_window_colour\fR\*(T>\fR \*(T<\fBcolour\fR\*(T>
|
||||
@ -280,6 +284,22 @@ If own_window is yes, you may use these window manager hints to affect the way C
|
||||
Notes: Use own_window_type desktop as another way to implement many of these hints implicitly.
|
||||
If you use own_window_type override, window manager hints have no meaning and are ignored.
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBown_window_title\fR\*(T>\fR
|
||||
Manually set the window name. Defaults to "<hostname> - conky".
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBown_window_transparent\fR\*(T>\fR
|
||||
Boolean, set pseudo-transparency?
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBown_window_type\fR\*(T>\fR
|
||||
if own_window is yes, you may specify type normal, desktop or override (default: normal).
|
||||
Desktop windows are special windows that have no window decorations; are always visible
|
||||
on your desktop; do not appear in your pager or taskbar; and are sticky across all workspaces.
|
||||
Override windows are not under the control of the window manager. Hints are ignored. This type
|
||||
of window can be useful for certain situations.
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBout_to_console\fR\*(T>\fR
|
||||
Print text to stdout.
|
||||
@ -316,10 +336,6 @@ Adds spaces after certain objects to stop them from moving other things around.
|
||||
\fB\*(T<\fBuse_xft\fR\*(T>\fR
|
||||
Use Xft (anti-aliased font and stuff)
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBwm_class_name\fR\*(T>\fR
|
||||
Manually set the WM_CLASS name. Defaults to "conky".
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBxftalpha\fR\*(T>\fR
|
||||
Alpha of Xft font. Must be a value at or between 1 and 0.
|
||||
|
@ -93,6 +93,11 @@ default_color white
|
||||
default_shade_color black
|
||||
default_outline_color black
|
||||
|
||||
dexter_client no
|
||||
dexter_server no
|
||||
# config file for libdexter (default search path: $HOME/.dexterrc; /etc/libdexter/dexter.conf)
|
||||
dexter_config
|
||||
|
||||
# Text alignment, other possible values are commented
|
||||
#alignment top_left
|
||||
#alignment top_right
|
||||
|
@ -79,7 +79,7 @@
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>./configure </option></command><option>--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --enable-xft --enable-own-window --enable-proc-uptime --enable-audacious --enable-bmpx --enable-hddtemp --enable-mpd --enable-xmms2 --enable-imlib2 --enable-portmon --enable-debug --enable-double-buffer --enable-xdamage --enable-x11</option>
|
||||
<command><option>./configure </option></command><option>--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --disable-own-window --enable-audacious --enable-bmpx --disable-hddtemp --disable-mpd --enable-xmms2 --disable-portmon --disable-network --enable-debug --disable-x11 --disable-double-buffer --disable-xdamage --disable-xft</option>
|
||||
</term>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
|
@ -6,7 +6,7 @@
|
||||
syntax "conky" "\.*conkyrc.*$"
|
||||
|
||||
## Configuration items
|
||||
color green "\<(alignment|background|border_margin|border_width|cpu_avg_samples|default_color|default_shade_color|default_outline_color|double_buffer|draw_borders|draw_graph_borders|draw_shades|draw_outline|font|gap_x|gap_y|imap|mail_spool|max_port_monitor_connections|max_specials|max_user_text|maximum_width|minimum_size|mpd_host|mpd_port|mpd_password|net_avg_samples|no_buffers|out_to_console|override_utf8_locale|own_window|own_window_transparent|own_window_type|own_window_hints|own_window_colour|pad_percents|pop3|stippled_borders|total_run_times|update_interval|uppercase|use_spacer|use_xft|wm_class_name|xftalpha|xftfont)\>"
|
||||
color green "\<(alignment|background|border_margin|border_width|cpu_avg_samples|default_color|default_shade_color|default_outline_color|dexter_client|dexter_config|dexter_server|double_buffer|draw_borders|draw_graph_borders|draw_shades|draw_outline|font|gap_x|gap_y|imap|mail_spool|max_port_monitor_connections|max_specials|max_user_text|maximum_width|minimum_size|mpd_host|mpd_port|mpd_password|net_avg_samples|no_buffers|out_to_console|override_utf8_locale|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|stippled_borders|total_run_times|update_interval|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>"
|
||||
|
||||
## Variables
|
||||
color brightblue "\<(acpiacadapter|acpifan|acpitemp|acpitempf|addr|adt746xcpu|adt746xfan|align|alignr|apm_adapter|apm_battery_life|apm_battery_time|audacious_bar|audacious_bitrate|audacious_channels|audacious_filename|audacious_frequency|audacious_length|audacious_length_seconds|audacious_playlist_length|audacious_playlist_position|audacious_position|audacious_position_seconds|audacious_status|audacious_title|battery|battery_time|bmpx_album|bmpx_artist|bmpx_bitrate|bmpx_title|bmpx_track|bmpx_uri|buffers|cached|color|colour|cpu|cpubar|diskio|downspeed|downspeedf|else|entropy_avail|entropy_bar|entropy_poolsize|exec|execbar|execgraph|execi|execibar|execigraph|font|freq|freq_dyn|freq_dyn_g|freq_g|fs_bar|fs_free|fs_free_perc|fs_size|fs_used|goto|hddtemp|head|hr|i2c|i8k_ac_status|i8k_bios|i8k_buttons_status|i8k_cpu_temp|i8k_cpu_tempf|i8k_left_fan_rpm|i8k_left_fan_status|i8k_right_fan_rpm|i8k_right_fan_status|i8k_serial|i8k_version|if_existing|if_running|if_mounted|kernel|linkstatus|loadavg|machine|mails|mem|membar|memmax|memperc|mpd_album|mpd_artist|mpd_bar|mpd_bitrate|mpd_elapsed|mpd_file|mpd_length|mpd_name|mpd_percent|mpd_smart|mpd_status|mpd_title|mpd_vol|new_mails|nodename|offset|outlinecolor|pre_exec|processes|running_processes|shadecolor|stippled_hr|swap|swapbar|swapmax|swapperc|sysname|tab|tail|tcp_portmon|texeci|time|top|top_mem|totaldown|totalup|tztime|updates|upspeed|upspeedf|upspeedgraph|uptime|uptime_short|voffset|voltage_mv|voltage_v)\>"
|
||||
|
@ -22,6 +22,9 @@ syn keyword ConkyrcSetting
|
||||
\ default_color
|
||||
\ default_outline_color
|
||||
\ default_shade_color
|
||||
\ dexter_client
|
||||
\ dexter_config
|
||||
\ dexter_server
|
||||
\ double_buffer
|
||||
\ draw_borders
|
||||
\ draw_graph_borders
|
||||
@ -45,8 +48,10 @@ syn keyword ConkyrcSetting
|
||||
\ out_to_console
|
||||
\ override_utf8_locale
|
||||
\ own_window
|
||||
\ own_window_class
|
||||
\ own_window_colour
|
||||
\ own_window_hints
|
||||
\ own_window_title
|
||||
\ own_window_transparent
|
||||
\ own_window_type
|
||||
\ pad_percents
|
||||
|
@ -62,10 +62,6 @@ conky_SOURCES = \
|
||||
$(netbsd) \
|
||||
$(port_monitors) \
|
||||
$(solaris) \
|
||||
remotec.c \
|
||||
remotec.h \
|
||||
remoted.c \
|
||||
remoted.h \
|
||||
timed_thread.c \
|
||||
timed_thread.h \
|
||||
$(x11) \
|
||||
|
@ -105,7 +105,8 @@ void *audacious_thread_func(void *pvoid)
|
||||
/* Loop until the main thread sets the runnable signal to 0i via timed_thread_destroy. */
|
||||
while (1) {
|
||||
|
||||
if (!xmms_remote_is_running (session)) {
|
||||
if (!xmms_remote_is_running (session))
|
||||
{
|
||||
memset(&items,0,sizeof(items));
|
||||
strcpy(items[AUDACIOUS_STATUS],"Not running");
|
||||
goto next_iter;
|
||||
@ -122,7 +123,8 @@ void *audacious_thread_func(void *pvoid)
|
||||
/* Current song title */
|
||||
playpos = xmms_remote_get_playlist_pos (session);
|
||||
psong = xmms_remote_get_playlist_title (session, playpos);
|
||||
if (psong) {
|
||||
if (psong)
|
||||
{
|
||||
strncpy(items[AUDACIOUS_TITLE],psong,sizeof(items[AUDACIOUS_TITLE])-1);
|
||||
g_free (psong);
|
||||
psong=NULL;
|
||||
@ -131,12 +133,10 @@ void *audacious_thread_func(void *pvoid)
|
||||
/* Current song length as MM:SS */
|
||||
frames = xmms_remote_get_playlist_time (session,playpos);
|
||||
length = frames / 1000;
|
||||
snprintf(items[AUDACIOUS_LENGTH],sizeof(items[AUDACIOUS_LENGTH])-1,
|
||||
"%d:%.2d", length / 60, length % 60);
|
||||
snprintf(items[AUDACIOUS_LENGTH],sizeof(items[AUDACIOUS_LENGTH])-1, "%d:%.2d", length / 60, length % 60);
|
||||
|
||||
/* Current song length in seconds */
|
||||
snprintf(items[AUDACIOUS_LENGTH_SECONDS],sizeof(items[AUDACIOUS_LENGTH_SECONDS])-1,
|
||||
"%d", length);
|
||||
snprintf(items[AUDACIOUS_LENGTH_SECONDS],sizeof(items[AUDACIOUS_LENGTH_SECONDS])-1, "%d", length);
|
||||
|
||||
/* Current song position as MM:SS */
|
||||
frames = xmms_remote_get_output_time (session);
|
||||
@ -145,8 +145,7 @@ void *audacious_thread_func(void *pvoid)
|
||||
"%d:%.2d", length / 60, length % 60);
|
||||
|
||||
/* Current song position in seconds */
|
||||
snprintf(items[AUDACIOUS_POSITION_SECONDS],sizeof(items[AUDACIOUS_POSITION_SECONDS])-1,
|
||||
"%d", length);
|
||||
snprintf(items[AUDACIOUS_POSITION_SECONDS],sizeof(items[AUDACIOUS_POSITION_SECONDS])-1, "%d", length);
|
||||
|
||||
/* Current song bitrate */
|
||||
xmms_remote_get_info (session, &rate, &freq, &chans);
|
||||
@ -160,7 +159,8 @@ void *audacious_thread_func(void *pvoid)
|
||||
|
||||
/* Current song filename */
|
||||
pfilename = xmms_remote_get_playlist_file (session,playpos);
|
||||
if (pfilename) {
|
||||
if (pfilename)
|
||||
{
|
||||
strncpy(items[AUDACIOUS_FILENAME],pfilename,sizeof(items[AUDACIOUS_FILENAME])-1);
|
||||
g_free (pfilename);
|
||||
pfilename=NULL;
|
||||
@ -183,6 +183,5 @@ next_iter:
|
||||
|
||||
if (timed_thread_test (info.audacious.p_timed_thread))
|
||||
timed_thread_exit (info.audacious.p_timed_thread);
|
||||
|
||||
}
|
||||
}
|
||||
|
18
src/common.c
18
src/common.c
@ -7,8 +7,6 @@
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include "remoted.h"
|
||||
#include "remotec.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -30,6 +28,11 @@ double get_time()
|
||||
return tv.tv_sec + (tv.tv_usec / 1000000.0);
|
||||
}
|
||||
|
||||
#if defined(HAVE_LIBDEXTER) && defined(__linux__)
|
||||
#define USE_OS_SPECIFIC_OPEN_FILE
|
||||
#endif
|
||||
|
||||
#ifndef USE_OS_SPECIFIC_OPEN_FILE
|
||||
FILE *open_file(const char *file, int *reported)
|
||||
{
|
||||
FILE *fp = fopen(file, "r");
|
||||
@ -44,6 +47,7 @@ FILE *open_file(const char *file, int *reported)
|
||||
|
||||
return fp;
|
||||
}
|
||||
#endif
|
||||
|
||||
void variable_substitute(const char *s, char *dest, unsigned int n)
|
||||
{
|
||||
@ -129,6 +133,11 @@ struct net_stat *get_net_stat(const char *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void clear_net_stats (void)
|
||||
{
|
||||
memset (netstats, 0, sizeof(netstats));
|
||||
}
|
||||
|
||||
void format_seconds(char *buf, unsigned int n, long t)
|
||||
{
|
||||
if (t >= 24 * 60 * 60) /* hours necessary when there are days? */
|
||||
@ -157,6 +166,7 @@ static double last_meminfo_update;
|
||||
static double last_fs_update;
|
||||
|
||||
unsigned long long need_mask;
|
||||
#define NEED(a) ((need_mask & (1 << a)) && ((info.mask & (1 << a)) == 0))
|
||||
|
||||
void update_stuff()
|
||||
{
|
||||
@ -178,8 +188,6 @@ void update_stuff()
|
||||
}
|
||||
|
||||
prepare_update();
|
||||
/* client(); this is approximately where the client should be called */
|
||||
#define NEED(a) ((need_mask & (1 << a)) && ((info.mask & (1 << a)) == 0))
|
||||
|
||||
if (NEED(INFO_UPTIME))
|
||||
update_uptime();
|
||||
@ -205,8 +213,6 @@ void update_stuff()
|
||||
if (NEED(INFO_MAIL))
|
||||
update_mail_count();
|
||||
|
||||
|
||||
|
||||
#if defined(__linux__)
|
||||
if (NEED(INFO_I8K))
|
||||
update_i8k();
|
||||
|
285
src/conky.c
285
src/conky.c
@ -95,6 +95,9 @@ static void print_version()
|
||||
#ifdef TCP_PORT_MONITOR
|
||||
" * portmon\n"
|
||||
#endif /* TCP_PORT_MONITOR */
|
||||
#ifdef HAVE_LIBDEXTER
|
||||
" * network\n"
|
||||
#endif
|
||||
"\n");
|
||||
|
||||
exit(0);
|
||||
@ -274,9 +277,6 @@ static char *current_config;
|
||||
/* set to 1 if you want all text to be in uppercase */
|
||||
static unsigned int stuff_in_upper_case;
|
||||
|
||||
/* Update interval */
|
||||
static double update_interval;
|
||||
|
||||
/* Run how many times? */
|
||||
static unsigned long total_run_times;
|
||||
|
||||
@ -380,6 +380,11 @@ static int pad_percents = 0;
|
||||
tcp_port_monitor_args_t tcp_port_monitor_args;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBDEXTER
|
||||
/* private config items for libdexter */
|
||||
static char *dexter_config = NULL;
|
||||
#endif
|
||||
|
||||
/* Text that is shown */
|
||||
static char original_text[] =
|
||||
"$nodename - $sysname $kernel on $machine\n"
|
||||
@ -1076,7 +1081,6 @@ enum text_object_type {
|
||||
#ifdef TCP_PORT_MONITOR
|
||||
OBJ_tcp_portmon,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
OBJ_iconv_start,
|
||||
OBJ_iconv_stop,
|
||||
@ -2006,7 +2010,7 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
|
||||
OBJ(acpitemp, 0) obj->data.i = open_acpi_temperature(arg);
|
||||
END OBJ(acpitempf, 0) obj->data.i = open_acpi_temperature(arg);
|
||||
END OBJ(acpiacadapter, 0)
|
||||
END OBJ(freq, 0)
|
||||
END OBJ(freq, INFO_FREQ)
|
||||
get_cpu_count();
|
||||
if (!arg
|
||||
|| !isdigit(arg[0])
|
||||
@ -2022,7 +2026,7 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
|
||||
obj->data.cpu_index=atoi(&arg[0]);
|
||||
}
|
||||
obj->a = 1;
|
||||
END OBJ(freq_g, 0)
|
||||
END OBJ(freq_g, INFO_FREQ)
|
||||
get_cpu_count();
|
||||
if (!arg
|
||||
|| !isdigit(arg[0])
|
||||
@ -2071,9 +2075,6 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
|
||||
obj->data.cpu_index=atoi(&arg[0]);
|
||||
}
|
||||
obj->a = 1;
|
||||
#else
|
||||
END OBJ(freq, 0);
|
||||
END OBJ(freq_g, 0);
|
||||
#endif /* __linux__ */
|
||||
END OBJ(freq_dyn, 0);
|
||||
END OBJ(freq_dyn_g, 0);
|
||||
@ -3428,15 +3429,15 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
|
||||
}
|
||||
} else {
|
||||
if (diskio_value > 1024*1024) {
|
||||
snprintf(p, 6, "%.1fGiB ",
|
||||
snprintf(p, 12, "%.1fGiB ",
|
||||
(double)diskio_value/1024/1024);
|
||||
} else if (diskio_value > 1024) {
|
||||
snprintf(p, 6, "%.1fMiB ",
|
||||
snprintf(p, 12, "%.1fMiB ",
|
||||
(double)diskio_value/1024);
|
||||
} else if (diskio_value > 0) {
|
||||
snprintf(p, 6, "%dKiB ", diskio_value);
|
||||
snprintf(p, 12, "%dKiB ", diskio_value);
|
||||
} else {
|
||||
snprintf(p, 6, "%dB ", diskio_value);
|
||||
snprintf(p, 12, "%dB ", diskio_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3469,8 +3470,10 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
|
||||
recv_speed / 1024.0);
|
||||
}
|
||||
OBJ(downspeedgraph) {
|
||||
if (obj->data.net->recv_speed == 0) // this is just to make the ugliness at start go away
|
||||
/*
|
||||
if (obj->data.net->recv_speed == 0)
|
||||
obj->data.net->recv_speed = 0.01;
|
||||
*/
|
||||
new_graph(p, obj->a, obj->b, obj->c, obj->d,
|
||||
(obj->data.net->recv_speed /
|
||||
1024.0), obj->e, 1);
|
||||
@ -4244,8 +4247,10 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
|
||||
trans_speed / 1024.0);
|
||||
}
|
||||
OBJ(upspeedgraph) {
|
||||
if (obj->data.net->trans_speed == 0) // this is just to make the ugliness at start go away
|
||||
/*
|
||||
if (obj->data.net->trans_speed == 0)
|
||||
obj->data.net->trans_speed = 0.01;
|
||||
*/
|
||||
new_graph(p, obj->a, obj->b, obj->c, obj->d,
|
||||
(obj->data.net->trans_speed /
|
||||
1024.0), obj->e, 1);
|
||||
@ -5065,7 +5070,6 @@ static void draw_string(const char *s)
|
||||
printf("%s\n", s);
|
||||
fflush(stdout); /* output immediately, don't buffer */
|
||||
}
|
||||
/* daemon_run(s); the daemon can be called here, but we need to have a buffer in daemon_run() and we need to tell it when everything is ready to be sent */
|
||||
memset(tmpstring1,0,TEXT_BUFFER_SIZE);
|
||||
memset(tmpstring2,0,TEXT_BUFFER_SIZE);
|
||||
strncpy(tmpstring1, s, TEXT_BUFFER_SIZE-1);
|
||||
@ -5881,21 +5885,40 @@ static void main_loop()
|
||||
|
||||
case ButtonPress:
|
||||
if (own_window)
|
||||
{
|
||||
/* if an ordinary window with decorations */
|
||||
if ((window.type==TYPE_NORMAL) && (!TEST_HINT(window.hints,HINT_UNDECORATED)))
|
||||
{
|
||||
/* allow conky to hold input focus.*/
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* forward the click to the desktop window */
|
||||
XUngrabPointer(display, ev.xbutton.time);
|
||||
ev.xbutton.window = window.desktop;
|
||||
XSendEvent(display, ev.xbutton.window, False, ButtonPressMask, &ev);
|
||||
XSetInputFocus(display, ev.xbutton.window,RevertToParent,ev.xbutton.time);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
if (own_window)
|
||||
{
|
||||
/* if an ordinary window with decorations */
|
||||
if ((window.type==TYPE_NORMAL) && (!TEST_HINT(window.hints,HINT_UNDECORATED)))
|
||||
{
|
||||
/* allow conky to hold input focus.*/
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* forward the release to the desktop window */
|
||||
ev.xbutton.window = window.desktop;
|
||||
XSendEvent(display, ev.xbutton.window, False, ButtonReleaseMask, &ev);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#endif
|
||||
@ -6092,6 +6115,12 @@ void clean_up(void)
|
||||
free (specials);
|
||||
specials=NULL;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBDEXTER
|
||||
dexter_library_exit ();
|
||||
if (dexter_config)
|
||||
free (dexter_config);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int string_to_bool(const char *s)
|
||||
@ -6188,7 +6217,9 @@ static void set_default_configurations(void)
|
||||
own_window = 0;
|
||||
window.type=TYPE_NORMAL;
|
||||
window.hints=0;
|
||||
strcpy(window.wm_class_name, "conky");
|
||||
strcpy(window.class_name, "Conky");
|
||||
update_uname();
|
||||
sprintf(window.title,"%s - conky",info.uname_s.nodename);
|
||||
#endif
|
||||
stippled_borders = 0;
|
||||
border_margin = 3;
|
||||
@ -6522,14 +6553,34 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
|
||||
#ifdef X11
|
||||
#ifdef OWN_WINDOW
|
||||
CONF("own_window") {
|
||||
if (value)
|
||||
own_window = string_to_bool(value);
|
||||
else
|
||||
CONF_ERR;
|
||||
}
|
||||
CONF("wm_class_name") {
|
||||
memset(window.wm_class_name,0,sizeof(window.wm_class_name));
|
||||
strncpy(window.wm_class_name, value, sizeof(window.wm_class_name)-1);
|
||||
CONF("own_window_class") {
|
||||
if (value)
|
||||
{
|
||||
memset(window.class_name,0,sizeof(window.class_name));
|
||||
strncpy(window.class_name, value, sizeof(window.class_name)-1);
|
||||
}
|
||||
else
|
||||
CONF_ERR;
|
||||
}
|
||||
CONF("own_window_title") {
|
||||
if (value)
|
||||
{
|
||||
memset(window.title,0,sizeof(window.title));
|
||||
strncpy(window.title, value, sizeof(window.title)-1);
|
||||
}
|
||||
else
|
||||
CONF_ERR;
|
||||
}
|
||||
CONF("own_window_transparent") {
|
||||
if (value)
|
||||
set_transparent = string_to_bool(value);
|
||||
else
|
||||
CONF_ERR;
|
||||
}
|
||||
CONF("own_window_colour") {
|
||||
if (value) {
|
||||
@ -6566,6 +6617,8 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
|
||||
}
|
||||
while (p_hint!=NULL);
|
||||
}
|
||||
else
|
||||
CONF_ERR;
|
||||
}
|
||||
CONF("own_window_type") {
|
||||
if (value) {
|
||||
@ -6578,6 +6631,8 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
|
||||
else
|
||||
CONF_ERR;
|
||||
}
|
||||
else
|
||||
CONF_ERR;
|
||||
}
|
||||
#endif
|
||||
CONF("stippled_borders") {
|
||||
@ -6667,6 +6722,29 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
|
||||
/* else tcp_port_monitor_args.max_port_monitor_connections > 0 as per config */
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_LIBDEXTER
|
||||
CONF("dexter_client")
|
||||
{
|
||||
if (value)
|
||||
dexter_client = string_to_bool (value);
|
||||
else
|
||||
CONF_ERR;
|
||||
}
|
||||
CONF("dexter_server")
|
||||
{
|
||||
if (value)
|
||||
dexter_server = string_to_bool (value);
|
||||
else
|
||||
CONF_ERR;
|
||||
}
|
||||
CONF("dexter_config")
|
||||
{
|
||||
if (value)
|
||||
dexter_config = strdup (value);
|
||||
else
|
||||
CONF_ERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
else
|
||||
ERR("%s: %d: no such configuration: '%s'", f, line, name);
|
||||
@ -6933,9 +7011,48 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
update_uname();
|
||||
#ifdef HAVE_LIBDEXTER
|
||||
memset (&packet_arrival_time, 0, sizeof (struct timespec));
|
||||
dexter_library_init ();
|
||||
if (dexter_client)
|
||||
{
|
||||
/* wait until some data packets arrive, else conky complains
|
||||
* bittery that /proc filesystems cannot be opened and, worse,
|
||||
* will likely segfault when it references unchecked pointers
|
||||
* in get_text_internal() -- those should be cleaned up.
|
||||
*/
|
||||
int try;
|
||||
const int max_tries=30;
|
||||
gboolean got_packet;
|
||||
GTimeVal timeval;
|
||||
fprintf (stderr, "Conky: waiting for data packets to arrive ...\n");
|
||||
for (try=0;try<max_tries;try++)
|
||||
{
|
||||
/* pause main thread for 1 sec */
|
||||
g_get_current_time (&timeval);
|
||||
g_time_val_add (&timeval, G_USEC_PER_SEC);
|
||||
g_mutex_lock (packet_mutex);
|
||||
/* mutex released before sleeping; re-acquired after time elapses */
|
||||
g_cond_timed_wait (packet_cond, packet_mutex, &timeval);
|
||||
got_packet = packet_arrival_time.tv_sec>0;
|
||||
g_mutex_unlock (packet_mutex);
|
||||
|
||||
if (got_packet)
|
||||
break;
|
||||
}
|
||||
if (got_packet)
|
||||
{
|
||||
fprintf(stderr, "Conky: packets arriving ...\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Conky: no data packets ...\n");
|
||||
dexter_library_exit ();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
generate_text();
|
||||
#ifdef X11
|
||||
selected_font = 0;
|
||||
update_text_area(); /* to get initial size of the window */
|
||||
@ -6944,7 +7061,7 @@ int main(int argc, char **argv)
|
||||
(own_window,
|
||||
text_width + border_margin * 2 + 1,
|
||||
text_height + border_margin * 2 + 1,
|
||||
set_transparent, background_colour, info.uname_s.nodename, argv, argc);
|
||||
set_transparent, background_colour, argv, argc);
|
||||
|
||||
selected_font = 0;
|
||||
update_text_area(); /* to position text/window on screen */
|
||||
@ -6988,6 +7105,12 @@ int main(int argc, char **argv)
|
||||
timed_thread_register (info.audacious.p_timed_thread, &info.audacious.p_timed_thread);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ***************
|
||||
* MAIN CONKY LOOP
|
||||
* ***************
|
||||
*
|
||||
*/
|
||||
main_loop();
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
@ -7004,3 +7127,119 @@ void signal_handler(int sig)
|
||||
* and do any signal processing there, NOT here. */
|
||||
g_signal_pending=sig;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBDEXTER
|
||||
void dexter_library_init (void)
|
||||
{
|
||||
/* start libdexter */
|
||||
if (dexter_client || dexter_server)
|
||||
{
|
||||
GError *error = NULL;
|
||||
dexter_init (dexter_config, &error);
|
||||
if (error)
|
||||
CRIT_ERR ("%s", error->message);
|
||||
|
||||
if (dexter_client)
|
||||
{
|
||||
if (!(info.dexter.channel = dexter_channel_new (NULL, NULL, NULL, dexter_channel_events)))
|
||||
CRIT_ERR("unable to create channel to server");
|
||||
dexter_channel_open (info.dexter.channel, &error);
|
||||
if (error)
|
||||
CRIT_ERR ("%s", error->message);
|
||||
dexter_channel_greet (info.dexter.channel, &error);
|
||||
if (error)
|
||||
CRIT_ERR ("%s", error->message);
|
||||
if (dexter_client_init () < 0)
|
||||
CRIT_ERR ("error initializing dexter client");
|
||||
|
||||
packet_mutex = g_mutex_new ();
|
||||
packet_cond = g_cond_new ();
|
||||
}
|
||||
|
||||
if (dexter_server)
|
||||
{
|
||||
if (!(info.dexter.server = dexter_server_new (NULL, NULL, NULL)))
|
||||
CRIT_ERR("unable to create server");
|
||||
dexter_server_start (info.dexter.server, &error);
|
||||
if (error)
|
||||
CRIT_ERR ("%s", error->message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void dexter_library_exit (void)
|
||||
{
|
||||
/* shutdown libdexter */
|
||||
if (dexter_client || dexter_server)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (dexter_client)
|
||||
{
|
||||
if (dexter_client_exit () < 0)
|
||||
ERR ("error de-initializing dexter client");
|
||||
if (info.dexter.channel)
|
||||
{
|
||||
dexter_channel_part (info.dexter.channel, &error);
|
||||
if (error)
|
||||
{
|
||||
ERR("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
dexter_channel_close (info.dexter.channel, &error);
|
||||
if (error)
|
||||
{
|
||||
ERR("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
dexter_channel_free (info.dexter.channel);
|
||||
info.dexter.channel=NULL;
|
||||
}
|
||||
|
||||
if (packet_mutex)
|
||||
{
|
||||
g_mutex_free (packet_mutex);
|
||||
packet_mutex=NULL;
|
||||
}
|
||||
if (packet_cond)
|
||||
{
|
||||
g_cond_free (packet_cond);
|
||||
packet_cond=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (dexter_server)
|
||||
{
|
||||
if (info.dexter.server)
|
||||
{
|
||||
dexter_server_stop (info.dexter.server, &error);
|
||||
if (error)
|
||||
{
|
||||
ERR("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
dexter_server_free (info.dexter.server);
|
||||
info.dexter.server=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
dexter_exit ();
|
||||
}
|
||||
}
|
||||
|
||||
void dexter_channel_events (DexterChannel *channel, gint event)
|
||||
{
|
||||
if (!channel)
|
||||
return;
|
||||
|
||||
/* if server disconnects we get this event. we also get it normally
|
||||
* following dexter_channel_part(). */
|
||||
if (event == DEXTER_CHANNEL_EVENT_NOCONN)
|
||||
{
|
||||
fprintf (stderr, "Conky: channel to server closed\n");
|
||||
if (dexter_client && (dexter_client_exit () < 0))
|
||||
ERR ("error de-initializing dexter client");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
45
src/conky.h
45
src/conky.h
@ -32,6 +32,10 @@
|
||||
#include <machine/apm_bios.h>
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
#ifdef HAVE_LIBDEXTER
|
||||
#include <dexter.h>
|
||||
#endif
|
||||
|
||||
#ifdef AUDACIOUS
|
||||
#include "audacious.h"
|
||||
#endif
|
||||
@ -198,6 +202,35 @@ struct entropy_s {
|
||||
#define MAX_PORT_MONITOR_CONNECTIONS_DEFAULT 256
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBDEXTER
|
||||
/* main start/stop for libdexter */
|
||||
void dexter_library_init (void);
|
||||
void dexter_library_exit (void);
|
||||
|
||||
/* os-specific init/exit for libdexter client activity */
|
||||
int dexter_client_init (void);
|
||||
int dexter_client_exit (void);
|
||||
|
||||
/* dexter channel events, i.e. we want to know if channel closes */
|
||||
void dexter_channel_events (DexterChannel *, gint);
|
||||
|
||||
/* info struct for libdexter */
|
||||
struct dexter_s {
|
||||
DexterChannel *channel;
|
||||
DexterServer *server;
|
||||
DexterServiceBroker *broker;
|
||||
};
|
||||
|
||||
/* public config items for libdexter */
|
||||
int dexter_client;
|
||||
int dexter_server;
|
||||
|
||||
/* data packet arrival time */
|
||||
struct timespec packet_arrival_time;
|
||||
GMutex *packet_mutex;
|
||||
GCond *packet_cond;
|
||||
#endif
|
||||
|
||||
enum {
|
||||
INFO_CPU = 0,
|
||||
INFO_MAIL = 1,
|
||||
@ -246,6 +279,9 @@ enum {
|
||||
#include "libmpdclient.h"
|
||||
#endif
|
||||
|
||||
/* Update interval */
|
||||
double update_interval;
|
||||
|
||||
volatile int g_signal_pending;
|
||||
|
||||
struct information {
|
||||
@ -299,6 +335,9 @@ struct information {
|
||||
unsigned long looped;
|
||||
#ifdef TCP_PORT_MONITOR
|
||||
tcp_port_monitor_collection_t * p_tcp_port_monitor_collection;
|
||||
#endif
|
||||
#ifdef HAVE_LIBDEXTER
|
||||
struct dexter_s dexter;
|
||||
#endif
|
||||
short kflags; /* kernel settings, see enum KFLAG */
|
||||
struct entropy_s entropy;
|
||||
@ -375,7 +414,8 @@ struct conky_window {
|
||||
int width;
|
||||
int height;
|
||||
#ifdef OWN_WINDOW
|
||||
char wm_class_name[256];
|
||||
char class_name[256];
|
||||
char title[256];
|
||||
int x;
|
||||
int y;
|
||||
unsigned int type;
|
||||
@ -402,7 +442,7 @@ extern int workarea[4];
|
||||
extern struct conky_window window;
|
||||
|
||||
void init_X11();
|
||||
void init_window(int use_own_window, int width, int height, int set_trans, int back_colour, char * nodename,
|
||||
void init_window(int use_own_window, int width, int height, int set_trans, int back_colour,
|
||||
char **argv, int argc);
|
||||
void create_gc();
|
||||
void set_transparent_background(Window win);
|
||||
@ -426,6 +466,7 @@ void variable_substitute(const char *s, char *dest, unsigned int n);
|
||||
void format_seconds(char *buf, unsigned int n, long t);
|
||||
void format_seconds_short(char *buf, unsigned int n, long t);
|
||||
struct net_stat *get_net_stat(const char *dev);
|
||||
void clear_net_stats(void);
|
||||
|
||||
void update_stuff();
|
||||
|
||||
|
@ -918,3 +918,20 @@ void
|
||||
free_all_processes(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBDEXTER
|
||||
/* return 0 on success, -1 on failure */
|
||||
int dexter_client_init (void)
|
||||
{
|
||||
/* init libdexter for freebsd-specific client-side activity */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* return 0 on success, -1 on failure */
|
||||
int dexter_client_exit (void)
|
||||
{
|
||||
/* de-init libdexter for freebsd-specific client-side activity */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
658
src/linux.c
658
src/linux.c
@ -32,80 +32,71 @@
|
||||
#define SHORTSTAT_TEMPL "%*s %llu %llu %llu"
|
||||
#define LONGSTAT_TEMPL "%*s %llu %llu %llu "
|
||||
|
||||
|
||||
static struct sysinfo s_info;
|
||||
#ifdef HAVE_LIBDEXTER
|
||||
/* need the procraw service from the libdexter dxt-sysinfo plugin */
|
||||
#include <dxt-sysinfo/procraw-public.h>
|
||||
#define PROCRAW_SERVICE_UUID "ce975a10-0e52-458a-a4b9-253734760436"
|
||||
/* timed sampler that delivers the procraw data */
|
||||
static DexterTimedSampler *procraw_sampler = NULL;
|
||||
/* procraw structure used as /proc surrogate */
|
||||
static DxtSysinfoProcrawData procraw_data;
|
||||
/* data selector mask for the service */
|
||||
gint procraw_mask;
|
||||
#endif
|
||||
|
||||
static int show_nice_processes;
|
||||
|
||||
/* this flags tells the linux routines to use the /proc system
|
||||
* where possible, even if other api's are available, e.g. sysinfo()
|
||||
* or getloadavg(). the reason for this is to allow for /proc-based
|
||||
* distributed monitoring. using a flag in this manner creates less
|
||||
* confusing code.
|
||||
*/
|
||||
static int prefer_proc = 0;
|
||||
|
||||
void prepare_update()
|
||||
{
|
||||
}
|
||||
|
||||
static void update_sysinfo()
|
||||
{
|
||||
sysinfo(&s_info);
|
||||
|
||||
info.uptime = (double) s_info.uptime;
|
||||
|
||||
/* there was some problem with these */
|
||||
#if 0
|
||||
// info.loadavg[0] = s_info.loads[0] / 100000.0f;
|
||||
info.loadavg[1] = s_info.loads[1] / 100000.0f;
|
||||
info.loadavg[2] = s_info.loads[2] / 100000.0f;
|
||||
gkrelltop_process_find_top_three info.mask |= 1 << INFO_LOADAVG;
|
||||
#endif
|
||||
|
||||
info.procs = s_info.procs;
|
||||
|
||||
/* these aren't nice, no cache and should check kernel version for mem_unit */
|
||||
#if 0
|
||||
info.memmax = s_info.totalram;
|
||||
info.mem = s_info.totalram - s_info.freeram;
|
||||
info.swapmax = s_info.totalswap;
|
||||
info.swap = s_info.totalswap - s_info.swap;
|
||||
info.mask |= 1 << INFO_MEM;
|
||||
#endif
|
||||
|
||||
info.mask |= (1 << INFO_UPTIME) | (1 << INFO_PROCS);
|
||||
}
|
||||
|
||||
void update_uptime()
|
||||
{
|
||||
/* prefers sysinfo() for uptime, I don't really know which one is better
|
||||
* (=faster?) */
|
||||
#ifdef USE_PROC_UPTIME
|
||||
static int rep;
|
||||
FILE *fp = open_file("/proc/uptime", &rep);
|
||||
if (!fp)
|
||||
return 0;
|
||||
#ifdef HAVE_SYSINFO
|
||||
if (!prefer_proc)
|
||||
{
|
||||
struct sysinfo s_info;
|
||||
sysinfo(&s_info);
|
||||
info.uptime = (double) s_info.uptime;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
static int rep = 0;
|
||||
FILE *fp;
|
||||
|
||||
if (!(fp = open_file("/proc/uptime", &rep)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
fscanf(fp, "%lf", &info.uptime);
|
||||
fclose(fp);
|
||||
|
||||
}
|
||||
info.mask |= (1 << INFO_UPTIME);
|
||||
#else
|
||||
update_sysinfo();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* these things are also in sysinfo except Buffers:, that's why I'm reading
|
||||
* them from proc */
|
||||
|
||||
static FILE *meminfo_fp;
|
||||
|
||||
void update_meminfo()
|
||||
{
|
||||
static int rep;
|
||||
FILE *meminfo_fp;
|
||||
static int rep = 0;
|
||||
/* unsigned int a; */
|
||||
char buf[256];
|
||||
|
||||
info.mem = info.memmax = info.swap = info.swapmax = info.bufmem =
|
||||
info.buffers = info.cached = 0;
|
||||
|
||||
if (meminfo_fp == NULL)
|
||||
meminfo_fp = open_file("/proc/meminfo", &rep);
|
||||
else
|
||||
fseek(meminfo_fp, 0, SEEK_SET);
|
||||
if (meminfo_fp == NULL)
|
||||
if (!(meminfo_fp = open_file("/proc/meminfo", &rep)))
|
||||
return;
|
||||
|
||||
while (!feof(meminfo_fp)) {
|
||||
@ -133,21 +124,21 @@ void update_meminfo()
|
||||
info.bufmem = info.cached + info.buffers;
|
||||
|
||||
info.mask |= (1 << INFO_MEM) | (1 << INFO_BUFFERS);
|
||||
|
||||
fclose (meminfo_fp);
|
||||
}
|
||||
|
||||
static FILE *net_dev_fp;
|
||||
static FILE *net_wireless_fp;
|
||||
|
||||
inline void update_net_stats()
|
||||
{
|
||||
static int rep;
|
||||
FILE *net_dev_fp;
|
||||
static int rep = 0;
|
||||
// FIXME: arbitrary size chosen to keep code simple.
|
||||
int i, i2;
|
||||
unsigned int curtmp1, curtmp2;
|
||||
unsigned int k;
|
||||
struct ifconf conf;
|
||||
|
||||
|
||||
char buf[256];
|
||||
double delta;
|
||||
|
||||
@ -157,12 +148,7 @@ inline void update_net_stats()
|
||||
return;
|
||||
|
||||
/* open file and ignore first two lines */
|
||||
if (net_dev_fp == NULL) {
|
||||
net_dev_fp = open_file("/proc/net/dev", &rep);
|
||||
}
|
||||
else
|
||||
fseek(net_dev_fp, 0, SEEK_SET);
|
||||
if (!net_dev_fp)
|
||||
if (!(net_dev_fp = open_file("/proc/net/dev", &rep)))
|
||||
return;
|
||||
|
||||
fgets(buf, 255, net_dev_fp); /* garbage */
|
||||
@ -265,17 +251,17 @@ inline void update_net_stats()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* fclose(net_dev_fp); net_dev_fp = NULL; */
|
||||
fclose(net_dev_fp);
|
||||
|
||||
info.mask |= (1 << INFO_NET);
|
||||
}
|
||||
|
||||
inline void update_wifi_stats()
|
||||
{
|
||||
/** wireless stats patch by Bobby Beckmann **/
|
||||
static int rep;
|
||||
static int rep = 0;
|
||||
int i;
|
||||
char buf[256];
|
||||
/*open file and ignore first two lines sorry, this code sucks ass right now, i'll clean it up later */
|
||||
@ -325,7 +311,27 @@ int result;
|
||||
|
||||
void update_total_processes()
|
||||
{
|
||||
update_sysinfo();
|
||||
#ifdef HAVE_SYSINFO
|
||||
if (!prefer_proc)
|
||||
{
|
||||
struct sysinfo s_info;
|
||||
sysinfo(&s_info);
|
||||
info.procs = s_info.procs;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
static int rep = 0;
|
||||
FILE *fp;
|
||||
|
||||
if (!(fp = open_file("/proc/loadavg", &rep)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
fscanf(fp, "%*f %*f %*f %*d/%hd", &info.procs );
|
||||
fclose(fp);
|
||||
}
|
||||
info.mask |= (1 << INFO_PROCS);
|
||||
}
|
||||
|
||||
#define CPU_SAMPLE_COUNT 15
|
||||
@ -345,10 +351,6 @@ struct cpu_info {
|
||||
double cpu_val[CPU_SAMPLE_COUNT];
|
||||
};
|
||||
static short cpu_setup = 0;
|
||||
static int rep;
|
||||
|
||||
|
||||
static FILE *stat_fp;
|
||||
|
||||
/*
|
||||
determine if this kernel gives us "extended" statistics information in /proc/stat.
|
||||
@ -364,15 +366,15 @@ void determine_longstat(char * buf) {
|
||||
|
||||
void get_cpu_count()
|
||||
{
|
||||
FILE *stat_fp;
|
||||
static int rep = 0;
|
||||
|
||||
if (info.cpu_usage) {
|
||||
return;
|
||||
}
|
||||
char buf[256];
|
||||
if (stat_fp == NULL)
|
||||
stat_fp = open_file("/proc/stat", &rep);
|
||||
else
|
||||
fseek(stat_fp, 0, SEEK_SET);
|
||||
if (stat_fp == NULL)
|
||||
|
||||
if (!(stat_fp = open_file("/proc/stat", &rep)))
|
||||
return;
|
||||
|
||||
info.cpu_count = 0;
|
||||
@ -389,6 +391,8 @@ void get_cpu_count()
|
||||
}
|
||||
}
|
||||
info.cpu_usage = malloc((info.cpu_count + 1) * sizeof(float));
|
||||
|
||||
fclose (stat_fp);
|
||||
}
|
||||
|
||||
#define TMPL_LONGSTAT "%*s %llu %llu %llu %llu %llu %llu %llu %llu"
|
||||
@ -396,6 +400,8 @@ void get_cpu_count()
|
||||
|
||||
inline static void update_stat()
|
||||
{
|
||||
FILE *stat_fp;
|
||||
static int rep = 0;
|
||||
static struct cpu_info *cpu = NULL;
|
||||
char buf[256];
|
||||
unsigned int i;
|
||||
@ -411,24 +417,19 @@ inline static void update_stat()
|
||||
cpu_setup = 1;
|
||||
}
|
||||
|
||||
if (stat_template == NULL) {
|
||||
if (!stat_template) {
|
||||
stat_template = KFLAG_ISSET(KFLAG_IS_LONGSTAT) ? TMPL_LONGSTAT : TMPL_SHORTSTAT ;
|
||||
}
|
||||
|
||||
if (cpu == NULL) {
|
||||
if (!cpu) {
|
||||
malloc_cpu_size = (info.cpu_count + 1) * sizeof(struct cpu_info);
|
||||
cpu = malloc(malloc_cpu_size);
|
||||
memset(cpu, 0, malloc_cpu_size);
|
||||
}
|
||||
|
||||
if (stat_fp == NULL) {
|
||||
stat_fp = open_file("/proc/stat", &rep);
|
||||
} else {
|
||||
fseek(stat_fp, 0, SEEK_SET);
|
||||
}
|
||||
if (stat_fp == NULL) {
|
||||
if (!(stat_fp = open_file("/proc/stat", &rep)))
|
||||
return;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
while (!feof(stat_fp)) {
|
||||
if (fgets(buf, 255, stat_fp) == NULL)
|
||||
@ -464,7 +465,7 @@ inline static void update_stat()
|
||||
info.mask |= (1 << INFO_CPU);
|
||||
|
||||
double delta = current_update_time - last_update_time;
|
||||
if (delta <= 0.001) return;
|
||||
if (delta <= 0.001) break;
|
||||
|
||||
cpu[index].cpu_val[0] = (cpu[index].cpu_active_total - cpu[index].cpu_last_active_total) /
|
||||
(float )(cpu[index].cpu_total - cpu[index].cpu_last_total);
|
||||
@ -490,6 +491,7 @@ inline static void update_stat()
|
||||
}
|
||||
|
||||
}
|
||||
fclose (stat_fp);
|
||||
}
|
||||
|
||||
void update_running_processes()
|
||||
@ -505,26 +507,29 @@ void update_cpu_usage()
|
||||
void update_load_average()
|
||||
{
|
||||
#ifdef HAVE_GETLOADAVG
|
||||
if (!prefer_proc)
|
||||
{
|
||||
double v[3];
|
||||
getloadavg(v, 3);
|
||||
info.loadavg[0] = (float) v[0];
|
||||
info.loadavg[1] = (float) v[1];
|
||||
info.loadavg[2] = (float) v[2];
|
||||
#else
|
||||
static int rep;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
static int rep = 0;
|
||||
FILE *fp;
|
||||
|
||||
fp = open_file("/proc/loadavg", &rep);
|
||||
if (!fp) {
|
||||
v[0] = v[1] = v[2] = 0.0;
|
||||
if (!(fp = open_file("/proc/loadavg", &rep)))
|
||||
{
|
||||
info.loadavg[0] = info.loadavg[1] = info.loadavg[2] = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
fscanf(fp, "%f %f %f", &info.loadavg[0], &info.loadavg[1],
|
||||
&info.loadavg[2]);
|
||||
|
||||
fscanf(fp, "%f %f %f", &info.loadavg[0], &info.loadavg[1], &info.loadavg[2]);
|
||||
fclose(fp);
|
||||
#endif
|
||||
}
|
||||
info.mask |= (1 << INFO_LOADAVG);
|
||||
}
|
||||
|
||||
#define PROC_I8K "/proc/i8k"
|
||||
@ -613,7 +618,7 @@ open_i2c_sensor(const char *dev, const char *type, int n, int *div,
|
||||
|
||||
/* if i2c device is NULL or *, get first */
|
||||
if (dev == NULL || strcmp(dev, "*") == 0) {
|
||||
static int rep;
|
||||
static int rep = 0;
|
||||
if (!get_first_file_in_a_directory(I2C_DIR, buf, &rep))
|
||||
return -1;
|
||||
dev = buf;
|
||||
@ -731,7 +736,7 @@ double get_i2c_info(int *fd, int div, char *devtype, char *type)
|
||||
|
||||
void get_adt746x_fan( char * p_client_buffer, size_t client_buffer_size )
|
||||
{
|
||||
static int rep;
|
||||
static int rep = 0;
|
||||
char adt746x_fan_state[64];
|
||||
FILE *fp;
|
||||
|
||||
@ -764,7 +769,7 @@ void get_adt746x_fan( char * p_client_buffer, size_t client_buffer_size )
|
||||
|
||||
void get_adt746x_cpu( char * p_client_buffer, size_t client_buffer_size )
|
||||
{
|
||||
static int rep;
|
||||
static int rep = 0;
|
||||
char adt746x_cpu_state[64];
|
||||
FILE *fp;
|
||||
|
||||
@ -855,20 +860,21 @@ void get_freq_dynamic( char * p_client_buffer, size_t client_buffer_size, char *
|
||||
char get_freq( char * p_client_buffer, size_t client_buffer_size, char * p_format, int divisor, unsigned int cpu )
|
||||
{
|
||||
FILE *f;
|
||||
static int rep = 0;
|
||||
char frequency[32];
|
||||
char s[256];
|
||||
double freq = 0;
|
||||
char current_freq_file[128];
|
||||
|
||||
cpu--;
|
||||
snprintf(current_freq_file, 127, "%s/cpu%d/%s",
|
||||
CPUFREQ_PREFIX, cpu, CPUFREQ_POSTFIX);
|
||||
|
||||
if ( !p_client_buffer || client_buffer_size <= 0 || !p_format || divisor <= 0 )
|
||||
return 0;
|
||||
|
||||
if (!prefer_proc)
|
||||
{
|
||||
char current_freq_file[128];
|
||||
snprintf(current_freq_file, 127, "%s/cpu%d/%s",CPUFREQ_PREFIX, cpu-1, CPUFREQ_POSTFIX);
|
||||
f = fopen(current_freq_file, "r");
|
||||
if (f) {
|
||||
if (f)
|
||||
{
|
||||
/* if there's a cpufreq /sys node, read the current frequency from this node;
|
||||
* divide by 1000 to get Mhz. */
|
||||
if (fgets(s, sizeof(s), f)) {
|
||||
@ -878,10 +884,10 @@ char get_freq( char * p_client_buffer, size_t client_buffer_size, char * p_forma
|
||||
fclose(f);
|
||||
snprintf( p_client_buffer, client_buffer_size, p_format, (freq/1000)/divisor );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
cpu++;
|
||||
f = fopen("/proc/cpuinfo", "r"); //open the CPU information file
|
||||
f = open_file("/proc/cpuinfo", &rep); //open the CPU information file
|
||||
if (!f) {
|
||||
perror("Conky: Failed to access '/proc/cpuinfo' at get_freq()");
|
||||
return 0;
|
||||
@ -1003,7 +1009,7 @@ char get_voltage( char * p_client_buffer, size_t client_buffer_size, char * p_fo
|
||||
|
||||
void get_acpi_fan( char * p_client_buffer, size_t client_buffer_size )
|
||||
{
|
||||
static int rep;
|
||||
static int rep = 0;
|
||||
char buf[256];
|
||||
char buf2[256];
|
||||
FILE *fp;
|
||||
@ -1038,7 +1044,7 @@ void get_acpi_fan( char * p_client_buffer, size_t client_buffer_size )
|
||||
|
||||
void get_acpi_ac_adapter( char * p_client_buffer, size_t client_buffer_size )
|
||||
{
|
||||
static int rep;
|
||||
static int rep = 0;
|
||||
char buf[256];
|
||||
char buf2[256];
|
||||
FILE *fp;
|
||||
@ -1094,7 +1100,7 @@ int open_acpi_temperature(const char *name)
|
||||
int fd;
|
||||
|
||||
if (name == NULL || strcmp(name, "*") == 0) {
|
||||
static int rep;
|
||||
static int rep = 0;
|
||||
if (!get_first_file_in_a_directory
|
||||
(ACPI_THERMAL_DIR, buf, &rep))
|
||||
return -1;
|
||||
@ -1199,7 +1205,7 @@ static double last_battery_time;
|
||||
|
||||
void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
|
||||
{
|
||||
static int rep, rep2;
|
||||
static int rep = 0, rep2 = 0;
|
||||
char acpi_path[128];
|
||||
snprintf(acpi_path, 127, ACPI_BATTERY_BASE_PATH "/%s/state", bat);
|
||||
|
||||
@ -1225,7 +1231,7 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
|
||||
|
||||
/* read last full capacity if it's zero */
|
||||
if (acpi_last_full == 0) {
|
||||
static int rep;
|
||||
static int rep = 0;
|
||||
char path[128];
|
||||
FILE *fp;
|
||||
snprintf(path, 127,
|
||||
@ -1396,7 +1402,7 @@ static double pb_battery_info_update;
|
||||
#define PMU_PATH "/proc/pmu"
|
||||
void get_powerbook_batt_info(char *buf, size_t n, int i)
|
||||
{
|
||||
static int rep;
|
||||
static int rep = 0;
|
||||
const char* batt_path = PMU_PATH "/battery_0";
|
||||
const char* info_path = PMU_PATH "/info";
|
||||
int flags, charge, max_charge, ac = -1;
|
||||
@ -1503,7 +1509,8 @@ void update_top()
|
||||
void update_diskio()
|
||||
{
|
||||
static unsigned int last = UINT_MAX;
|
||||
static FILE* fp;
|
||||
FILE* fp;
|
||||
static int rep=0;
|
||||
|
||||
char buf[512];
|
||||
int major, minor;
|
||||
@ -1511,11 +1518,8 @@ void update_diskio()
|
||||
unsigned int reads, writes = 0;
|
||||
int col_count = 0;
|
||||
|
||||
if (!fp) {
|
||||
fp = fopen("/proc/diskstats", "r");
|
||||
} else {
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
}
|
||||
if (!(fp =open_file("/proc/diskstats", &rep)))
|
||||
return;
|
||||
|
||||
/* read reads and writes from all disks (minor = 0), including
|
||||
* cd-roms and floppies, and summ them up
|
||||
@ -1551,6 +1555,8 @@ void update_diskio()
|
||||
last = current;
|
||||
|
||||
diskio_value = tot;
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
/* Here come the IBM ACPI-specific things. For reference, see
|
||||
@ -1780,7 +1786,7 @@ Peter Tarjan (ptarjan@citromail.hu)
|
||||
|
||||
void update_entropy (void)
|
||||
{
|
||||
static int rep;
|
||||
static int rep = 0;
|
||||
const char *entropy_avail = "/proc/sys/kernel/random/entropy_avail";
|
||||
const char *entropy_poolsize = "/proc/sys/kernel/random/poolsize";
|
||||
FILE *fp1, *fp2;
|
||||
@ -1802,4 +1808,422 @@ void update_entropy (void)
|
||||
|
||||
fclose (fp1);
|
||||
fclose (fp2);
|
||||
|
||||
info.mask |= (1 << INFO_ENTROPY);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBDEXTER
|
||||
FILE *open_file(const char *file, int *reported)
|
||||
{
|
||||
/* this version of open_file() is the hook that ties the client/server code
|
||||
* into conky. if conky wants to open a /proc file that the server is feeding
|
||||
* us, we do not return an ordinary file stream pointer to the local /proc
|
||||
* filesystem. instead, we return a string stream pointer to the proc surrogate,
|
||||
* so conky parses remote data as if it were local.
|
||||
*/
|
||||
FILE *fp;
|
||||
|
||||
if ((strcmp (file,"/proc/cpuinfo")==0) && (procraw_mask & PROCRAW_CPUINFO))
|
||||
{
|
||||
if (!procraw_sampler)
|
||||
return NULL;
|
||||
fp = fmemopen (procraw_data.cpuinfo, procraw_data.cpuinfo_sz, "r");
|
||||
}
|
||||
else if ((strcmp (file,"/proc/loadavg")==0) && (procraw_mask & PROCRAW_LOADAVG))
|
||||
{
|
||||
if (!procraw_sampler)
|
||||
return NULL;
|
||||
fp = fmemopen (procraw_data.loadavg, procraw_data.loadavg_sz, "r");
|
||||
}
|
||||
else if ((strcmp (file,"/proc/meminfo")==0) && (procraw_mask & PROCRAW_MEMINFO))
|
||||
{
|
||||
if (!procraw_sampler)
|
||||
return NULL;
|
||||
fp = fmemopen (procraw_data.meminfo, procraw_data.meminfo_sz, "r");
|
||||
}
|
||||
else if ((strcmp (file,"/proc/stat")==0) && (procraw_mask & PROCRAW_STAT))
|
||||
{
|
||||
if (!procraw_sampler)
|
||||
return NULL;
|
||||
fp = fmemopen (procraw_data.stat, procraw_data.stat_sz, "r");
|
||||
}
|
||||
else if ((strcmp (file,"/proc/uptime")==0) && (procraw_mask & PROCRAW_UPTIME))
|
||||
{
|
||||
if (!procraw_sampler)
|
||||
return NULL;
|
||||
fp = fmemopen (procraw_data.uptime, procraw_data.uptime_sz, "r");
|
||||
}
|
||||
else if ((strcmp (file,"/proc/net/dev")==0) && (procraw_mask & PROCRAW_NET_DEV))
|
||||
{
|
||||
if (!procraw_sampler)
|
||||
return NULL;
|
||||
fp = fmemopen (procraw_data.net_dev, procraw_data.net_dev_sz, "r");
|
||||
}
|
||||
else if ((strcmp (file,"/proc/diskstats")==0) && (procraw_mask & PROCRAW_DISKSTATS))
|
||||
{
|
||||
if (!procraw_sampler)
|
||||
return NULL;
|
||||
fp = fmemopen (procraw_data.diskstats, procraw_data.diskstats_sz, "r");
|
||||
}
|
||||
else
|
||||
{
|
||||
fp = fopen(file, "r");
|
||||
}
|
||||
|
||||
if (!fp)
|
||||
{
|
||||
if (!reported || *reported == 0)
|
||||
{
|
||||
ERR("can't open %s: %s", file, strerror(errno));
|
||||
if (reported)
|
||||
*reported = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
void sampler_data_callback (gpointer sampler, gpointer sampler_data)
|
||||
{
|
||||
/* callback runs in a thread */
|
||||
if (!sampler)
|
||||
return;
|
||||
|
||||
if (sampler_data)
|
||||
{
|
||||
FILE *out;
|
||||
char *p;
|
||||
unsigned int i;
|
||||
DxtSysinfoProcrawData *data = (DxtSysinfoProcrawData *)sampler_data;
|
||||
|
||||
/* use GNU string streams and stdio locking to exchange data with main thread. */
|
||||
|
||||
/* update /proc/cpuinfo surrogate */
|
||||
for (;data->cpuinfo;)
|
||||
{
|
||||
if (!(out = open_memstream (&procraw_data.cpuinfo, &procraw_data.cpuinfo_sz)))
|
||||
break;
|
||||
|
||||
flockfile (out);
|
||||
if (procraw_data.cpuinfo)
|
||||
{
|
||||
free (procraw_data.cpuinfo); procraw_data.cpuinfo=NULL;
|
||||
}
|
||||
for (p=data->cpuinfo, i=0; i<data->cpuinfo_sz; i++, p++)
|
||||
{
|
||||
/* we have the FILE lock so use faster putc_unlocked() */
|
||||
if (fputc_unlocked (*p, out) == EOF)
|
||||
break;
|
||||
}
|
||||
fclose (out);
|
||||
funlockfile (out);
|
||||
break;
|
||||
}
|
||||
|
||||
/* update /proc/loadavg surrogate */
|
||||
for (;data->loadavg;)
|
||||
{
|
||||
if (!(out = open_memstream (&procraw_data.loadavg, &procraw_data.loadavg_sz)))
|
||||
break;
|
||||
|
||||
flockfile (out);
|
||||
if (procraw_data.loadavg)
|
||||
{
|
||||
free (procraw_data.loadavg); procraw_data.loadavg=NULL;
|
||||
}
|
||||
for (p=data->loadavg, i=0; i<data->loadavg_sz; i++, p++)
|
||||
{
|
||||
/* we have the FILE lock so use faster putc_unlocked() */
|
||||
if (fputc_unlocked (*p, out) == EOF)
|
||||
break;
|
||||
}
|
||||
fclose (out);
|
||||
funlockfile (out);
|
||||
break;
|
||||
}
|
||||
|
||||
/* update /proc/meminfo surrogate */
|
||||
for (;data->meminfo;)
|
||||
{
|
||||
if (!(out = open_memstream (&procraw_data.meminfo, &procraw_data.meminfo_sz)))
|
||||
break;
|
||||
|
||||
flockfile (out);
|
||||
if (procraw_data.meminfo)
|
||||
{
|
||||
free (procraw_data.meminfo); procraw_data.meminfo=NULL;
|
||||
}
|
||||
for (p=data->meminfo, i=0; i<data->meminfo_sz; i++, p++)
|
||||
{
|
||||
/* we have the FILE lock so use faster putc_unlocked() */
|
||||
if (fputc_unlocked (*p, out) == EOF)
|
||||
break;
|
||||
}
|
||||
fclose (out);
|
||||
funlockfile (out);
|
||||
break;
|
||||
}
|
||||
|
||||
/* update /proc/stat surrogate */
|
||||
for (;data->stat;)
|
||||
{
|
||||
if (!(out = open_memstream (&procraw_data.stat, &procraw_data.stat_sz)))
|
||||
break;
|
||||
|
||||
flockfile (out);
|
||||
if (procraw_data.stat)
|
||||
{
|
||||
free (procraw_data.stat); procraw_data.stat=NULL;
|
||||
}
|
||||
for (p=data->stat, i=0; i<data->stat_sz; i++, p++)
|
||||
{
|
||||
/* we have the FILE lock so use faster putc_unlocked() */
|
||||
if (fputc_unlocked (*p, out) == EOF)
|
||||
break;
|
||||
}
|
||||
fclose (out);
|
||||
funlockfile (out);
|
||||
break;
|
||||
}
|
||||
|
||||
/* update /proc/uptime surrogate */
|
||||
for (;data->uptime;)
|
||||
{
|
||||
if (!(out = open_memstream (&procraw_data.uptime, &procraw_data.uptime_sz)))
|
||||
break;
|
||||
|
||||
flockfile (out);
|
||||
if (procraw_data.uptime)
|
||||
{
|
||||
free (procraw_data.uptime); procraw_data.uptime=NULL;
|
||||
}
|
||||
for (p=data->uptime, i=0; i<data->uptime_sz; i++, p++)
|
||||
{
|
||||
/* we have the FILE lock so use faster putc_unlocked() */
|
||||
if (fputc_unlocked (*p, out) == EOF)
|
||||
break;
|
||||
}
|
||||
fclose (out);
|
||||
funlockfile (out);
|
||||
break;
|
||||
}
|
||||
|
||||
/* update /proc/net/dev surrogate */
|
||||
for (;data->net_dev;)
|
||||
{
|
||||
if (!(out = open_memstream (&procraw_data.net_dev, &procraw_data.net_dev_sz)))
|
||||
break;
|
||||
|
||||
flockfile (out);
|
||||
if (procraw_data.net_dev)
|
||||
{
|
||||
free (procraw_data.net_dev); procraw_data.net_dev=NULL;
|
||||
}
|
||||
for (p=data->net_dev, i=0; i<data->net_dev_sz; i++, p++)
|
||||
{
|
||||
/* we have the FILE lock so use faster putc_unlocked() */
|
||||
if (fputc_unlocked (*p, out) == EOF)
|
||||
break;
|
||||
}
|
||||
fclose (out);
|
||||
funlockfile (out);
|
||||
break;
|
||||
}
|
||||
|
||||
/* update /proc/diskstats surrogate */
|
||||
for (;data->diskstats;)
|
||||
{
|
||||
if (!(out = open_memstream (&procraw_data.diskstats, &procraw_data.diskstats_sz)))
|
||||
break;
|
||||
|
||||
flockfile (out);
|
||||
if (procraw_data.diskstats)
|
||||
{
|
||||
free (procraw_data.diskstats); procraw_data.diskstats=NULL;
|
||||
}
|
||||
for (p=data->diskstats, i=0; i<data->diskstats_sz; i++, p++)
|
||||
{
|
||||
/* we have the FILE lock so use faster putc_unlocked() */
|
||||
if (fputc_unlocked (*p, out) == EOF)
|
||||
break;
|
||||
}
|
||||
fclose (out);
|
||||
funlockfile (out);
|
||||
break;
|
||||
}
|
||||
|
||||
/* record data packet arrival time */
|
||||
g_mutex_lock (packet_mutex);
|
||||
clock_gettime (CLOCK_REALTIME, &packet_arrival_time);
|
||||
g_mutex_unlock (packet_mutex);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Conky: data packet arrived\n");
|
||||
#endif
|
||||
|
||||
} /* if (sampler_data) ... */
|
||||
}
|
||||
|
||||
/* return 0 on success, -1 on failure */
|
||||
int dexter_client_init (void)
|
||||
{
|
||||
/* init libdexter for linux-specific client-side activity */
|
||||
|
||||
DexterServiceBroker *broker;
|
||||
DexterPluginServiceGroup *service_group;
|
||||
DexterPluginService *procraw_service;
|
||||
DexterSamplerDataCallback *callbacks;
|
||||
GError *error = NULL;
|
||||
|
||||
/* create a service broker so we can query the server for its services */
|
||||
if (!(broker = dexter_service_broker_new (info.dexter.channel)))
|
||||
{
|
||||
ERR ("unable to create service broker");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* fetch the services from the server */
|
||||
service_group = dexter_service_broker_get_services (broker, DEXTER_SERVICE_SAMPLER, &error);
|
||||
if (error)
|
||||
{
|
||||
ERR("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
dexter_service_broker_free (broker);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* dont need service broker any more */
|
||||
dexter_service_broker_free (broker);
|
||||
broker=NULL;
|
||||
|
||||
/* find the procraw service */
|
||||
procraw_service=NULL;
|
||||
if (!dexterplugin_service_group_find_uuid (&procraw_service, service_group, PROCRAW_SERVICE_UUID))
|
||||
{
|
||||
ERR ("server doesn't offer the procraw service: (%s)", PROCRAW_SERVICE_UUID);
|
||||
dexterplugin_service_group_free (service_group);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* create null-terminated callback list with one callback on it */
|
||||
callbacks = g_new0 (DexterSamplerDataCallback, 2);
|
||||
callbacks[0] = sampler_data_callback;
|
||||
|
||||
/* create the procraw timed sampler, timed to match conky's update_interval */
|
||||
procraw_sampler = dexter_timedsampler_new (procraw_service, update_interval*G_USEC_PER_SEC,
|
||||
callbacks, info.dexter.channel, &error);
|
||||
if (error)
|
||||
{
|
||||
ERR("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
dexterplugin_service_group_free (service_group);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* free callbacks as libdexter makes internal copy */
|
||||
g_free (callbacks);
|
||||
callbacks=NULL;
|
||||
|
||||
/* initialize the timed sampler */
|
||||
procraw_mask = 0;
|
||||
if (need_mask & (1 << INFO_FREQ))
|
||||
procraw_mask |= PROCRAW_CPUINFO;
|
||||
if (need_mask & (1 << INFO_LOADAVG))
|
||||
procraw_mask |= PROCRAW_LOADAVG;
|
||||
if ((need_mask & (1 << INFO_MEM)) || (need_mask & (1 << INFO_BUFFERS)))
|
||||
procraw_mask |= PROCRAW_MEMINFO;
|
||||
if ((need_mask & (1 << INFO_CPU)) || (need_mask & (1 << INFO_PROCS)) ||
|
||||
(need_mask & (1 << INFO_RUN_PROCS)) || (need_mask & (1 << INFO_FREQ )))
|
||||
procraw_mask |= PROCRAW_STAT;
|
||||
if (need_mask & (1 << INFO_UPTIME))
|
||||
procraw_mask |= PROCRAW_UPTIME;
|
||||
if (need_mask & (1 << INFO_NET))
|
||||
procraw_mask |= PROCRAW_NET_DEV;
|
||||
if (need_mask & (1 << INFO_DISKIO))
|
||||
procraw_mask |= PROCRAW_DISKSTATS;
|
||||
|
||||
dexter_timedsampler_initialize (procraw_sampler, &procraw_mask, NULL, &error);
|
||||
if (error)
|
||||
{
|
||||
ERR("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
dexter_timedsampler_free (procraw_sampler, NULL);
|
||||
dexterplugin_service_group_free (service_group);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* start the timed sampler and begin receiving updates from server */
|
||||
dexter_timedsampler_start (procraw_sampler, &error);
|
||||
if (error)
|
||||
{
|
||||
ERR("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
dexter_timedsampler_free (procraw_sampler, NULL);
|
||||
dexterplugin_service_group_free (service_group);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
dexterplugin_service_group_free (service_group);
|
||||
|
||||
/* so far, so good. tell the linux routines to read /proc,
|
||||
* even if other api's are available. */
|
||||
prefer_proc = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* return 0 on success, -1 on failure */
|
||||
int dexter_client_exit (void)
|
||||
{
|
||||
/* de-init libdexter for linux-specific client-side activity */
|
||||
|
||||
if (procraw_sampler)
|
||||
{
|
||||
dexter_timedsampler_stop (procraw_sampler, NULL);
|
||||
dexter_timedsampler_free (procraw_sampler, NULL);
|
||||
procraw_sampler=NULL;
|
||||
}
|
||||
|
||||
/* free left-over sampler data. ok to do this without thread sync because
|
||||
* this function runs in the same thread that conky issues open_file(). */
|
||||
if (procraw_data.cpuinfo)
|
||||
{
|
||||
free (procraw_data.cpuinfo); procraw_data.cpuinfo=NULL;
|
||||
}
|
||||
if (procraw_data.loadavg)
|
||||
{
|
||||
free (procraw_data.loadavg); procraw_data.loadavg=NULL;
|
||||
}
|
||||
if (procraw_data.meminfo)
|
||||
{
|
||||
free (procraw_data.meminfo); procraw_data.meminfo=NULL;
|
||||
}
|
||||
if (procraw_data.stat)
|
||||
{
|
||||
free (procraw_data.stat); procraw_data.stat=NULL;
|
||||
}
|
||||
if (procraw_data.uptime)
|
||||
{
|
||||
free (procraw_data.uptime); procraw_data.uptime=NULL;
|
||||
}
|
||||
if (procraw_data.net_dev)
|
||||
{
|
||||
free (procraw_data.net_dev); procraw_data.net_dev=NULL;
|
||||
}
|
||||
if (procraw_data.diskstats)
|
||||
{
|
||||
free (procraw_data.diskstats); procraw_data.diskstats=NULL;
|
||||
}
|
||||
|
||||
info.uptime=0.0;
|
||||
info.procs=0;
|
||||
info.mem = info.memmax = info.swap = info.swapmax = info.bufmem = info.buffers = info.cached = 0;
|
||||
info.run_procs=0;
|
||||
if (info.cpu_usage)
|
||||
{
|
||||
memset(info.cpu_usage, 0, info.cpu_count * sizeof (float));
|
||||
}
|
||||
clear_net_stats ();
|
||||
diskio_value=0;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
17
src/netbsd.c
17
src/netbsd.c
@ -370,3 +370,20 @@ void get_acpi_fan( char * p_client_buffer, size_t client_buffer_size )
|
||||
void update_entropy (void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBDEXTER
|
||||
/* return 0 on success, -1 on failure */
|
||||
int dexter_client_init (void)
|
||||
{
|
||||
/* init libdexter for netbsd-specific client-side activity */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* return 0 on success, -1 on failure */
|
||||
int dexter_client_exit (void)
|
||||
{
|
||||
/* de-init libdexter for netbsd-specific client-side activity */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* This program is licensed under BSD license, read COPYING
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
okay, nothing here right now. thanks for coming out
|
||||
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#define PORT 3490 // the port client will be connecting to
|
||||
|
||||
#define MAXDATASIZE 100 // max number of bytes we can get at once
|
||||
|
||||
void client()
|
||||
{
|
||||
int sockfd, numbytes;
|
||||
char buf[MAXDATASIZE];
|
||||
struct hostent *he;
|
||||
struct sockaddr_in their_addr; // connector's address information
|
||||
if ((he=gethostbyname("localhost")) == NULL) { // get the host info
|
||||
perror("gethostbyname");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||
perror("socket");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
their_addr.sin_family = AF_INET; // host byte order
|
||||
their_addr.sin_port = htons(PORT); // short, network byte order
|
||||
their_addr.sin_addr = *((struct in_addr *)he->h_addr);
|
||||
memset(&(their_addr.sin_zero), '\0', 8); // zero the rest of the struct
|
||||
|
||||
if (connect(sockfd, (struct sockaddr *)&their_addr,
|
||||
sizeof(struct sockaddr)) == -1) {
|
||||
perror("connect");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) == -1) {
|
||||
perror("recv");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
buf[numbytes] = '\0';
|
||||
|
||||
printf("Received: %s",buf);
|
||||
|
||||
close(sockfd);
|
||||
|
||||
return;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* This program is licensed under BSD license, read COPYING
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
okay, nothing here right now. thanks for coming out
|
||||
|
||||
*/
|
||||
|
||||
void client();
|
126
src/remoted.c
126
src/remoted.c
@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* This program is licensed under BSD license, read COPYING
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
|
||||
static pthread_t daemon_thread;
|
||||
static int daemon_status = 0;
|
||||
static char *data;
|
||||
|
||||
/* okay, heres how it will basically work.
|
||||
* when something connects, it will first send the conkyrc on the local (daemonized) server
|
||||
* after this, it will simply continue to send all the buffered text to the remote client
|
||||
* http://analyser.oli.tudelft.nl/beej/mirror/net/html/
|
||||
* http://www.kegel.com/c10k.html
|
||||
*/
|
||||
|
||||
#define MYPORT 3490 // the port users will be connecting to
|
||||
|
||||
#define BACKLOG 10 // how many pending connections queue will hold
|
||||
|
||||
void sigchld_handler(/*int s*/)
|
||||
{
|
||||
while(wait(NULL) > 0);
|
||||
}
|
||||
|
||||
void *daemon_loop()
|
||||
{
|
||||
/* do something */
|
||||
|
||||
|
||||
|
||||
int sockfd, new_fd; // listen on sock_fd, new connection on new_fd
|
||||
struct sockaddr_in my_addr; // my address information
|
||||
struct sockaddr_in their_addr; // connector's address information
|
||||
socklen_t sin_size;
|
||||
struct sigaction sa;
|
||||
int yes=1;
|
||||
|
||||
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||
perror("socket");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(int)) == -1) {
|
||||
perror("setsockopt");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
my_addr.sin_family = AF_INET; // host byte order
|
||||
my_addr.sin_port = htons(MYPORT); // short, network byte order
|
||||
my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP
|
||||
memset(&(my_addr.sin_zero), '\0', 8); // zero the rest of the struct
|
||||
|
||||
if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr))
|
||||
== -1) {
|
||||
perror("bind");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (listen(sockfd, BACKLOG) == -1) {
|
||||
perror("listen");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sa.sa_handler = sigchld_handler; // reap all dead processes
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = SA_RESTART;
|
||||
if (sigaction(SIGCHLD, &sa, NULL) == -1) {
|
||||
perror("sigaction");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while(1) { // main accept() loop
|
||||
sin_size = sizeof(struct sockaddr_in);
|
||||
if ((new_fd = accept(sockfd, (struct sockaddr *)&their_addr,
|
||||
&sin_size)) == -1) {
|
||||
perror("accept");
|
||||
continue;
|
||||
}
|
||||
printf("server: got connection from %s\n",
|
||||
inet_ntoa(their_addr.sin_addr));
|
||||
if (!fork()) { // this is the child process
|
||||
close(sockfd); // child doesn't need the listener
|
||||
if (send(new_fd, data, 14, 0) == -1)
|
||||
perror("send");
|
||||
close(new_fd);
|
||||
exit(0);
|
||||
}
|
||||
close(new_fd); // parent doesn't need this
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void daemon_run(const char *s)
|
||||
{
|
||||
/* create thread, keep an eye on it */
|
||||
data = (char *)s;
|
||||
int iret;
|
||||
if (!daemon_status) {
|
||||
daemon_status = 1;
|
||||
iret = pthread_create(&daemon_thread, NULL, daemon_loop, NULL);
|
||||
} else if (daemon_status == 1) {
|
||||
/* thread is still running, we'll just wait for it to finish for now */
|
||||
pthread_join(daemon_thread, NULL);
|
||||
daemon_status = 0;
|
||||
} else {
|
||||
/* something else */
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
/*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* This program is licensed under BSD license, read COPYING
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
|
||||
void daemon_run(const char *s);
|
16
src/x11.c
16
src/x11.c
@ -26,8 +26,6 @@ int use_xdbe;
|
||||
int use_xft = 0;
|
||||
#endif
|
||||
|
||||
#define WINDOW_NAME_FMT "%s - conky"
|
||||
|
||||
/* some basic X11 stuff */
|
||||
Display *display;
|
||||
int display_width;
|
||||
@ -185,7 +183,7 @@ inline void set_transparent_background(Window win)
|
||||
//XClearWindow(display, win); not sure why this was here
|
||||
}
|
||||
|
||||
void init_window(int own_window, int w, int h, int set_trans, int back_colour, char * nodename,
|
||||
void init_window(int own_window, int w, int h, int set_trans, int back_colour,
|
||||
char **argv, int argc)
|
||||
{
|
||||
/* There seems to be some problems with setting transparent background (on
|
||||
@ -194,8 +192,6 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c
|
||||
set_transparent = set_trans;
|
||||
background_colour = back_colour;
|
||||
|
||||
nodename = (char *)nodename;
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
if (own_window) {
|
||||
|
||||
@ -245,7 +241,6 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c
|
||||
XClassHint classHint;
|
||||
XWMHints wmHint;
|
||||
Atom xa;
|
||||
char window_title[256];
|
||||
|
||||
/* Parent is root window so WM can take control */
|
||||
window.window = XCreateWindow(display,
|
||||
@ -257,16 +252,15 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c
|
||||
CWBackPixel|CWOverrideRedirect,
|
||||
&attrs);
|
||||
|
||||
classHint.res_name = window.wm_class_name;
|
||||
classHint.res_name = window.class_name;
|
||||
classHint.res_class = classHint.res_name;
|
||||
|
||||
wmHint.flags = InputHint | StateHint;
|
||||
wmHint.input = False;
|
||||
/* allow decorated windows to be given input focus by WM */
|
||||
wmHint.input = TEST_HINT(window.hints,HINT_UNDECORATED) ? False : True;
|
||||
wmHint.initial_state = NormalState;
|
||||
|
||||
sprintf(window_title,WINDOW_NAME_FMT,nodename);
|
||||
|
||||
XmbSetWMProperties (display, window.window, window_title, NULL,
|
||||
XmbSetWMProperties (display, window.window, window.title, NULL,
|
||||
argv, argc,
|
||||
NULL, &wmHint, &classHint);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user