1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-23 19:39:06 +00:00

removal of xmms/bmp / addition of audacious/infopipe

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@713 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Philip Kovacs 2006-11-03 20:54:52 +00:00
parent a5de2b09d9
commit 87953b122b
16 changed files with 1301 additions and 1107 deletions

View File

@ -1,5 +1,14 @@
# $Id$
2006-11-03 pkovacs
* Removed direct xmms support from conky. The Xmms and Bmp players
are now no longer directly supported as those projects are dead and
distros such as gentoo are slated them for removal.
* Added direct support for Audacious and Infopipe plugin via two new
sets of variables (audacious_ and infopipe_). Users can still view
Xmms and Bmp status within conky by use of the Infopipe support.
* Conky no longer loads Audacious music player library dynamically.
2006-10-18
* Implement WiFi signal level detection on FreeBSD (patch
by Stepan Zastupov)

190
README
View File

@ -43,10 +43,11 @@ 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-seti --enable-double-buffer
--enable-own-window --enable-proc-uptime --enable-mpd --enable-mldonkey
--enable-x11 --enable-portmon --enable-xmms --enable-bmp --enable-auda-
cious --enable-infopipe --enable-bmpx
statedir=/var/lib --enable-xft --enable-own-window --enable-proc-uptime
--enable-audacious --enable-infopipe --enable-bmpx --enable-seti --en-
able-hddtemp --enable-mpd --enable-xmms2 --enable-imlib2 --enable-port-
mon --enable-mldonkey --enable-debug --enable-double-buffer --en-
able-xdamage --enable-x11
make
@ -367,12 +368,6 @@ CONFIGURATION SETTINGS
Xft font to use.
xmms_player
Use specified player/plugin for the xmms status variables. Valid
items are: none, xmms, bmp, audacious and infopipe. (default is
none). Note that bmpx is currently handled separately.
TEXT After this begins text to be formatted on screen
@ -432,6 +427,58 @@ VARIABLES
AC adapterstatus is on-line or charging (FreeBSD only)
audacious_bar (height),(width)
Progress bar
audacious_bitrate
Bitrate of current tune
audacious_channels
Number of audio channels of current tune
audacious_filename
Full path and filename of current tune
audacious_frequency
Sampling frequency of current tune
audacious_length
Total length of current tune as MM:SS
audacious_length_seconds
Total length of current tune in seconds
audacious_playlist_position
Playlist position of current tune
audacious_playlist_length
Number of tunes in playlist
audacious_position
Position of current tune (MM:SS)
audacious_position_seconds
Position of current tune in seconds
audacious_status
Player status (Playing/Paused/Stopped/Not running)
audacious_title
Title of current tune
battery (num)
Remaining capacity in ACPI or APM battery. ACPI battery number
can be given as argument (default is BAT0).
@ -748,6 +795,58 @@ VARIABLES
you will be prompted to enter the password when Conky starts.
infopipe_bar (height),(width)
Progress bar
infopipe_bitrate
Bitrate of current tune
infopipe_channels
Number of audio channels of current tune
infopipe_filename
Full path and filename of current tune
infopipe_frequency
Sampling frequency of current tune
infopipe_length
Total length of current tune as MM:SS
infopipe_length_seconds
Total length of current tune in seconds
infopipe_playlist_position
Playlist position of current tune
infopipe_playlist_length
Number of tunes in playlist
infopipe_position
Position of current tune (MM:SS)
infopipe_position_seconds
Position of current tune in seconds
infopipe_status
Player status (Playing/Paused/Stopped/Not running)
infopipe_title
Title of current tune
kernel Kernel version
@ -1089,67 +1188,6 @@ VARIABLES
ted, the parameter defaults to 1.
xmms_bar (height),(width)
xmms / bmp / audacious / infopipe: progress bar
xmms_bitrate
xmms / bmp / audacious / infopipe: bitrate of current tune
xmms_channels
xmms / bmp / audacious / infopipe: number of audio channels of
current tune
xmms_filename
xmms / bmp / audacious / infopipe: full path and filename of
current tune
xmms_frequency
xmms / bmp / audacious / infopipe: sampling frequency of current
tune
xmms_length
xmms / bmp / audacious / infopipe: total length of current tune
as MM:SS
xmms_length_seconds
xmms / bmp / audacious / infopipe: total length of current tune
in seconds
xmms_playlist_position
xmms / bmp / audacious / infopipe: playlist position of current
tune
xmms_playlist_length
xmms / bmp / audacious / infopipe: number of tunes in playlist
xmms_position
xmms / bmp / audacious / infopipe: MM:SS position of current
tune
xmms_position_seconds
xmms / bmp / audacious / infopipe: position of current tune in
seconds
xmms_status
xmms / bmp / audacious / infopipe: player status (Play-
ing/Paused/Stopped/Not running)
xmms_title
xmms / bmp / audacious / infopipe: title of current tune
EXAMPLES
conky -t '${time %D %H:%m}' -o -u 30
Start Conky in its own window with date and clock as text and 30
@ -1164,11 +1202,11 @@ FILES
BUGS
Drawing to root or some other desktop window directly doesn't work with
all window managers. Especially doesn't work well with Gnome and it has
been reported that it doesn't work with KDE either. Nautilus can be
disabled from drawing to desktop with program gconf-editor. Uncheck
show_desktop in /apps/nautilus/preferences/. There is -w switch in
Conky to set some specific window id. You might find xwininfo -tree
useful to find the window to draw to. You can also use -o argument
been reported that it doesn't work with KDE either. Nautilus can be
disabled from drawing to desktop with program gconf-editor. Uncheck
show_desktop in /apps/nautilus/preferences/. There is -w switch in
Conky to set some specific window id. You might find xwininfo -tree
useful to find the window to draw to. You can also use -o argument
which makes Conky to create its own window.
SEE ALSO

View File

@ -102,106 +102,6 @@ if test $dah = "yes"; then
AC_DEFINE(PROC_UPTIME, 1, [Define if you want to use /proc/uptime for uptime])
fi
dnl
dnl XMMS (Version 1)
dnl
want_xmms=auto
AC_ARG_ENABLE(xmms,
[ --enable-xmms enable xmms (ver. 1) media player support [[default=auto]]],
[want_xmms="$enableval"])
case x$want_xmms in
xauto)
want_xmms=yes
## its ok to favor the glib 2.0 headers over 1.2 for our purposes ##
PKG_CHECK_MODULES([XMMS], [glib-2.0], [], [PKG_CHECK_MODULES([XMMS], [glib-1.2], [], [want_xmms=no])])
if test x$want_xmms = xyes; then
AC_CHECK_HEADERS([dlfcn.h], [], [want_xmms=no])
if test x$want_xmms = xyes; then
AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"],
[AC_CHECK_FUNCS(dlopen,[],
[want_xmms=no])])
if test x$want_xmms = xyes; then
CFLAGS="$CFLAGS $XMMS_CFLAGS"
### if we link to glib 1.2, that means 2.0 wasn't found ###
### if we link to glib 2.0, that's ok, we will load libglib-1.2.so.0 dynamically ###
LIBS="$LIBS $XMMS_LIBS"
AC_DEFINE(XMMS, 1, [Define for XMMS Ver. 1 support])
fi
fi
fi
;;
xyes)
## its ok to favor the glib 2.0 headers over 1.2 for our purposes ##
PKG_CHECK_MODULES([XMMS], [glib-2.0], [], [PKG_CHECK_MODULES([XMMS], [glib-1.2])])
CFLAGS="$CFLAGS $XMMS_CFLAGS"
### if we link to glib 1.2, that means 2.0 wasn't found ###
### if we link to glib 2.0, that's ok, we will load libglib-1.2.so.0 dynamically ###
LIBS="$LIBS $XMMS_LIBS"
AC_CHECK_HEADERS([dlfcn.h], [],
[AC_MSG_ERROR(["dlfcn.h not found: dynamic library loading not supported"])])
AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"],
[AC_CHECK_FUNCS(dlopen,[],
[AC_MSG_ERROR([dlopen() not available])])])
AC_DEFINE(XMMS, 1, [Define for XMMS Ver. 1 support])
;;
xno)
;;
*)
echo "Error: invalid xmms parameter specified: $want_xmms"
exit -1
;;
esac
AM_CONDITIONAL(BUILD_XMMS, test x$want_xmms = xyes)
dnl
dnl BMP (through 0.9.7.1)
dnl
want_bmp=auto
AC_ARG_ENABLE(bmp,
[ --enable-bmp enable beep media media player support [[default=auto]]],
[want_bmp="$enableval"])
case x$want_bmp in
xauto)
want_bmp=yes
PKG_CHECK_MODULES([BMP], [glib-2.0], [], [want_bmp=no])
if test x$want_bmp = xyes; then
AC_CHECK_HEADERS([dlfcn.h], [], [want_bmp=no])
if test x$want_bmp = xyes; then
AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"],
[AC_CHECK_FUNCS(dlopen,[],
[want_bmp=no])])
if test x$want_bmp = xyes; then
CFLAGS="$CFLAGS $BMP_CFLAGS"
LIBS="$LIBS $BMP_LIBS"
AC_DEFINE(BMP, 1, [Define for Beep Media Player support])
fi
fi
fi
;;
xyes)
PKG_CHECK_MODULES([BMP], [glib-2.0 >= 2.0])
CFLAGS="$CFLAGS $BMP_CFLAGS"
LIBS="$LIBS $BMP_LIBS"
AC_CHECK_HEADERS([dlfcn.h], [],
[AC_MSG_ERROR(["dlfcn.h not found: dynamic library loading not supported"])])
AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"],
[AC_CHECK_FUNCS(dlopen,[],
[AC_MSG_ERROR([dlopen() not available])])])
AC_DEFINE(BMP, 1, [Define for Beep Media Player support])
;;
xno)
;;
*)
echo "Error: invalid bmp parameter specified: $want_bmp"
exit -1
;;
esac
AM_CONDITIONAL(BUILD_BMP, test x$want_bmp = xyes)
dnl
dnl Audacious Media Player
@ -215,30 +115,18 @@ AC_ARG_ENABLE(audacious,
case x$want_audacious in
xauto)
want_audacious=yes
PKG_CHECK_MODULES([AUDACIOUS], [glib-2.0], [], [want_audacious=no])
PKG_CHECK_MODULES([AUDACIOUS], [audacious >= 0.1], [], [want_audacious=no])
if test x$want_audacious = xyes; then
AC_CHECK_HEADERS([dlfcn.h], [], [want_audacious=no])
if test x$want_audacious = xyes; then
AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"],
[AC_CHECK_FUNCS(dlopen,[],
[want_audacious=no])])
if test x$want_audacious = xyes; then
CFLAGS="$CFLAGS $AUDACIOUS_CFLAGS"
LIBS="$LIBS $AUDACIOUS_LIBS"
AC_DEFINE(AUDACIOUS, 1, [Define for Audacious support])
fi
fi
CFLAGS="$CFLAGS $AUDACIOUS_CFLAGS"
LIBS="$LIBS $AUDACIOUS_LIBS"
AC_DEFINE(AUDACIOUS, 1, [Define for Audacious support])
fi
;;
xyes)
PKG_CHECK_MODULES([AUDACIOUS], [glib-2.0])
PKG_CHECK_MODULES([AUDACIOUS], [audacious >= 0.1], [],
[AC_MSG_ERROR([Can't find Audacious development files.])])
CFLAGS="$CFLAGS $AUDACIOUS_CFLAGS"
LIBS="$LIBS $AUDACIOUS_LIBS"
AC_CHECK_HEADERS([dlfcn.h], [],
[AC_MSG_ERROR(["dlfcn.h not found: dynamic library loading not supported"])])
AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"],
[AC_CHECK_FUNCS(dlopen,[],
[AC_MSG_ERROR([dlopen() not available])])])
AC_DEFINE(AUDACIOUS, 1, [Define for Audacious support])
;;
xno)
@ -254,9 +142,9 @@ dnl
dnl InfoPipe (Version 1.3)
dnl
want_infopipe=yes
want_infopipe=no
AC_ARG_ENABLE(infopipe,
[ --enable-infopipe enable xmms/bmp infopipe support [[default=yes]]],
[ --enable-infopipe enable xmms/bmp infopipe support [[default=no]]],
[want_infopipe="$enableval"])
case x$want_infopipe in
@ -647,8 +535,6 @@ $PACKAGE $VERSION configured successfully:
xdamage extension: $want_xdamage
* music detection:
xmms: $want_xmms
bmp: $want_bmp
audacious: $want_audacious
infopipe: $want_infopipe
bmpx: $want_bmpx

View File

@ -363,13 +363,6 @@
<para></para></listitem>
</varlistentry>
<varlistentry>
<term><command><option>xmms_player</option></command></term>
<listitem>
Use specified player/plugin for the xmms status variables. Valid items are: none, xmms, bmp, audacious and infopipe. (default is none). Note that bmpx is currently handled separately.
<para></para></listitem>
</varlistentry>
<varlistentry>
<term><command><option>TEXT</option></command></term>
<listitem>

View File

@ -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\-seti \-\-enable\-double\-buffer \-\-enable\-own\-window \-\-enable\-proc\-uptime \-\-enable\-mpd \-\-enable\-mldonkey \-\-enable\-x11 \-\-enable\-portmon \-\-enable\-xmms \-\-enable\-bmp \-\-enable\-audacious \-\-enable\-infopipe \-\-enable\-bmpx \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 \-\-enable\-xft \-\-enable\-own\-window \-\-enable\-proc\-uptime \-\-enable\-audacious \-\-enable\-infopipe \-\-enable\-bmpx \-\-enable\-seti \-\-enable\-hddtemp \-\-enable\-mpd \-\-enable\-xmms2 \-\-enable\-imlib2 \-\-enable\-portmon \-\-enable\-mldonkey \-\-enable\-debug \-\-enable\-double\-buffer \-\-enable\-xdamage \-\-enable\-x11\fR\*(T>
.TP
\fB\*(T<\fBmake\fR\*(T>\fR
.TP
@ -341,10 +341,6 @@ Alpha of Xft font. Must be a value at or between 1 and 0.
\fB\*(T<\fBxftfont\fR\*(T>\fR
Xft font to use.
.TP
\fB\*(T<\fBxmms_player\fR\*(T>\fR
Use specified player/plugin for the xmms status variables. Valid items are: none, xmms, bmp, audacious and infopipe. (default is none). Note that bmpx is currently handled separately.
.TP
\fB\*(T<\fBTEXT\fR\*(T>\fR
After this begins text to be formatted on screen
@ -404,6 +400,58 @@ Display APM battery life in percent (FreeBSD only)
Display remaining APM battery life in hh:mm:ss or "unknown" if
AC adapterstatus is on-line or charging (FreeBSD only)
.TP
\fB\*(T<\fBaudacious_bar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T>
Progress bar
.TP
\fB\*(T<\fBaudacious_bitrate\fR\*(T>\fR
Bitrate of current tune
.TP
\fB\*(T<\fBaudacious_channels\fR\*(T>\fR
Number of audio channels of current tune
.TP
\fB\*(T<\fBaudacious_filename\fR\*(T>\fR
Full path and filename of current tune
.TP
\fB\*(T<\fBaudacious_frequency\fR\*(T>\fR
Sampling frequency of current tune
.TP
\fB\*(T<\fBaudacious_length\fR\*(T>\fR
Total length of current tune as MM:SS
.TP
\fB\*(T<\fBaudacious_length_seconds\fR\*(T>\fR
Total length of current tune in seconds
.TP
\fB\*(T<\fBaudacious_playlist_position\fR\*(T>\fR
Playlist position of current tune
.TP
\fB\*(T<\fBaudacious_playlist_length\fR\*(T>\fR
Number of tunes in playlist
.TP
\fB\*(T<\fBaudacious_position\fR\*(T>\fR
Position of current tune (MM:SS)
.TP
\fB\*(T<\fBaudacious_position_seconds\fR\*(T>\fR
Position of current tune in seconds
.TP
\fB\*(T<\fBaudacious_status\fR\*(T>\fR
Player status (Playing/Paused/Stopped/Not running)
.TP
\fB\*(T<\fBaudacious_title\fR\*(T>\fR
Title of current tune
.TP
\fB\*(T<\fBbattery\fR\*(T>\fR \*(T<\fB(num)\fR\*(T>
Remaining capacity in ACPI or APM battery. ACPI battery number can be given as argument (default is BAT0).
@ -661,6 +709,58 @@ Displays the number of messages in your global IMAP inbox by default. You can de
\fB\*(T<\fBimap_unseen\fR\*(T>\fR \*(T<\fB(args)\fR\*(T>
Displays the number of unseen messages in your global IMAP inbox by default. You can define individual IMAP inboxes seperately by passing arguments to this object. Arguments are: "host user pass [-i interval] [-p port] [-e command]". Default port is 110, default interval is 5 minutes. If the password is supplied as '*', you will be prompted to enter the password when Conky starts.
.TP
\fB\*(T<\fBinfopipe_bar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T>
Progress bar
.TP
\fB\*(T<\fBinfopipe_bitrate\fR\*(T>\fR
Bitrate of current tune
.TP
\fB\*(T<\fBinfopipe_channels\fR\*(T>\fR
Number of audio channels of current tune
.TP
\fB\*(T<\fBinfopipe_filename\fR\*(T>\fR
Full path and filename of current tune
.TP
\fB\*(T<\fBinfopipe_frequency\fR\*(T>\fR
Sampling frequency of current tune
.TP
\fB\*(T<\fBinfopipe_length\fR\*(T>\fR
Total length of current tune as MM:SS
.TP
\fB\*(T<\fBinfopipe_length_seconds\fR\*(T>\fR
Total length of current tune in seconds
.TP
\fB\*(T<\fBinfopipe_playlist_position\fR\*(T>\fR
Playlist position of current tune
.TP
\fB\*(T<\fBinfopipe_playlist_length\fR\*(T>\fR
Number of tunes in playlist
.TP
\fB\*(T<\fBinfopipe_position\fR\*(T>\fR
Position of current tune (MM:SS)
.TP
\fB\*(T<\fBinfopipe_position_seconds\fR\*(T>\fR
Position of current tune in seconds
.TP
\fB\*(T<\fBinfopipe_status\fR\*(T>\fR
Player status (Playing/Paused/Stopped/Not running)
.TP
\fB\*(T<\fBinfopipe_title\fR\*(T>\fR
Title of current tune
.TP
\fB\*(T<\fBkernel\fR\*(T>\fR
Kernel version
@ -986,58 +1086,6 @@ Returns CPU #n's voltage in V. CPUs are
counted from 1. If omitted, the parameter
defaults to 1.
.TP
\fB\*(T<\fBxmms_bar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T>
xmms / bmp / audacious / infopipe: progress bar
.TP
\fB\*(T<\fBxmms_bitrate\fR\*(T>\fR
xmms / bmp / audacious / infopipe: bitrate of current tune
.TP
\fB\*(T<\fBxmms_channels\fR\*(T>\fR
xmms / bmp / audacious / infopipe: number of audio channels of current tune
.TP
\fB\*(T<\fBxmms_filename\fR\*(T>\fR
xmms / bmp / audacious / infopipe: full path and filename of current tune
.TP
\fB\*(T<\fBxmms_frequency\fR\*(T>\fR
xmms / bmp / audacious / infopipe: sampling frequency of current tune
.TP
\fB\*(T<\fBxmms_length\fR\*(T>\fR
xmms / bmp / audacious / infopipe: total length of current tune as MM:SS
.TP
\fB\*(T<\fBxmms_length_seconds\fR\*(T>\fR
xmms / bmp / audacious / infopipe: total length of current tune in seconds
.TP
\fB\*(T<\fBxmms_playlist_position\fR\*(T>\fR
xmms / bmp / audacious / infopipe: playlist position of current tune
.TP
\fB\*(T<\fBxmms_playlist_length\fR\*(T>\fR
xmms / bmp / audacious / infopipe: number of tunes in playlist
.TP
\fB\*(T<\fBxmms_position\fR\*(T>\fR
xmms / bmp / audacious / infopipe: MM:SS position of current tune
.TP
\fB\*(T<\fBxmms_position_seconds\fR\*(T>\fR
xmms / bmp / audacious / infopipe: position of current tune in seconds
.TP
\fB\*(T<\fBxmms_status\fR\*(T>\fR
xmms / bmp / audacious / infopipe: player status (Playing/Paused/Stopped/Not running)
.TP
\fB\*(T<\fBxmms_title\fR\*(T>\fR
xmms / bmp / audacious / infopipe: title of current tune
.SH EXAMPLES
.TP
\*(T<conky \*(T>\*(T<\fB\-t '${time %D %H:%m}' \-o \-u 30\fR\*(T>

View File

@ -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-seti --enable-double-buffer --enable-own-window --enable-proc-uptime --enable-mpd --enable-mldonkey --enable-x11 --enable-portmon --enable-xmms --enable-bmp --enable-audacious --enable-infopipe --enable-bmpx </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 --enable-xft --enable-own-window --enable-proc-uptime --enable-audacious --enable-infopipe --enable-bmpx --enable-seti --enable-hddtemp --enable-mpd --enable-xmms2 --enable-imlib2 --enable-portmon --enable-mldonkey --enable-debug --enable-double-buffer --enable-xdamage --enable-x11</option>
</term>
</varlistentry>
<varlistentry>

View File

@ -111,6 +111,124 @@
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>audacious_bar</option></command>
<option>(height),(width)</option>
</term>
<listitem>
Progress bar
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>audacious_bitrate</option></command>
</term>
<listitem>
Bitrate of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>audacious_channels</option></command>
</term>
<listitem>
Number of audio channels of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>audacious_filename</option></command>
</term>
<listitem>
Full path and filename of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>audacious_frequency</option></command>
</term>
<listitem>
Sampling frequency of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>audacious_length</option></command>
</term>
<listitem>
Total length of current tune as MM:SS
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>audacious_length_seconds</option></command>
</term>
<listitem>
Total length of current tune in seconds
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>audacious_playlist_position</option></command>
</term>
<listitem>
Playlist position of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>audacious_playlist_length</option></command>
</term>
<listitem>
Number of tunes in playlist
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>audacious_position</option></command>
</term>
<listitem>
Position of current tune (MM:SS)
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>audacious_position_seconds</option></command>
</term>
<listitem>
Position of current tune in seconds
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>audacious_status</option></command>
</term>
<listitem>
Player status (Playing/Paused/Stopped/Not running)
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>audacious_title</option></command>
</term>
<listitem>
Title of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>battery</option></command>
@ -725,6 +843,124 @@
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>infopipe_bar</option></command>
<option>(height),(width)</option>
</term>
<listitem>
Progress bar
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>infopipe_bitrate</option></command>
</term>
<listitem>
Bitrate of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>infopipe_channels</option></command>
</term>
<listitem>
Number of audio channels of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>infopipe_filename</option></command>
</term>
<listitem>
Full path and filename of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>infopipe_frequency</option></command>
</term>
<listitem>
Sampling frequency of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>infopipe_length</option></command>
</term>
<listitem>
Total length of current tune as MM:SS
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>infopipe_length_seconds</option></command>
</term>
<listitem>
Total length of current tune in seconds
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>infopipe_playlist_position</option></command>
</term>
<listitem>
Playlist position of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>infopipe_playlist_length</option></command>
</term>
<listitem>
Number of tunes in playlist
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>infopipe_position</option></command>
</term>
<listitem>
Position of current tune (MM:SS)
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>infopipe_position_seconds</option></command>
</term>
<listitem>
Position of current tune in seconds
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>infopipe_status</option></command>
</term>
<listitem>
Player status (Playing/Paused/Stopped/Not running)
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>infopipe_title</option></command>
</term>
<listitem>
Title of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>kernel</option></command>
@ -1405,122 +1641,4 @@
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>xmms_bar</option></command>
<option>(height),(width)</option>
</term>
<listitem>
xmms / bmp / audacious / infopipe: progress bar
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>xmms_bitrate</option></command>
</term>
<listitem>
xmms / bmp / audacious / infopipe: bitrate of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>xmms_channels</option></command>
</term>
<listitem>
xmms / bmp / audacious / infopipe: number of audio channels of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>xmms_filename</option></command>
</term>
<listitem>
xmms / bmp / audacious / infopipe: full path and filename of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>xmms_frequency</option></command>
</term>
<listitem>
xmms / bmp / audacious / infopipe: sampling frequency of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>xmms_length</option></command>
</term>
<listitem>
xmms / bmp / audacious / infopipe: total length of current tune as MM:SS
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>xmms_length_seconds</option></command>
</term>
<listitem>
xmms / bmp / audacious / infopipe: total length of current tune in seconds
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>xmms_playlist_position</option></command>
</term>
<listitem>
xmms / bmp / audacious / infopipe: playlist position of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>xmms_playlist_length</option></command>
</term>
<listitem>
xmms / bmp / audacious / infopipe: number of tunes in playlist
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>xmms_position</option></command>
</term>
<listitem>
xmms / bmp / audacious / infopipe: MM:SS position of current tune
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>xmms_position_seconds</option></command>
</term>
<listitem>
xmms / bmp / audacious / infopipe: position of current tune in seconds
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>xmms_status</option></command>
</term>
<listitem>
xmms / bmp / audacious / infopipe: player status (Playing/Paused/Stopped/Not running)
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>xmms_title</option></command>
</term>
<listitem>
xmms / bmp / audacious / infopipe: title of current tune
<para></para></listitem>
</varlistentry>
</variablelist>

View File

@ -1,19 +1,11 @@
bin_PROGRAMS = conky
if BUILD_XMMS
xmms = xmms.c xmms.h
endif
if BUILD_BMP
xmms = xmms.c xmms.h
endif
if BUILD_AUDACIOUS
xmms = xmms.c xmms.h
audacious = audacious.c audacious.h
endif
if BUILD_INFOPIPE
xmms = xmms.c xmms.h
infopipe = infopipe.c infopipe.h
endif
if BUILD_BMPX
@ -66,9 +58,56 @@ if BUILD_HDDTEMP
hddtemp = hddtemp.c
endif
conky_SOURCES = common.c fs.c $(linux) mail.c mixer.c $(seti) $(mpd) $(xmms2) $(solaris) $(freebsd) $(netbsd) $(port_monitors) conky.c conky.h $(x11) $(mldonkey) remoted.c remoted.h remotec.c remotec.h $(xmms) $(bmpx) $(hddtemp)
conky_SOURCES = \
$(audacious) \
$(bmpx) \
common.c \
conky.c \
conky.h \
$(freebsd) \
fs.c \
$(hddtemp) \
$(infopipe) \
$(linux) \
mail.c \
mixer.c \
$(mldonkey) \
$(mpd) \
$(netbsd) \
$(port_monitors) \
$(seti) \
$(solaris) \
remotec.c \
remotec.h \
remoted.c \
remoted.h \
$(x11) \
$(xmms2)
AM_LDFLAGS = $(X11_LIBS) $(XFT_LIBS) $(CAIRO_LIBS) $(PTHREAD_LIBS) -lm
EXTRA_DIST = seti.c linux.c solaris.c freebsd.c netbsd.c mpd.c libmpdclient.c \
libmpdclient.h xmms2.c top.h mldonkey.c ftp.c ftp.h x11.c hddtemp.c
EXTRA_DIST = \
audacious.c \
audacious.h \
bmpx.c \
freebsd.c \
ftp.c \
ftp.h \
hash.c \
hash.h \
hddtemp.c \
infopipe.c \
infopipe.h \
linux.c \
libmpdclient.c \
libmpdclient.h \
libtcp-portmon.c \
libtcp-portmon.h \
mldonkey.c \
mpd.c \
netbsd.c \
seti.c \
solaris.c \
top.h \
x11.c \
xmms2.c

219
src/audacious.c Normal file
View File

@ -0,0 +1,219 @@
/* -------------------------------------------------------------------------
* audacious.c: conky support for audacious music player
*
* Copyright (C) 2005 Philip Kovacs kovacsp3@comcast.net
*
* $Id $
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* --------------------------------------------------------------------------- */
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <glib.h>
#include <audacious/beepctrl.h>
#include "config.h"
#include "conky.h"
#include "audacious.h"
/* access to this item array is synchronized */
static audacious_t audacious_items;
/* -----------------------------------------
* Conky update function for audacious data.
* ----------------------------------------- */
void update_audacious(void)
{
/*
The worker thread is updating audacious_items array asynchronously to the main
conky thread. We merely copy the audacious_items array into the main thread's
info structure when the main thread's update cycle fires.
*/
pthread_mutex_lock(&info.audacious.item_mutex);
memcpy(&info.audacious.items,audacious_items,sizeof(audacious_items));
pthread_mutex_unlock(&info.audacious.item_mutex);
}
/* ------------------------------------------------------------
* Create a worker thread for audacious media player status.
*
* Returns 0 on success, -1 on error.
* ------------------------------------------------------------*/
int create_audacious_thread(void)
{
/* Is a worker is thread already running? */
if (info.audacious.thread)
return(-1);
/* Joinable thread for audacious activity */
pthread_attr_init(&info.audacious.thread_attr);
pthread_attr_setdetachstate(&info.audacious.thread_attr, PTHREAD_CREATE_JOINABLE);
/* Init mutexes */
pthread_mutex_init(&info.audacious.item_mutex, NULL);
pthread_mutex_init(&info.audacious.runnable_mutex, NULL);
/* Init runnable condition for worker thread */
pthread_mutex_lock(&info.audacious.runnable_mutex);
info.audacious.runnable=1;
pthread_mutex_unlock(&info.audacious.runnable_mutex);
if (pthread_create(&info.audacious.thread, &info.audacious.thread_attr, audacious_thread_func, NULL))
return(-1);
return 0;
}
/* ------------------------------------------------
* Destroy audacious player status thread.
*
* Returns 0 on success, -1 on error.
* ------------------------------------------------ */
int destroy_audacious_thread(void)
{
/* Is a worker is thread running? If not, no error. */
if (!info.audacious.thread)
return(0);
/* Signal audacious thread to terminate */
pthread_mutex_lock(&info.audacious.runnable_mutex);
info.audacious.runnable=0;
pthread_mutex_unlock(&info.audacious.runnable_mutex);
/* Destroy thread attribute and wait for thread */
pthread_attr_destroy(&info.audacious.thread_attr);
if (pthread_join(info.audacious.thread, NULL))
return(-1);
/* Destroy mutexes */
pthread_mutex_destroy(&info.audacious.item_mutex);
pthread_mutex_destroy(&info.audacious.runnable_mutex);
info.audacious.thread=(pthread_t)0;
return 0;
}
/* ---------------------------------------------------
* Worker thread function for audacious data sampling.
* --------------------------------------------------- */
void *audacious_thread_func(void *pvoid)
{
int runnable;
static audacious_t items;
gint session,playpos,frames,length;
gint rate,freq,chans;
gchar *psong,*pfilename;
pvoid=(void *)pvoid; /* avoid warning */
session=0;
psong=NULL;
pfilename=NULL;
/* Grab the runnable signal. Should be non-zero here or we do nothing. */
pthread_mutex_lock(&info.audacious.runnable_mutex);
runnable=info.audacious.runnable;
pthread_mutex_unlock(&info.audacious.runnable_mutex );
/* Loop until the main thread sets the runnable signal to 0. */
while(runnable) {
for (;;) { /* convenience loop so we can break below */
if (!xmms_remote_is_running (session)) {
memset(&items,0,sizeof(items));
strcpy(items[AUDACIOUS_STATUS],"Not running");
break;
}
/* Player status */
if (xmms_remote_is_paused (session))
strcpy(items[AUDACIOUS_STATUS],"Paused");
else if (xmms_remote_is_playing (session))
strcpy(items[AUDACIOUS_STATUS],"Playing");
else
strcpy(items[AUDACIOUS_STATUS],"Stopped");
/* Current song title */
playpos = xmms_remote_get_playlist_pos (session);
psong = xmms_remote_get_playlist_title (session, playpos);
if (psong) {
strncpy(items[AUDACIOUS_TITLE],psong,sizeof(items[AUDACIOUS_TITLE])-1);
g_free (psong);
psong=NULL;
}
/* 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);
/* Current song length in seconds */
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);
length = frames / 1000;
snprintf(items[AUDACIOUS_POSITION],sizeof(items[AUDACIOUS_POSITION])-1,
"%d:%.2d", length / 60, length % 60);
/* Current song position in seconds */
snprintf(items[AUDACIOUS_POSITION_SECONDS],sizeof(items[AUDACIOUS_POSITION_SECONDS])-1,
"%d", length);
/* Current song bitrate */
xmms_remote_get_info (session, &rate, &freq, &chans);
snprintf(items[AUDACIOUS_BITRATE],sizeof(items[AUDACIOUS_BITRATE])-1, "%d", rate);
/* Current song frequency */
snprintf(items[AUDACIOUS_FREQUENCY],sizeof(items[AUDACIOUS_FREQUENCY])-1, "%d", freq);
/* Current song channels */
snprintf(items[AUDACIOUS_CHANNELS],sizeof(items[AUDACIOUS_CHANNELS])-1, "%d", chans);
/* Current song filename */
pfilename = xmms_remote_get_playlist_file (session,playpos);
if (pfilename) {
strncpy(items[AUDACIOUS_FILENAME],pfilename,sizeof(items[AUDACIOUS_FILENAME])-1);
g_free (pfilename);
pfilename=NULL;
}
/* Length of the Playlist (number of songs) */
length = xmms_remote_get_playlist_length (session);
snprintf(items[AUDACIOUS_PLAYLIST_LENGTH],sizeof(items[AUDACIOUS_PLAYLIST_LENGTH])-1, "%d", length);
/* Playlist position (index of song) */
snprintf(items[AUDACIOUS_PLAYLIST_POSITION],sizeof(items[AUDACIOUS_PLAYLIST_POSITION])-1, "%d", playpos+1);
break;
}
/* Deliver the refreshed items array to g_items. */
pthread_mutex_lock(&info.audacious.item_mutex);
memcpy(&audacious_items,items,sizeof(items));
pthread_mutex_unlock(&info.audacious.item_mutex);
/* Grab the runnable signal for next loop. */
pthread_mutex_lock(&info.audacious.runnable_mutex);
runnable=info.audacious.runnable;
pthread_mutex_unlock(&info.audacious.runnable_mutex);
sleep(1);
}
pthread_exit(NULL);
}

View File

@ -1,9 +1,9 @@
/* -------------------------------------------------------------------------
* xmms.h: conky support for XMMS-related projects
* audacious.h: conky support for audacious music player
*
* Copyright (C) 2005 Philip Kovacs kovacsp3@comcast.net
*
* $Id$
* $Id $
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,49 +20,37 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* --------------------------------------------------------------------------- */
#ifndef XMMS_H
#define XMMS_H
#ifndef AUDACIOUS_H
#define AUDACIOUS_H
enum _xmms_items {
XMMS_STATUS=0,
XMMS_TITLE,
XMMS_LENGTH,
XMMS_LENGTH_SECONDS,
XMMS_POSITION,
XMMS_POSITION_SECONDS,
XMMS_BITRATE,
XMMS_FREQUENCY,
XMMS_CHANNELS,
XMMS_FILENAME,
XMMS_PLAYLIST_LENGTH,
XMMS_PLAYLIST_POSITION,
enum _audacious_items {
AUDACIOUS_STATUS=0,
AUDACIOUS_TITLE,
AUDACIOUS_LENGTH,
AUDACIOUS_LENGTH_SECONDS,
AUDACIOUS_POSITION,
AUDACIOUS_POSITION_SECONDS,
AUDACIOUS_BITRATE,
AUDACIOUS_FREQUENCY,
AUDACIOUS_CHANNELS,
AUDACIOUS_FILENAME,
AUDACIOUS_PLAYLIST_LENGTH,
AUDACIOUS_PLAYLIST_POSITION,
};
enum _xmms_projects {
PROJECT_NONE = 0,
PROJECT_XMMS = 1,
PROJECT_BMP = 2,
PROJECT_AUDACIOUS = 3,
PROJECT_INFOPIPE = 4
};
/* 12 slots for the audacious values */
typedef char audacious_t[12][128];
#define SET_XMMS_PROJECT_AVAILABLE(mask,project) (mask |= (1<<project))
#define TEST_XMMS_PROJECT_AVAILABLE(mask,project) (mask & (1<<project))
/* create a worker thread for audacious media player status */
int create_audacious_thread(void);
/* 12 slots for the xmms values */
typedef char xmms_t[12][128];
/* create a worker thread for xmms media player status */
int create_xmms_thread(void);
/* destroy xmms media player worker thread */
int destroy_xmms_thread(void);
/* destroy audacious media player worker thread */
int destroy_audacious_thread(void);
/* Service routine for the conky main thread */
void update_xmms(void);
void update_audacious(void);
/* Thread functions */
void *xmms_thread_func_dynamic(void *);
void *xmms_thread_func_infopipe(void *);
void *audacious_thread_func(void *);
#endif

View File

@ -232,10 +232,16 @@ void update_stuff()
update_xmms2();
#endif
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
if (NEED(INFO_XMMS))
update_xmms();
#ifdef AUDACIOUS
if (NEED(INFO_AUDACIOUS))
update_audacious();
#endif
#ifdef INFOPIPE
if (NEED(INFO_INFOPIPE))
update_infopipe();
#endif
#ifdef BMPX
if (NEED(INFO_BMPX))
update_bmpx();

View File

@ -70,12 +70,6 @@ static void print_version()
# endif /* HAVE_XDBE */
#endif /* X11 */
"\n Music detection:\n"
#ifdef XMMS
" * xmms\n"
#endif /* XMMS */
#ifdef BMP
" * bmp\n"
#endif /* BMP */
#ifdef AUDACIOUS
" * audacious\n"
#endif /* AUDACIOUS */
@ -1075,20 +1069,35 @@ enum text_object_type {
OBJ_xmms2_bar,
OBJ_xmms2_smart,
#endif
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
OBJ_xmms_status,
OBJ_xmms_title,
OBJ_xmms_length,
OBJ_xmms_length_seconds,
OBJ_xmms_position,
OBJ_xmms_position_seconds,
OBJ_xmms_bitrate,
OBJ_xmms_frequency,
OBJ_xmms_channels,
OBJ_xmms_filename,
OBJ_xmms_playlist_length,
OBJ_xmms_playlist_position,
OBJ_xmms_bar,
#ifdef AUDACIOUS
OBJ_audacious_status,
OBJ_audacious_title,
OBJ_audacious_length,
OBJ_audacious_length_seconds,
OBJ_audacious_position,
OBJ_audacious_position_seconds,
OBJ_audacious_bitrate,
OBJ_audacious_frequency,
OBJ_audacious_channels,
OBJ_audacious_filename,
OBJ_audacious_playlist_length,
OBJ_audacious_playlist_position,
OBJ_audacious_bar,
#endif
#ifdef INFOPIPE
OBJ_infopipe_status,
OBJ_infopipe_title,
OBJ_infopipe_length,
OBJ_infopipe_length_seconds,
OBJ_infopipe_position,
OBJ_infopipe_position_seconds,
OBJ_infopipe_bitrate,
OBJ_infopipe_frequency,
OBJ_infopipe_channels,
OBJ_infopipe_filename,
OBJ_infopipe_playlist_length,
OBJ_infopipe_playlist_position,
OBJ_infopipe_bar,
#endif
#ifdef BMPX
OBJ_bmpx_title,
@ -2949,23 +2958,41 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
END OBJ(xmms2_smart, INFO_XMMS2)
END
#endif
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
OBJ(xmms_status, INFO_XMMS) END
OBJ(xmms_title, INFO_XMMS) END
OBJ(xmms_length, INFO_XMMS) END
OBJ(xmms_length_seconds, INFO_XMMS) END
OBJ(xmms_position, INFO_XMMS) END
OBJ(xmms_position_seconds, INFO_XMMS) END
OBJ(xmms_bitrate, INFO_XMMS) END
OBJ(xmms_frequency, INFO_XMMS) END
OBJ(xmms_channels, INFO_XMMS) END
OBJ(xmms_filename, INFO_XMMS) END
OBJ(xmms_playlist_length, INFO_XMMS) END
OBJ(xmms_playlist_position, INFO_XMMS) END
OBJ(xmms_bar, INFO_XMMS)
#ifdef AUDACIOUS
OBJ(audacious_status, INFO_AUDACIOUS) END
OBJ(audacious_title, INFO_AUDACIOUS) END
OBJ(audacious_length, INFO_AUDACIOUS) END
OBJ(audacious_length_seconds, INFO_AUDACIOUS) END
OBJ(audacious_position, INFO_AUDACIOUS) END
OBJ(audacious_position_seconds, INFO_AUDACIOUS) END
OBJ(audacious_bitrate, INFO_AUDACIOUS) END
OBJ(audacious_frequency, INFO_AUDACIOUS) END
OBJ(audacious_channels, INFO_AUDACIOUS) END
OBJ(audacious_filename, INFO_AUDACIOUS) END
OBJ(audacious_playlist_length, INFO_AUDACIOUS) END
OBJ(audacious_playlist_position, INFO_AUDACIOUS) END
OBJ(audacious_bar, INFO_AUDACIOUS)
(void) scan_bar(arg, &obj->a, &obj->b);
END
#endif
#ifdef INFOPIPE
OBJ(infopipe_status, INFO_INFOPIPE) END
OBJ(infopipe_title, INFO_INFOPIPE) END
OBJ(infopipe_length, INFO_INFOPIPE) END
OBJ(infopipe_length_seconds, INFO_INFOPIPE) END
OBJ(infopipe_position, INFO_INFOPIPE) END
OBJ(infopipe_position_seconds, INFO_INFOPIPE) END
OBJ(infopipe_bitrate, INFO_INFOPIPE) END
OBJ(infopipe_frequency, INFO_INFOPIPE) END
OBJ(infopipe_channels, INFO_INFOPIPE) END
OBJ(infopipe_filename, INFO_INFOPIPE) END
OBJ(infopipe_playlist_length, INFO_INFOPIPE) END
OBJ(infopipe_playlist_position, INFO_INFOPIPE) END
OBJ(infopipe_bar, INFO_INFOPIPE)
(void) scan_bar(arg, &obj->a, &obj->b);
END
#endif
#ifdef BMPX
OBJ(bmpx_title, INFO_BMPX)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
@ -4553,47 +4580,91 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
}
}
#endif
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
OBJ(xmms_status) {
snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_STATUS]);
#ifdef AUDACIOUS
OBJ(audacious_status) {
snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_STATUS]);
}
OBJ(xmms_title) {
snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_TITLE]);
OBJ(audacious_title) {
snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_TITLE]);
}
OBJ(xmms_length) {
snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_LENGTH]);
OBJ(audacious_length) {
snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_LENGTH]);
}
OBJ(xmms_length_seconds) {
snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_LENGTH_SECONDS]);
OBJ(audacious_length_seconds) {
snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_LENGTH_SECONDS]);
}
OBJ(xmms_position) {
snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_POSITION]);
OBJ(audacious_position) {
snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_POSITION]);
}
OBJ(xmms_position_seconds) {
snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_POSITION_SECONDS]);
OBJ(audacious_position_seconds) {
snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_POSITION_SECONDS]);
}
OBJ(xmms_bitrate) {
snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_BITRATE]);
OBJ(audacious_bitrate) {
snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_BITRATE]);
}
OBJ(xmms_frequency) {
snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_FREQUENCY]);
OBJ(audacious_frequency) {
snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_FREQUENCY]);
}
OBJ(xmms_channels) {
snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_CHANNELS]);
OBJ(audacious_channels) {
snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_CHANNELS]);
}
OBJ(xmms_filename) {
snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_FILENAME]);
OBJ(audacious_filename) {
snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_FILENAME]);
}
OBJ(xmms_playlist_length) {
snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_PLAYLIST_LENGTH]);
OBJ(audacious_playlist_length) {
snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_PLAYLIST_LENGTH]);
}
OBJ(xmms_playlist_position) {
snprintf(p, p_max_size, "%s", cur->xmms.items[XMMS_PLAYLIST_POSITION]);
OBJ(audacious_playlist_position) {
snprintf(p, p_max_size, "%s", cur->audacious.items[AUDACIOUS_PLAYLIST_POSITION]);
}
OBJ(xmms_bar) {
OBJ(audacious_bar) {
double progress;
progress= atof(cur->xmms.items[XMMS_POSITION_SECONDS]) /
atof(cur->xmms.items[XMMS_LENGTH_SECONDS]);
progress= atof(cur->audacious.items[AUDACIOUS_POSITION_SECONDS]) /
atof(cur->audacious.items[AUDACIOUS_LENGTH_SECONDS]);
new_bar(p,obj->a,obj->b,(int)(progress*255.0f));
}
#endif
#ifdef INFOPIPE
OBJ(infopipe_status) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_STATUS]);
}
OBJ(infopipe_title) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_TITLE]);
}
OBJ(infopipe_length) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_LENGTH]);
}
OBJ(infopipe_length_seconds) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_LENGTH_SECONDS]);
}
OBJ(infopipe_position) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_POSITION]);
}
OBJ(infopipe_position_seconds) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_POSITION_SECONDS]);
}
OBJ(infopipe_bitrate) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_BITRATE]);
}
OBJ(infopipe_frequency) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_FREQUENCY]);
}
OBJ(infopipe_channels) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_CHANNELS]);
}
OBJ(infopipe_filename) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_FILENAME]);
}
OBJ(infopipe_playlist_length) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_PLAYLIST_LENGTH]);
}
OBJ(infopipe_playlist_position) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_PLAYLIST_POSITION]);
}
OBJ(infopipe_bar) {
double progress;
progress= atof(cur->infopipe.items[INFOPIPE_POSITION_SECONDS]) /
atof(cur->infopipe.items[INFOPIPE_LENGTH_SECONDS]);
new_bar(p,obj->a,obj->b,(int)(progress*255.0f));
}
#endif
@ -6085,13 +6156,13 @@ void reload_config(void)
free(info.cpu_usage);
info.cpu_usage = NULL;
}
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
if (info.xmms.thread) {
if (destroy_xmms_thread()!=0)
{
ERR("error destroying xmms_player thread");
}
}
#ifdef AUDACIOUS
if ( (info.audacious.thread) && (destroy_audacious_thread()!=0) )
ERR("error destroying audacious thread");
#endif
#ifdef INFOPIPE
if ( (info.infopipe.thread) && (destroy_infopipe_thread()!=0) )
ERR("error destroying audacious thread");
#endif
#ifdef TCP_PORT_MONITOR
destroy_tcp_port_monitor_collection( info.p_tcp_port_monitor_collection );
@ -6109,12 +6180,13 @@ void reload_config(void)
#ifdef TCP_PORT_MONITOR
info.p_tcp_port_monitor_collection = NULL;
#endif
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
if ( (!info.xmms.thread) && (info.xmms.current_project > PROJECT_NONE) &&
(create_xmms_thread() !=0) )
{
CRIT_ERR("unable to create xmms_player thread!");
}
#ifdef AUDACIOUS
if ( (!info.audacious.thread) && (create_audacious_thread() !=0) )
CRIT_ERR("unable to create audacious thread!");
#endif
#ifdef INFOPIPE
if ( (!info.infopipe.thread) && (create_infopipe_thread() !=0) )
CRIT_ERR("unable to create infopipe thread!");
#endif
extract_variable_text(text);
free(text);
@ -6180,11 +6252,13 @@ void clean_up(void)
destroy_tcp_port_monitor_collection( info.p_tcp_port_monitor_collection );
info.p_tcp_port_monitor_collection = NULL;
#endif
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
if ( info.xmms.thread && (destroy_xmms_thread()!=0) )
{
ERR("error destroying xmms_player thread");
}
#ifdef AUDACIOUS
if ( info.audacious.thread && (destroy_audacious_thread()!=0) )
ERR("error destroying audacious thread");
#endif
#ifdef INFOPIPE
if ( info.infopipe.thread && (destroy_infopipe_thread()!=0) )
ERR("error destroying infopipe thread");
#endif
}
@ -6313,10 +6387,6 @@ static void set_default_configurations(void)
tcp_port_monitor_collection_args.min_port_monitors = MIN_PORT_MONITORS_DEFAULT;
tcp_port_monitor_args.min_port_monitor_connections = MIN_PORT_MONITOR_CONNECTIONS_DEFAULT;
#endif
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
info.xmms.current_project=PROJECT_NONE;
#endif
}
static void load_config_file(const char *f)
@ -6443,26 +6513,10 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
CONF_ERR;
}
#endif /* X11 */
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
CONF("xmms_player") {
if (value) {
if (strncmp(value,"none",4)==0)
info.xmms.current_project=PROJECT_NONE;
else if (strncmp(value,"xmms",4)==0)
info.xmms.current_project=PROJECT_XMMS;
else if (strncmp(value,"bmp",3)==0)
info.xmms.current_project=PROJECT_BMP;
else if (strncmp(value,"audacious",9)==0)
info.xmms.current_project=PROJECT_AUDACIOUS;
else if (strncmp(value,"infopipe",8)==0)
info.xmms.current_project=PROJECT_INFOPIPE;
else
CONF_ERR;
}
else
CONF_ERR;
if (value)
ERR("xmms_player is deprecated. see ./configure --help");
}
#endif
CONF("imap") {
if (value) {
info.mail = parse_mail_args(IMAP, value);
@ -6891,19 +6945,6 @@ int main(int argc, char **argv)
tcp_port_monitor_args.min_port_monitor_connections = MIN_PORT_MONITOR_CONNECTIONS_DEFAULT;
#endif
#if defined(XMMS)
SET_XMMS_PROJECT_AVAILABLE(info.xmms.project_mask, PROJECT_XMMS);
#endif
#if defined(BMP)
SET_XMMS_PROJECT_AVAILABLE(info.xmms.project_mask, PROJECT_BMP);
#endif
#if defined(AUDACIOUS)
SET_XMMS_PROJECT_AVAILABLE(info.xmms.project_mask, PROJECT_AUDACIOUS);
#endif
#if defined(INFOPIPE)
SET_XMMS_PROJECT_AVAILABLE(info.xmms.project_mask, PROJECT_INFOPIPE);
#endif
/* handle command line parameters that don't change configs */
#ifdef X11
char *s, *temp;
@ -7183,21 +7224,23 @@ int main(int argc, char **argv)
ERR("error setting signal handler: %s", strerror(errno) );
}
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
if ( (info.xmms.current_project > PROJECT_NONE) && (create_xmms_thread() !=0) )
#ifdef AUDACIOUS
if ( (create_audacious_thread() !=0) )
{
CRIT_ERR("unable to create xmms_player thread!");
CRIT_ERR("unable to create audacious thread!");
}
#endif
main_loop();
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
if ( info.xmms.thread && (destroy_xmms_thread()!=0) )
{
ERR("error destroying xmms_player thread");
}
#ifdef AUDACIOUS
if ( info.audacious.thread && (destroy_audacious_thread()!=0) )
ERR("error destroying audacious thread");
#endif
#ifdef INFOPIPE
if ( info.infopipe.thread && (destroy_infopipe_thread()!=0) )
ERR("error destroying infopipe thread");
#endif
#if defined(__FreeBSD__)
kvm_close(kd);

View File

@ -42,8 +42,12 @@
#include <machine/apm_bios.h>
#endif /* __FreeBSD__ */
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
#include "xmms.h"
#ifdef AUDACIOUS
#include "audacious.h"
#endif
#ifdef INFOPIPE
#include "infopipe.h"
#endif
#ifdef XMMS2
@ -175,13 +179,22 @@ struct xmms2_s {
};
#endif
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
struct xmms_s {
unsigned int project_mask;
unsigned int current_project;
xmms_t items; /* e.g. items[XMMS_STATUS] yields char[] */
#ifdef AUDACIOUS
struct audacious_s {
audacious_t items; /* e.g. items[AUDACIOUS_STATUS] */
int runnable; /* used to signal worker thread to stop */
pthread_t thread; /* worker thread for xmms updating */
pthread_t thread; /* worker thread */
pthread_attr_t thread_attr; /* thread attributes */
pthread_mutex_t item_mutex; /* mutex for item array */
pthread_mutex_t runnable_mutex; /* mutex for runnable flag */
};
#endif
#ifdef INFOPIPE
struct infopipe_s {
infopipe_t items; /* e.g. items[INFOPIPE_STATUS] */
int runnable; /* used to signal worker thread to stop */
pthread_t thread; /* worker thread */
pthread_attr_t thread_attr; /* thread attributes */
pthread_mutex_t item_mutex; /* mutex for item array */
pthread_mutex_t runnable_mutex; /* mutex for runnable flag */
@ -237,14 +250,17 @@ enum {
#ifdef TCP_PORT_MONITOR
INFO_TCP_PORT_MONITOR = 22,
#endif
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
INFO_XMMS = 23,
#ifdef AUDACIOUS
INFO_AUDACIOUS = 23,
#endif
#ifdef INFOPIPE
INFO_INFOPIPE = 24,
#endif
#ifdef BMPX
INFO_BMPX = 24,
INFO_BMPX = 25,
#endif
#ifdef XMMS2
INFO_XMMS2 = 25,
INFO_XMMS2 = 26,
#endif
};
@ -298,8 +314,11 @@ struct information {
fd_set xmms2_fdset;
xmmsc_connection_t *xmms2_conn;
#endif
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE)
struct xmms_s xmms;
#ifdef AUDACIOUS
struct audacious_s audacious;
#endif
#ifdef INFOPIPE
struct infopipe_s infopipe;
#endif
#ifdef BMPX
struct bmpx_s bmpx;

268
src/infopipe.c Normal file
View File

@ -0,0 +1,268 @@
/* -------------------------------------------------------------------------
* infopipe.c: conky support for infopipe plugin
*
* Copyright (C) 2005 Philip Kovacs kovacsp3@comcast.net
*
* $Id $
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* --------------------------------------------------------------------------- */
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include <fcntl.h>
#include "config.h"
#include "conky.h"
#include "xmms.h"
#define INFOPIPE_NAMED_PIPE "/tmp/xmms-info"
/* 14 keys comprise the output of the infopipe plugin. */
enum _infopipe_keys {
INFOPIPE_KEY_PROTOCOL=0,
INFOPIPE_KEY_VERSION,
INFOPIPE_KEY_STATUS,
INFOPIPE_KEY_PLAYLIST_TUNES,
INFOPIPE_KEY_PLAYLIST_CURRTUNE,
INFOPIPE_KEY_USEC_POSITION,
INFOPIPE_KEY_POSITION,
INFOPIPE_KEY_USEC_TIME,
INFOPIPE_KEY_TIME,
INFOPIPE_KEY_BITRATE,
INFOPIPE_KEY_FREQUENCY,
INFOPIPE_KEY_CHANNELS,
INFOPIPE_KEY_TITLE,
INFOPIPE_KEY_FILE
};
/* access to this item array is synchronized */
static infopipe_t infopipe_items;
/* ----------------------------------------
* Conky update function for infopipe data.
* ---------------------------------------- */
void update_infopipe(void)
{
/*
The worker thread is updating the infopipe_items array asynchronously to the main
conky thread. We merely copy the infopipe_items array into the main thread's info
structure when the main thread's update cycle fires.
*/
pthread_mutex_lock(&info.infopipe.item_mutex);
memcpy(&info.infopipe.items,infopipe_items,sizeof(infopipe_items));
pthread_mutex_unlock(&info.infopipe.item_mutex);
}
/* ------------------------------------------------------------
* Create a worker thread for infopipe media player status.
*
* Returns 0 on success, -1 on error.
* ------------------------------------------------------------*/
int create_infopipe_thread(void)
{
/* Is a worker is thread already running? */
if (info.infopipe.thread)
return(-1);
/* Joinable thread for infopipe activity */
pthread_attr_init(&info.infopipe.thread_attr);
pthread_attr_setdetachstate(&info.infopipe.thread_attr, PTHREAD_CREATE_JOINABLE);
/* Init mutexes */
pthread_mutex_init(&info.infopipe.item_mutex, NULL);
pthread_mutex_init(&info.infopipe.runnable_mutex, NULL);
/* Init runnable condition for worker thread */
pthread_mutex_lock(&info.infopipe.runnable_mutex);
info.infopipe.runnable=1;
pthread_mutex_unlock(&info.infopipe.runnable_mutex);
if (pthread_create(&info.infopipe.thread, &info.infopipe.thread_attr, infopipe_thread_func, NULL))
return(-1);
return 0;
}
/* ------------------------------------------------
* Destroy infopipe status thread.
*
* Returns 0 on success, -1 on error.
* ------------------------------------------------ */
int destroy_infopipe_thread(void)
{
/* Is a worker is thread running? If not, no error. */
if (!info.infopipe.thread)
return(0);
/* Signal infopipe worker thread to terminate */
pthread_mutex_lock(&info.infopipe.runnable_mutex);
info.infopipe.runnable=0;
pthread_mutex_unlock(&info.infopipe.runnable_mutex);
/* Destroy thread attribute and wait for thread */
pthread_attr_destroy(&info.infopipe.thread_attr);
if (pthread_join(info.infopipe.thread, NULL))
return(-1);
/* Destroy mutexes */
pthread_mutex_destroy(&info.infopipe.item_mutex);
pthread_mutex_destroy(&info.infopipe.runnable_mutex);
info.infopipe.thread=(pthread_t)0;
return 0;
}
/* --------------------------------------------------
* Worker thread function for InfoPipe data sampling.
* -------------------------------------------------- */
void *infopipe_thread_func(void *pvoid)
{
int i,rc,fd,runnable;
fd_set readset;
struct timeval tm;
static char buf[2048],line[128];
static infopipe_t items;
char *pbuf,c;
pvoid=(void*)pvoid; /* avoid warning */
/* Grab the runnable signal. Should be non-zero here or we do nothing. */
pthread_mutex_lock(&info.infopipe.runnable_mutex);
runnable=info.infopipe.runnable;
pthread_mutex_unlock(&info.infopipe.runnable_mutex );
/* Loop until the main thread sets the runnable signal to 0. */
while(runnable) {
for (;;) { /* convenience loop so we can break below */
memset(buf,0,sizeof(buf));
if ((fd=open(INFOPIPE_NAMED_PIPE, O_RDONLY | O_NONBLOCK)) < 0) {
/* InfoPipe is not running */
memset(items,0,sizeof(items));
strcpy(items[INFOPIPE_STATUS],"Not running");
break;
}
FD_ZERO(&readset);
FD_SET(fd,&readset);
/* On Linux, select() reduces the timer by the amount of time not slept,
* so we must reset the timer with each loop. */
tm.tv_sec=1;
tm.tv_usec=0;
rc=select(fd+1,&readset,NULL,NULL,&tm);
if (rc == -1) {
/* -- debug --
perror("infopipe select()");
*/
}
else if (rc && FD_ISSET(fd,&readset)) { /* ready to read */
if (read(fd,buf,sizeof(buf)) > 0) { /* buf has data */
pbuf=buf;
for (i=0;i<14;i++) {
/* 14 lines of key: value pairs presented in a known order */
memset(line,0,sizeof(line));
if ( sscanf(pbuf,"%*[^:]: %[^\n]",line) == EOF )
break;
while((c = *pbuf++) && (c != '\n'));
switch(i) {
case INFOPIPE_KEY_PROTOCOL:
break;
case INFOPIPE_KEY_VERSION:
break;
case INFOPIPE_KEY_STATUS:
strncpy(items[INFOPIPE_STATUS],line,sizeof(items[INFOPIPE_STATUS])-1);
break;
case INFOPIPE_KEY_PLAYLIST_TUNES:
strncpy(items[INFOPIPE_PLAYLIST_LENGTH],line,sizeof(items[INFOPIPE_PLAYLIST_LENGTH])-1);
break;
case INFOPIPE_KEY_PLAYLIST_CURRTUNE:
strncpy(items[INFOPIPE_PLAYLIST_POSITION],line,sizeof(items[INFOPIPE_PLAYLIST_POSITION])-1);
break;
case INFOPIPE_KEY_USEC_POSITION:
snprintf(items[INFOPIPE_POSITION_SECONDS],sizeof(items[INFOPIPE_POSITION_SECONDS])-1,
"%d", atoi(line) / 1000);
break;
case INFOPIPE_KEY_POSITION:
strncpy(items[INFOPIPE_POSITION],line,sizeof(items[INFOPIPE_POSITION])-1);
break;
case INFOPIPE_KEY_USEC_TIME:
snprintf(items[INFOPIPE_LENGTH_SECONDS],sizeof(items[INFOPIPE_LENGTH_SECONDS])-1,
"%d", atoi(line) / 1000);
break;
case INFOPIPE_KEY_TIME:
strncpy(items[INFOPIPE_LENGTH],line,sizeof(items[INFOPIPE_LENGTH])-1);
break;
case INFOPIPE_KEY_BITRATE:
strncpy(items[INFOPIPE_BITRATE],line,sizeof(items[INFOPIPE_BITRATE])-1);
break;
case INFOPIPE_KEY_FREQUENCY:
strncpy(items[INFOPIPE_FREQUENCY],line,sizeof(items[INFOPIPE_FREQUENCY])-1);
break;
case INFOPIPE_KEY_CHANNELS:
strncpy(items[INFOPIPE_CHANNELS],line,sizeof(items[INFOPIPE_CHANNELS])-1);
break;
case INFOPIPE_KEY_TITLE:
strncpy(items[INFOPIPE_TITLE],line,sizeof(items[INFOPIPE_TITLE])-1);
break;
case INFOPIPE_KEY_FILE:
strncpy(items[INFOPIPE_FILENAME],line,sizeof(items[INFOPIPE_FILENAME])-1);
break;
default:
break;
}
}
/* -- debug --
for(i=0;i<14;i++)
printf("%s\n",items[i]);
*/
}
}
else {
/* -- debug --
printf("no infopipe data\n");
*/
}
close(fd);
break;
}
/* Deliver the refreshed items array to g_items. */
pthread_mutex_lock(&info.infopipe.item_mutex);
memcpy(&infopipe_items,items,sizeof(items));
pthread_mutex_unlock(&info.infopipe.item_mutex);
/* Grab the runnable signal for next loop. */
pthread_mutex_lock(&info.infopipe.runnable_mutex);
runnable=info.infopipe.runnable;
pthread_mutex_unlock(&info.infopipe.runnable_mutex);
sleep(1);
}
pthread_exit(NULL);
}

56
src/infopipe.h Normal file
View File

@ -0,0 +1,56 @@
/* -------------------------------------------------------------------------
* infopipe.h: conky support for infopipe plugin
*
* Copyright (C) 2005 Philip Kovacs kovacsp3@comcast.net
*
* $Id $
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* --------------------------------------------------------------------------- */
#ifndef INFOPIPE_H
#define INFOPIPE_H
enum _infopipe_items {
INFOPIPE_STATUS=0,
INFOPIPE_TITLE,
INFOPIPE_LENGTH,
INFOPIPE_LENGTH_SECONDS,
INFOPIPE_POSITION,
INFOPIPE_POSITION_SECONDS,
INFOPIPE_BITRATE,
INFOPIPE_FREQUENCY,
INFOPIPE_CHANNELS,
INFOPIPE_FILENAME,
INFOPIPE_PLAYLIST_LENGTH,
INFOPIPE_PLAYLIST_POSITION,
};
/* 12 slots for the infopipe values */
typedef char infopipe_t[12][128];
/* create a worker thread for infopipe media player status */
int create_infopipe_thread(void);
/* destroy infopipe media player worker thread */
int destroy_infopipe_thread(void);
/* Service routine for the conky main thread */
void update_infopipe(void);
/* Thread functions */
void *infopipe_thread_func(void *);
#endif

View File

@ -1,536 +0,0 @@
/* -------------------------------------------------------------------------
* xmms.c: conky support for XMMS-related projects
*
* Copyright (C) 2005 Philip Kovacs kovacsp3@comcast.net
*
* $Id$
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* --------------------------------------------------------------------------- */
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "config.h"
#include "conky.h"
#include "xmms.h"
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS)
#include <glib.h>
#include <dlfcn.h>
#endif
#if defined(INFOPIPE)
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include <fcntl.h>
#define INFOPIPE_NAMED_PIPE "/tmp/xmms-info"
/* 14 keys comprise the output of the infopipe plugin. */
enum _infopipe_keys {
INFOPIPE_PROTOCOL=0,
INFOPIPE_VERSION,
INFOPIPE_STATUS,
INFOPIPE_PLAYLIST_TUNES,
INFOPIPE_PLAYLIST_CURRTUNE,
INFOPIPE_USEC_POSITION,
INFOPIPE_POSITION,
INFOPIPE_USEC_TIME,
INFOPIPE_TIME,
INFOPIPE_BITRATE,
INFOPIPE_FREQUENCY,
INFOPIPE_CHANNELS,
INFOPIPE_TITLE,
INFOPIPE_FILE
};
#endif
static char *xmms_project_name[] = {
"none",
"xmms",
"bmp",
"audacious",
"infopipe"
};
/* access to this item array is synchronized with mutexes */
static xmms_t g_items;
/* ------------------------------------
* Conky update function for XMMS data.
* ------------------------------------ */
void update_xmms(void)
{
/*
The worker thread is updating the g_items array asynchronously to the main
conky thread. We merely copy the g_items array into the main thread's info
structure when the main thread's update cycle fires. Note that using the
mutexes here makes it easier since we won't have to do any sync in conky.c.
*/
pthread_mutex_lock(&info.xmms.item_mutex);
memcpy(&info.xmms.items,g_items,sizeof(g_items));
pthread_mutex_unlock(&info.xmms.item_mutex);
}
/* ------------------------------------------------------------
* Create a worker thread for xmms-related media player status.
*
* Returns 0 on success, -1 on error.
* ------------------------------------------------------------*/
int create_xmms_thread(void)
{
/* Was an an available project requested? */
if (!TEST_XMMS_PROJECT_AVAILABLE(info.xmms.project_mask, info.xmms.current_project)) {
ERR("xmms_player '%s' not configured", xmms_project_name[info.xmms.current_project]);
return(-1);
}
/* The project should not be PROJECT_NONE */
if (info.xmms.current_project==PROJECT_NONE)
return(-1);
/* Is a worker is thread already running? */
if (info.xmms.thread)
return(-1);
/* Joinable thread for xmms activity */
pthread_attr_init(&info.xmms.thread_attr);
pthread_attr_setdetachstate(&info.xmms.thread_attr, PTHREAD_CREATE_JOINABLE);
/* Init mutexes */
pthread_mutex_init(&info.xmms.item_mutex, NULL);
pthread_mutex_init(&info.xmms.runnable_mutex, NULL);
/* Init runnable condition for worker thread */
pthread_mutex_lock(&info.xmms.runnable_mutex);
info.xmms.runnable=1;
pthread_mutex_unlock(&info.xmms.runnable_mutex);
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS)
if (info.xmms.current_project==PROJECT_XMMS ||
info.xmms.current_project==PROJECT_BMP ||
info.xmms.current_project==PROJECT_AUDACIOUS) {
if (pthread_create(&info.xmms.thread, &info.xmms.thread_attr, xmms_thread_func_dynamic, NULL))
return(-1);
}
#endif
#if defined(INFOPIPE)
if (info.xmms.current_project==PROJECT_INFOPIPE) {
if (pthread_create(&info.xmms.thread, &info.xmms.thread_attr, xmms_thread_func_infopipe, NULL))
return(-1);
}
#endif
return 0;
}
/* ------------------------------------------------
* Destroy xmms-related media player status thread.
*
* Returns 0 on success, -1 on error.
* ------------------------------------------------ */
int destroy_xmms_thread(void)
{
/* Is a worker is thread running? If not, no error. */
if (!info.xmms.thread)
return(0);
/* Signal xmms worker thread to terminate */
pthread_mutex_lock(&info.xmms.runnable_mutex);
info.xmms.runnable=0;
pthread_mutex_unlock(&info.xmms.runnable_mutex);
/* Destroy thread attribute and wait for thread */
pthread_attr_destroy(&info.xmms.thread_attr);
if (pthread_join(info.xmms.thread, NULL))
return(-1);
/* Destroy mutexes */
pthread_mutex_destroy(&info.xmms.item_mutex);
pthread_mutex_destroy(&info.xmms.runnable_mutex);
info.xmms.thread=(pthread_t)0;
return 0;
}
#if defined(XMMS) || defined(BMP) || defined(AUDACIOUS)
void check_dlerror(void)
{
static const char *error;
if ((error = dlerror()) != NULL) {
ERR("error grabbing function symbol");
pthread_exit(NULL);
}
}
/* ------------------------------------------------------------
* Worker thread function for XMMS/BMP/Audacious data sampling.
* ------------------------------------------------------------ */
void *xmms_thread_func_dynamic(void *pvoid)
{
void *handle,*glib_v1_2_handle;
int runnable;
static xmms_t items;
gint session,playpos,frames,length;
gint rate,freq,chans;
gchar *psong,*pfilename;
/* Function pointers for the functions we load dynamically */
void (*g_free_v1_2)(gpointer mem);
gboolean (*xmms_remote_is_running)(gint session);
gboolean (*xmms_remote_is_paused)(gint session);
gboolean (*xmms_remote_is_playing)(gint session);
gint (*xmms_remote_get_playlist_pos)(gint session);
gchar *(*xmms_remote_get_playlist_title)(gint session, gint pos);
gint (*xmms_remote_get_playlist_time)(gint session, gint pos);
gint (*xmms_remote_get_output_time)(gint session);
void (*xmms_remote_get_info)(gint session, gint *rate, gint *freq, gint *chans);
gchar *(*xmms_remote_get_playlist_file)(gint session, gint pos);
gint (*xmms_remote_get_playlist_length)(gint session);
pvoid=(void *)pvoid; /* avoid warning */
session=0;
psong=NULL;
pfilename=NULL;
handle=NULL;
glib_v1_2_handle=NULL;
g_free_v1_2=NULL;
/* Conky will likely be linked to libglib-2.0.so and not libglib-1.2.so.0. If conky is receiving
* gchar * data from xmms, these strings need to be freed using g_free() from libglib-1.2.so.0.
* This macro selects the g_free() from the correct library. */
#define G_FREE(mem) (info.xmms.current_project==PROJECT_XMMS ? (*g_free_v1_2)(mem) : g_free(mem))
switch(info.xmms.current_project) {
case (PROJECT_XMMS) :
/* make an effort to find the glib 1.2 shared lib */
if ( ((glib_v1_2_handle = dlopen("libglib-1.2.so.0", RTLD_LAZY))==NULL) &&
((glib_v1_2_handle = dlopen("libglib-12.so.0", RTLD_LAZY))==NULL) &&
((glib_v1_2_handle = dlopen("libglib-12.so", RTLD_LAZY))==NULL) &&
((glib_v1_2_handle = dlopen("libglib12.so", RTLD_LAZY))==NULL) &&
((glib_v1_2_handle = dlopen("libglib.so", RTLD_LAZY))==NULL) )
{
ERR("unable to find glib 1.2 shared object lib!");
pthread_exit(NULL);
}
g_free_v1_2=dlsym(glib_v1_2_handle, "g_free");
check_dlerror();
handle = dlopen("libxmms.so", RTLD_LAZY);
if (!handle) {
ERR("unable to open libxmms.so");
pthread_exit(NULL);
}
break;
case (PROJECT_BMP) :
handle = dlopen("libbeep.so", RTLD_LAZY);
if (!handle) {
ERR("unable to open libbeep.so");
pthread_exit(NULL);
}
break;
case (PROJECT_AUDACIOUS) :
handle = dlopen("libaudacious.so", RTLD_LAZY);
if (!handle) {
ERR("unable to open libaudacious.so");
pthread_exit(NULL);
}
break;
case (PROJECT_NONE) :
default :
pthread_exit(NULL);
}
/* Grab the function pointers from the library */
xmms_remote_is_running = dlsym(handle, "xmms_remote_is_running");
check_dlerror();
xmms_remote_is_paused = dlsym(handle, "xmms_remote_is_paused");
check_dlerror();
xmms_remote_is_playing = dlsym(handle, "xmms_remote_is_playing");
check_dlerror();
xmms_remote_get_playlist_pos = dlsym(handle, "xmms_remote_get_playlist_pos");
check_dlerror();
xmms_remote_get_playlist_title = dlsym(handle, "xmms_remote_get_playlist_title");
check_dlerror();
xmms_remote_get_playlist_time = dlsym(handle, "xmms_remote_get_playlist_time");
check_dlerror();
xmms_remote_get_output_time = dlsym(handle, "xmms_remote_get_output_time");
check_dlerror();
xmms_remote_get_info = dlsym(handle, "xmms_remote_get_info");
xmms_remote_get_playlist_file = dlsym(handle, "xmms_remote_get_playlist_file");
check_dlerror();
xmms_remote_get_playlist_length = dlsym(handle, "xmms_remote_get_playlist_length");
check_dlerror();
/* Grab the runnable signal. Should be non-zero here or we do nothing. */
pthread_mutex_lock(&info.xmms.runnable_mutex);
runnable=info.xmms.runnable;
pthread_mutex_unlock(&info.xmms.runnable_mutex );
/* Loop until the main thread sets the runnable signal to 0. */
while(runnable) {
for (;;) { /* convenience loop so we can break below */
if (!(*xmms_remote_is_running)(session)) {
memset(&items,0,sizeof(items));
strcpy(items[XMMS_STATUS],"Not running");
break;
}
/* Player status */
if ((*xmms_remote_is_paused)(session))
strcpy(items[XMMS_STATUS],"Paused");
else if ((*xmms_remote_is_playing)(session))
strcpy(items[XMMS_STATUS],"Playing");
else
strcpy(items[XMMS_STATUS],"Stopped");
/* Current song title */
playpos = (*xmms_remote_get_playlist_pos)(session);
psong = (*xmms_remote_get_playlist_title)(session, playpos);
if (psong) {
strncpy(items[XMMS_TITLE],psong,sizeof(items[XMMS_TITLE])-1);
G_FREE(psong);
psong=NULL;
}
/* Current song length as MM:SS */
frames = (*xmms_remote_get_playlist_time)(session,playpos);
length = frames / 1000;
snprintf(items[XMMS_LENGTH],sizeof(items[XMMS_LENGTH])-1,
"%d:%.2d", length / 60, length % 60);
/* Current song length in seconds */
snprintf(items[XMMS_LENGTH_SECONDS],sizeof(items[XMMS_LENGTH_SECONDS])-1,
"%d", length);
/* Current song position as MM:SS */
frames = (*xmms_remote_get_output_time)(session);
length = frames / 1000;
snprintf(items[XMMS_POSITION],sizeof(items[XMMS_POSITION])-1,
"%d:%.2d", length / 60, length % 60);
/* Current song position in seconds */
snprintf(items[XMMS_POSITION_SECONDS],sizeof(items[XMMS_POSITION_SECONDS])-1,
"%d", length);
/* Current song bitrate */
(*xmms_remote_get_info)(session, &rate, &freq, &chans);
snprintf(items[XMMS_BITRATE],sizeof(items[XMMS_BITRATE])-1, "%d", rate);
/* Current song frequency */
snprintf(items[XMMS_FREQUENCY],sizeof(items[XMMS_FREQUENCY])-1, "%d", freq);
/* Current song channels */
snprintf(items[XMMS_CHANNELS],sizeof(items[XMMS_CHANNELS])-1, "%d", chans);
/* Current song filename */
pfilename = (*xmms_remote_get_playlist_file)(session,playpos);
if (pfilename) {
strncpy(items[XMMS_FILENAME],pfilename,sizeof(items[XMMS_FILENAME])-1);
G_FREE(pfilename);
pfilename=NULL;
}
/* Length of the Playlist (number of songs) */
length = (*xmms_remote_get_playlist_length)(session);
snprintf(items[XMMS_PLAYLIST_LENGTH],sizeof(items[XMMS_PLAYLIST_LENGTH])-1, "%d", length);
/* Playlist position (index of song) */
snprintf(items[XMMS_PLAYLIST_POSITION],sizeof(items[XMMS_PLAYLIST_POSITION])-1, "%d", playpos+1);
break;
}
/* Deliver the refreshed items array to g_items. */
pthread_mutex_lock(&info.xmms.item_mutex);
memcpy(&g_items,items,sizeof(items));
pthread_mutex_unlock(&info.xmms.item_mutex);
/* Grab the runnable signal for next loop. */
pthread_mutex_lock(&info.xmms.runnable_mutex);
runnable=info.xmms.runnable;
pthread_mutex_unlock(&info.xmms.runnable_mutex);
sleep(1);
}
if (handle)
dlclose(handle);
if (glib_v1_2_handle)
dlclose(glib_v1_2_handle);
pthread_exit(NULL);
}
#endif
#if defined(INFOPIPE)
/* --------------------------------------------------
* Worker thread function for InfoPipe data sampling.
* -------------------------------------------------- */
void *xmms_thread_func_infopipe(void *pvoid)
{
int i,rc,fd,runnable;
fd_set readset;
struct timeval tm;
static char buf[2048],line[128];
static xmms_t items;
char *pbuf,c;
pvoid=(void*)pvoid; /* avoid warning */
/* Grab the runnable signal. Should be non-zero here or we do nothing. */
pthread_mutex_lock(&info.xmms.runnable_mutex);
runnable=info.xmms.runnable;
pthread_mutex_unlock(&info.xmms.runnable_mutex );
/* Loop until the main thread sets the runnable signal to 0. */
while(runnable) {
for (;;) { /* convenience loop so we can break below */
memset(buf,0,sizeof(buf));
if ((fd=open(INFOPIPE_NAMED_PIPE, O_RDONLY | O_NONBLOCK)) < 0) {
/* InfoPipe is not running */
memset(items,0,sizeof(items));
strcpy(items[XMMS_STATUS],"Not running");
break;
}
FD_ZERO(&readset);
FD_SET(fd,&readset);
/* On Linux, select() reduces the timer by the amount of time not slept,
* so we must reset the timer with each loop. */
tm.tv_sec=1;
tm.tv_usec=0;
rc=select(fd+1,&readset,NULL,NULL,&tm);
if (rc == -1) {
/* -- debug --
perror("infopipe select()");
*/
}
else if (rc && FD_ISSET(fd,&readset)) { /* ready to read */
if (read(fd,buf,sizeof(buf)) > 0) { /* buf has data */
pbuf=buf;
for (i=0;i<14;i++) {
/* 14 lines of key: value pairs presented in a known order */
memset(line,0,sizeof(line));
if ( sscanf(pbuf,"%*[^:]: %[^\n]",line) == EOF )
break;
while((c = *pbuf++) && (c != '\n'));
switch(i) {
case INFOPIPE_PROTOCOL:
break;
case INFOPIPE_VERSION:
break;
case INFOPIPE_STATUS:
strncpy(items[XMMS_STATUS],line,sizeof(items[XMMS_STATUS])-1);
break;
case INFOPIPE_PLAYLIST_TUNES:
strncpy(items[XMMS_PLAYLIST_LENGTH],line,sizeof(items[XMMS_PLAYLIST_LENGTH])-1);
break;
case INFOPIPE_PLAYLIST_CURRTUNE:
strncpy(items[XMMS_PLAYLIST_POSITION],line,sizeof(items[XMMS_PLAYLIST_POSITION])-1);
break;
case INFOPIPE_USEC_POSITION:
snprintf(items[XMMS_POSITION_SECONDS],sizeof(items[XMMS_POSITION_SECONDS])-1,
"%d", atoi(line) / 1000);
break;
case INFOPIPE_POSITION:
strncpy(items[XMMS_POSITION],line,sizeof(items[XMMS_POSITION])-1);
break;
case INFOPIPE_USEC_TIME:
snprintf(items[XMMS_LENGTH_SECONDS],sizeof(items[XMMS_LENGTH_SECONDS])-1,
"%d", atoi(line) / 1000);
break;
case INFOPIPE_TIME:
strncpy(items[XMMS_LENGTH],line,sizeof(items[XMMS_LENGTH])-1);
break;
case INFOPIPE_BITRATE:
strncpy(items[XMMS_BITRATE],line,sizeof(items[XMMS_BITRATE])-1);
break;
case INFOPIPE_FREQUENCY:
strncpy(items[XMMS_FREQUENCY],line,sizeof(items[XMMS_FREQUENCY])-1);
break;
case INFOPIPE_CHANNELS:
strncpy(items[XMMS_CHANNELS],line,sizeof(items[XMMS_CHANNELS])-1);
break;
case INFOPIPE_TITLE:
strncpy(items[XMMS_TITLE],line,sizeof(items[XMMS_TITLE])-1);
break;
case INFOPIPE_FILE:
strncpy(items[XMMS_FILENAME],line,sizeof(items[XMMS_FILENAME])-1);
break;
default:
break;
}
}
/* -- debug --
for(i=0;i<14;i++)
printf("%s\n",items[i]);
*/
}
}
else {
/* -- debug --
printf("no infopipe data\n");
*/
}
close(fd);
break;
}
/* Deliver the refreshed items array to g_items. */
pthread_mutex_lock(&info.xmms.item_mutex);
memcpy(&g_items,items,sizeof(items));
pthread_mutex_unlock(&info.xmms.item_mutex);
/* Grab the runnable signal for next loop. */
pthread_mutex_lock(&info.xmms.runnable_mutex);
runnable=info.xmms.runnable;
pthread_mutex_unlock(&info.xmms.runnable_mutex);
sleep(1);
}
pthread_exit(NULL);
}
#endif