Hannu Saransaari <hipo at users dot sourceforge dot net>
Main code
+Henri Häkkinen <henux at users dot sourceforge dot net>
+ MOC support
+
hinokind <hinokind at users dot sourceforge dot net>
support negative values in human_readable()
Linux wifi code
RSS code (created with Mikko Sysikaski)
+Tris <asto at users dot sourceforge dot net>
+ Scroll step patch
+
tyir <tyir at users dot sourceforge dot net>
MPD features patch 1319461
# $Id$
+2008-09-24
+ * Introduced (buggy) support for IMAP IDLE
+ * Added support for MOC (the console audio player) (thanks henux)
+ * Added scroll step patch (thanks asto)
+
2008-09-11
* Maybe fix missing include bug
(http://bugs.gentoo.org/show_bug.cgi?id=235233)
Percentage of memory in use
+ 1mmoc_state0m
+ Current state of MOC; playing, stopped etc.
+
+
+ 1mmoc_file0m
+ File name of the current MOC song
+
+
+ 1mmoc_title0m
+ Title of the current MOC song
+
+
+ 1mmoc_artist0m
+ Artist of the current MOC song
+
+
+ 1mmoc_song0m
+ The current song name being played in MOC.
+
+
+ 1mmoc_album0m
+ Album of the current MOC song
+
+
+ 1mmoc_totaltime0m
+ Total length of the current MOC song
+
+
+ 1mmoc_timeleft0m
+ Time left in the current MOC song
+
+
+ 1mmoc_curtime0m
+ Current time of the current MOC song
+
+
+ 1mmoc_bitrate0m
+ Bitrate in the current MOC song
+
+
+ 1mmoc_rate0m
+ Rate of the current MOC song
+
+
1mmonitor0m
Number of the monitor on which conky is running
Running processes (not sleeping), requires Linux 2.6
- 1mscroll length text0m
- Scroll ’text’ showing ’length’ number of characters at the same
- time. The text may also contain variables. If a var creates out‐
- put on multiple lines then the lines are placed behind each oth‐
- er separated with a ’|’-sign. Do NOT use vars that change colors
- or otherwise affect the design inside a scrolling text. If you
- want spaces between the start and the end of ’text’, place them
- at the end of ’text’ not at the front ("foobar" and " foobar"
- can both generate "barfoo" but "foobar " will keep the spaces
- like this "bar foo").
+ 1mscroll length (step) text0m
+ Scroll ’text’ by ’step’ characters showing ’length’ number of
+ characters at the same time. The text may also contain vari‐
+ ables. ’step’ is optional and defaults to 1 if not set. If a var
+ creates output on multiple lines then the lines are placed be‐
+ hind each other separated with a ’|’-sign. Do NOT use vars that
+ change colors or otherwise affect the design inside a scrolling
+ text. If you want spaces between the start and the end of
+ ’text’, place them at the end of ’text’ not at the front ("foo‐
+ bar" and " foobar" can both generate "barfoo" but "foobar " will
+ keep the spaces like this "bar foo").
1mshadecolor (color)0m
1msmapi (ARGS)0m
- when using smapi, display contents of the /sys/devices/plat‐
- form/smapi directory. ARGS are either ’(FILENAME)’ or ’bat (IN‐
- DEX) (FILENAME)’ to display the corresponding files’ content.
- This is a very raw method of accessing the smapi values. When
+ when using smapi, display contents of the /sys/devices/plat‐
+ form/smapi directory. ARGS are either ’(FILENAME)’ or ’bat (IN‐
+ DEX) (FILENAME)’ to display the corresponding files’ content.
+ This is a very raw method of accessing the smapi values. When
available, better use one of the smapi_* variables instead.
1msmapi_bat_bar (INDEX),(height),(width)0m
- when using smapi, display the remaining capacity of the battery
+ when using smapi, display the remaining capacity of the battery
with index INDEX as a bar.
1msmapi_bat_perc (INDEX)0m
- when using smapi, display the remaining capacity in percent of
- the battery with index INDEX. This is a separate variable be‐
+ when using smapi, display the remaining capacity in percent of
+ the battery with index INDEX. This is a separate variable be‐
cause it supports the ’use_spacer’ configuration option.
1msmapi_bat_power INDEX0m
- when using smapi, display the current power of the battery with
- index INDEX in watt. This is a separate variable because the
- original read out value is being converted from mW. The sign of
- the output reflects charging (positive) or discharging (nega‐
+ when using smapi, display the current power of the battery with
+ index INDEX in watt. This is a separate variable because the
+ original read out value is being converted from mW. The sign of
+ the output reflects charging (positive) or discharging (nega‐
tive) state.
1msmapi_bat_temp INDEX0m
when using smapi, display the current temperature of the battery
- with index INDEX in degree Celsius. This is a separate variable
+ with index INDEX in degree Celsius. This is a separate variable
because the original read out value is being converted from mil‐
li degree Celsius.
The connection index provides you with access to each connection
in the port monitor. The monitor will return information for in‐
dex values from 0 to n-1 connections. Values higher than n-1 are
- simply ignored. For the "count" item, the connection index must
+ simply ignored. For the "count" item, the connection index must
be omitted. It is required for all other items.
Examples:
- 1m${tcp_portmon 6881 6999 count} 22m- displays the number of connec‐
+ 1m${tcp_portmon 6881 6999 count} 22m- displays the number of connec‐
tions in the bittorrent port range
- 1m${tcp_portmon 22 22 rip 0} 22m- displays the remote host ip of the
+ 1m${tcp_portmon 22 22 rip 0} 22m- displays the remote host ip of the
first sshd connection
- 1m${tcp_portmon 22 22 rip 9} 22m- displays the remote host ip of the
+ 1m${tcp_portmon 22 22 rip 9} 22m- displays the remote host ip of the
tenth sshd connection
1m${tcp_portmon 1 1024 rhost 0} 22m- displays the remote host name of
the first connection on a privileged port
1m${tcp_portmon 1 1024 rport 4} 22m- displays the remote host port of
the fifth connection on a privileged port
- 1m${tcp_portmon 1 65535 lservice 14} 22m- displays the local service
+ 1m${tcp_portmon 1 65535 lservice 14} 22m- displays the local service
name of the fifteenth connection in the range of all ports
Note that port monitor variables which share the same port range
actually refer to the same monitor, so many references to a sin‐
gle port range for different items and different indexes all use
- the same monitor internally. In other words, the program avoids
+ the same monitor internally. In other words, the program avoids
creating redundant monitors.
1mtexeci interval command0m
- Runs a command at an interval inside a thread and displays the
- output. Same as $execi, except the command is run inside a
- thread. Use this if you have a slow script to keep Conky updat‐
- ing. You should make the interval slightly longer then the time
- it takes your script to execute. For example, if you have a
- script that take 5 seconds to execute, you should make the in‐
+ Runs a command at an interval inside a thread and displays the
+ output. Same as $execi, except the command is run inside a
+ thread. Use this if you have a slow script to keep Conky updat‐
+ ing. You should make the interval slightly longer then the time
+ it takes your script to execute. For example, if you have a
+ script that take 5 seconds to execute, you should make the in‐
terval at least 6 seconds. See also $execi.
1mrss url delay_in_minutes action item_num0m
- Download and parse RSS feeds. Action may be one of the follow‐
- ing: feed_title, item_title (with num par), item_desc (with num
+ Download and parse RSS feeds. Action may be one of the follow‐
+ ing: feed_title, item_title (with num par), item_desc (with num
par) and item_titles.
1mtime (format)0m
- Local time, see man strftime to get more information about for‐
+ Local time, see man strftime to get more information about for‐
mat
1mtztime (timezone) (format)0m
- Local time for specified timezone, see man strftime to get more
- information about format. The timezone argument is specified in
- similar fashion as TZ environment variable. For hints, look in
+ Local time for specified timezone, see man strftime to get more
+ information about format. The timezone argument is specified in
+ similar fashion as TZ environment variable. For hints, look in
/usr/share/zoneinfo. e.g. US/Pacific, Europe/Zurich, etc.
1mtotaldown net0m
- Total download, overflows at 4 GB on Linux with 32-bit arch and
+ Total download, overflows at 4 GB on Linux with 32-bit arch and
there doesn’t seem to be a way to know how many times it has al‐
ready done that before conky has started.
1mtop type, num0m
- This takes arguments in the form:top (name) (number) Basically,
- processes are ranked from highest to lowest in terms of cpu us‐
- age, which is what (num) represents. The types are: "name",
- "pid", "cpu", "mem", "mem_res", "mem_vsize", and "time". There
+ This takes arguments in the form:top (name) (number) Basically,
+ processes are ranked from highest to lowest in terms of cpu us‐
+ age, which is what (num) represents. The types are: "name",
+ "pid", "cpu", "mem", "mem_res", "mem_vsize", and "time". There
can be a max of 10 processes listed.
Upload speed in KiB with one decimal
- 1mupspeedgraph normal|log net (height),(width) (gradient colour 1) (gra‐0m
+ 1mupspeedgraph normal|log net (height),(width) (gradient colour 1) (gra‐0m
1mdient colour 2) (scale)0m
- Upload speed graph, colours defined in hex, minus the #. If
- scale is non-zero, it becomes the scale for the graph. Uses a
- logarithmic scale (to see small numbers) when you use "log" in‐
+ Upload speed graph, colours defined in hex, minus the #. If
+ scale is non-zero, it becomes the scale for the graph. Uses a
+ logarithmic scale (to see small numbers) when you use "log" in‐
stead of "normal".
1mvoffset (pixels)0m
- Change vertical offset by N pixels. Negative values will cause
+ Change vertical offset by N pixels. Negative values will cause
text to overlap. See also $offset.
1mvoltage_mv (n)0m
- Returns CPU #n’s voltage in mV. CPUs are counted from 1. If
+ Returns CPU #n’s voltage in mV. CPUs are counted from 1. If
omitted, the parameter defaults to 1.
1meve api_userid api_key character_id0m
- Fetches your currently training skill from the Eve Online API
+ Fetches your currently training skill from the Eve Online API
servers (http://www.eve-online.com/) and displays the skill
along with the remaining training time.
1mBUGS0m
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. If you do try running Conky
- in its own window, be sure to read up on the own_window_type settings
+ in its own window, be sure to read up on the own_window_type settings
and experiment.
1mSEE ALSO0m
#conky on irc.freenode.net
1mCOPYING0m
- Copyright (c) 2005-2008 Brenden Matthews, Philip Kovacs, et. al. Any
+ Copyright (c) 2005-2008 Brenden Matthews, Philip Kovacs, et. al. Any
original torsmo code is licensed under the BSD license (see LICENSE.BSD
for a copy). All code written since the fork of torsmo is licensed un‐
der the GPL (see LICENSE.GPL for a copy), except where noted different‐
- ly (such as in portmon code, timed thread code, and audacious code
+ ly (such as in portmon code, timed thread code, and audacious code
which are LGPL, and prss which is an MIT-style license).
1mAUTHORS0m
fi
dnl
+dnl MOC
+dnl
+
+AC_ARG_ENABLE([moc],
+ AC_HELP_STRING([--disable-moc], [disable if you do not want MOC support @<:@default=yes@:>@]),
+ [want_moc="$enableval"], [want_moc=yes])
+
+AM_CONDITIONAL(BUILD_MOC, test x$want_moc = xyes)
+if test x$want_moc = xyes; then
+ AC_DEFINE(MOC, 1, [Define if you want MOC support])
+fi
+
+dnl
dnl XMMS2
dnl
Audacious: $want_audacious
BMPx: $want_bmpx
MPD: $want_mpd
+ MOC: $want_moc
XMMS2: $want_xmms2
* General:
Percentage of memory in use
.TP
+\fB\*(T<\fBmoc_state\fR\*(T>\fR
+Current state of MOC; playing, stopped etc.
+
+.TP
+\fB\*(T<\fBmoc_file\fR\*(T>\fR
+File name of the current MOC song
+
+.TP
+\fB\*(T<\fBmoc_title\fR\*(T>\fR
+Title of the current MOC song
+
+.TP
+\fB\*(T<\fBmoc_artist\fR\*(T>\fR
+Artist of the current MOC song
+
+.TP
+\fB\*(T<\fBmoc_song\fR\*(T>\fR
+The current song name being played in MOC.
+
+.TP
+\fB\*(T<\fBmoc_album\fR\*(T>\fR
+Album of the current MOC song
+
+.TP
+\fB\*(T<\fBmoc_totaltime\fR\*(T>\fR
+Total length of the current MOC song
+
+.TP
+\fB\*(T<\fBmoc_timeleft\fR\*(T>\fR
+Time left in the current MOC song
+
+.TP
+\fB\*(T<\fBmoc_curtime\fR\*(T>\fR
+Current time of the current MOC song
+
+.TP
+\fB\*(T<\fBmoc_bitrate\fR\*(T>\fR
+Bitrate in the current MOC song
+
+.TP
+\fB\*(T<\fBmoc_rate\fR\*(T>\fR
+Rate of the current MOC song
+
+.TP
\fB\*(T<\fBmonitor\fR\*(T>\fR
Number of the monitor on which conky is running
Running processes (not sleeping), requires Linux 2.6
.TP
-\fB\*(T<\fBscroll\fR\*(T>\fR \*(T<\fBlength text\fR\*(T>
-Scroll 'text' showing 'length' number of characters at the same time. The text may also contain variables. If a var creates output on multiple lines then the lines are placed behind each other separated with a '|'-sign. Do NOT use vars that change colors or otherwise affect the design inside a scrolling text. If you want spaces between the start and the end of 'text', place them at the end of 'text' not at the front ("foobar" and " foobar" can both generate "barfoo" but "foobar " will keep the spaces like this "bar foo").
+\fB\*(T<\fBscroll\fR\*(T>\fR \*(T<\fBlength (step) text\fR\*(T>
+Scroll 'text' by 'step' characters showing 'length' number of characters at the same time. The text may also contain variables. 'step' is optional and defaults to 1 if not set. If a var creates output on multiple lines then the lines are placed behind each other separated with a '|'-sign. Do NOT use vars that change colors or otherwise affect the design inside a scrolling text. If you want spaces between the start and the end of 'text', place them at the end of 'text' not at the front ("foobar" and " foobar" can both generate "barfoo" but "foobar " will keep the spaces like this "bar foo").
.TP
\fB\*(T<\fBshadecolor\fR\*(T>\fR \*(T<\fB(color)\fR\*(T>
<varlistentry>
<term>
+ <command><option>moc_state</option></command>
+ </term>
+ <listitem>
+ Current state of MOC; playing, stopped etc.
+ <para></para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <command><option>moc_file</option></command>
+ </term>
+ <listitem>
+ File name of the current MOC song
+ <para></para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <command><option>moc_title</option></command>
+ </term>
+ <listitem>
+ Title of the current MOC song
+ <para></para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <command><option>moc_artist</option></command>
+ </term>
+ <listitem>
+ Artist of the current MOC song
+ <para></para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <command><option>moc_song</option></command>
+ </term>
+ <listitem>
+ The current song name being played in MOC.
+ <para></para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <command><option>moc_album</option></command>
+ </term>
+ <listitem>
+ Album of the current MOC song
+ <para></para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <command><option>moc_totaltime</option></command>
+ </term>
+ <listitem>
+ Total length of the current MOC song
+ <para></para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <command><option>moc_timeleft</option></command>
+ </term>
+ <listitem>
+ Time left in the current MOC song
+ <para></para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <command><option>moc_curtime</option></command>
+ </term>
+ <listitem>
+ Current time of the current MOC song
+ <para></para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <command><option>moc_bitrate</option></command>
+ </term>
+ <listitem>
+ Bitrate in the current MOC song
+ <para></para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <command><option>moc_rate</option></command>
+ </term>
+ <listitem>
+ Rate of the current MOC song
+ <para></para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
<command><option>monitor</option></command>
</term>
<listitem>
<varlistentry>
<term>
<command><option>scroll</option></command>
- <option>length text</option>
+ <option>length (step) text</option>
</term>
<listitem>
- Scroll 'text' showing 'length' number of characters at the same time. The text may also contain variables. If a var creates output on multiple lines then the lines are placed behind each other separated with a '|'-sign. Do NOT use vars that change colors or otherwise affect the design inside a scrolling text. If you want spaces between the start and the end of 'text', place them at the end of 'text' not at the front ("foobar" and " foobar" can both generate "barfoo" but "foobar " will keep the spaces like this "bar foo").
+ Scroll 'text' by 'step' characters showing 'length' number of characters at the same time. The text may also contain variables. 'step' is optional and defaults to 1 if not set. If a var creates output on multiple lines then the lines are placed behind each other separated with a '|'-sign. Do NOT use vars that change colors or otherwise affect the design inside a scrolling text. If you want spaces between the start and the end of 'text', place them at the end of 'text' not at the front ("foobar" and " foobar" can both generate "barfoo" but "foobar " will keep the spaces like this "bar foo").
<para></para></listitem>
</varlistentry>
mpd = mpd.c libmpdclient.c
endif
+if BUILD_MOC
+moc = moc.c
+endif
+
if BUILD_XMMS2
xmms2 = xmms2.c
endif
mail.c \
mixer.c \
$(mpd) \
+ $(moc) \
$(netbsd) \
$(openbsd) \
$(port_monitors) \
rss.h \
mail.h \
mixer.h \
+ moc.h \
+ moc.c \
mpd.c \
mpd.h \
netbsd.c \
}
#endif
+#ifdef MOC
+ if (NEED(INFO_MOC)) {
+ if (!info.moc.timed_thread) {
+ init_moc(&info.moc);
+ info.moc.timed_thread = timed_thread_create(&update_moc,
+ (void *) &info.moc, info.music_player_interval * 100000);
+ if (!info.moc.timed_thread) {
+ ERR("Failed to create MOC timed thread");
+ }
+ timed_thread_register(info.moc.timed_thread, &info.moc.timed_thread);
+ if (timed_thread_run(info.moc.timed_thread)) {
+ ERR("Failed to run MOC timed thread");
+ }
+ }
+ }
+#endif
+
#ifdef XMMS2
if (NEED(INFO_XMMS2)) {
update_xmms2();
#define MAX_IF_BLOCK_DEPTH 5
#define MAX_TAIL_LINES 100
-/* #define SIGNAL_BLOCKING */
-#undef SIGNAL_BLOCKING
+#define SIGNAL_BLOCKING
+//#undef SIGNAL_BLOCKING
+sigset_t oldmask;
static void print_version(void) __attribute__((noreturn));
#ifdef MPD
" * mpd\n"
#endif /* MPD */
+#ifdef MOC
+ " * moc\n"
+#endif /* MOC */
#ifdef XMMS2
" * xmms2\n"
#endif /* XMMS2 */
static const char *suffixes[] = { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "" };
+
#ifdef X11
/* text size */
OBJ_mpd_percent,
OBJ_mpd_smart,
#endif
+#ifdef MOC
+ OBJ_moc_state,
+ OBJ_moc_file,
+ OBJ_moc_title,
+ OBJ_moc_artist,
+ OBJ_moc_song,
+ OBJ_moc_album,
+ OBJ_moc_totaltime,
+ OBJ_moc_timeleft,
+ OBJ_moc_curtime,
+ OBJ_moc_bitrate,
+ OBJ_moc_rate,
+#endif
OBJ_music_player_interval,
#ifdef XMMS2
OBJ_xmms2_artist,
struct {
char *text;
unsigned int show;
+ unsigned int step;
unsigned int start;
} scroll;
char sendbuf[MAXDATASIZE];
char *reply;
unsigned int fail = 0;
- unsigned int old_unseen = UINT_MAX;
- unsigned int old_messages = UINT_MAX;
+ unsigned long old_unseen = ULONG_MAX;
+ unsigned long old_messages = ULONG_MAX;
struct stat stat_buf;
struct hostent he, *he_res = 0;
int he_errno;
char hostbuff[2048];
struct sockaddr_in their_addr; // connector's address information
struct mail_s *mail = (struct mail_s *)arg;
+ int has_idle = 0;
#ifdef HAVE_GETHOSTBYNAME_R
if (gethostbyname_r(mail->host, &he, hostbuff, sizeof(hostbuff), &he_res, &he_errno)) { // get the host info
fail++;
break;
}
+ if (strstr(recvbuf, " IDLE ") != NULL) {
+ has_idle = 1;
+ }
+
strncpy(sendbuf, "a2 STATUS ", MAXDATASIZE);
strncat(sendbuf, mail->folder, MAXDATASIZE - strlen(sendbuf) - 1);
strncat(sendbuf, " (MESSAGES UNSEEN)\r\n",
fail++;
break;
}
+
// now we get the data
reply = strstr(recvbuf, " (MESSAGES ");
reply += 2;
&mail->unseen);
timed_thread_unlock(mail->p_timed_thread);
}
- strncpy(sendbuf, "a3 logout\r\n", MAXDATASIZE);
- if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
- perror("send a3");
- fail++;
- break;
- }
- timeout.tv_sec = 60; // 60 second timeout i guess
- timeout.tv_usec = 0;
- FD_ZERO(&fdset);
- FD_SET(sockfd, &fdset);
- res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
- if (res > 0) {
- if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
- perror("recv a3");
- fail++;
- break;
- }
- }
- recvbuf[numbytes] = '\0';
- if (strstr(recvbuf, "a3 OK") == NULL) {
- ERR("IMAP logout failed: %s", recvbuf);
- fail++;
- break;
- }
if (strlen(mail->command) > 1 && (mail->unseen > old_unseen
|| (mail->messages > old_messages && mail->unseen > 0))) {
// new mail goodie
fail = 0;
old_unseen = mail->unseen;
old_messages = mail->messages;
+
+ if (has_idle) {
+ strncpy(sendbuf, "a4 SELECT ", MAXDATASIZE);
+ strncat(sendbuf, mail->folder, MAXDATASIZE - strlen(sendbuf) - 1);
+ strncat(sendbuf, "\r\n", MAXDATASIZE - strlen(sendbuf) - 1);
+ if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
+ perror("send a4");
+ fail++;
+ break;
+ }
+ timeout.tv_sec = 60; // 60 second timeout i guess
+ timeout.tv_usec = 0;
+ FD_ZERO(&fdset);
+ FD_SET(sockfd, &fdset);
+ res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
+ if (res > 0) {
+ if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
+ perror("recv a4");
+ fail++;
+ break;
+ }
+ }
+ recvbuf[numbytes] = '\0';
+ if (strstr(recvbuf, "a4 OK") == NULL) {
+ ERR("IMAP status failed: %s", recvbuf);
+ fail++;
+ break;
+ }
+
+ strncpy(sendbuf, "a5 IDLE\r\n", MAXDATASIZE);
+ if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
+ perror("send a5");
+ fail++;
+ break;
+ }
+ timeout.tv_sec = 60; // 60 second timeout i guess
+ timeout.tv_usec = 0;
+ FD_ZERO(&fdset);
+ FD_SET(sockfd, &fdset);
+ res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
+ if (res > 0) {
+ if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
+ perror("recv a5");
+ fail++;
+ break;
+ }
+ }
+ recvbuf[numbytes] = '\0';
+ if (strstr(recvbuf, "+ idling") == NULL) {
+ ERR("IMAP status failed: %s", recvbuf);
+ fail++;
+ break;
+ }
+ recvbuf[0] = '\0';
+
+ while (1) {
+ FD_ZERO(&fdset);
+ FD_SET(sockfd, &fdset);
+ if (timed_thread_test(mail->p_timed_thread)) {
+ break;
+ }
+ res = pselect(sockfd + 1, &fdset, NULL, NULL, NULL, &oldmask);
+ if (res == -1 && errno == EINTR) {
+ timed_thread_exit(mail->p_timed_thread);
+ } else if (res > 0) {
+ if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
+ perror("recv idling");
+ fail++;
+ printf("fail\n");
+ break;
+ }
+ } else {
+ break;
+ }
+ recvbuf[numbytes] = '\0';
+ if (strlen(recvbuf) > 2) {
+ unsigned long messages, unseen;
+ char *buf = recvbuf;
+ buf = strstr(buf, "EXISTS");
+ if (buf) {
+ // back up until we reach '*'
+ while (buf >= recvbuf && buf[0] != '*') {
+ buf--;
+ }
+ if (sscanf(buf, "* %lu EXISTS\r\n", &messages) == 1) {
+ timed_thread_lock(mail->p_timed_thread);
+ mail->messages = messages;
+ timed_thread_unlock(mail->p_timed_thread);
+ }
+ }
+ buf = strstr(buf, "RECENT");
+ if (buf) {
+ // back up until we reach '*'
+ while (buf >= recvbuf && buf[0] != '*') {
+ buf--;
+ }
+ if (sscanf(buf, "* %lu RECENT\r\n", &unseen) == 1) {
+ timed_thread_lock(mail->p_timed_thread);
+ mail->unseen = unseen;
+ timed_thread_unlock(mail->p_timed_thread);
+ }
+ }
+ }
+ if (strlen(mail->command) > 1 && (mail->unseen > old_unseen
+ || (mail->messages > old_messages && mail->unseen > 0))) {
+ // new mail goodie
+ if (system(mail->command) == -1) {
+ perror("system()");
+ }
+ }
+ fail = 0;
+ old_unseen = mail->unseen;
+ old_messages = mail->messages;
+
+ }
+ } else {
+ strncpy(sendbuf, "a3 logout\r\n", MAXDATASIZE);
+ if (send(sockfd, sendbuf, strlen(sendbuf), 0) == -1) {
+ perror("send a3");
+ fail++;
+ break;
+ }
+ timeout.tv_sec = 60; // 60 second timeout i guess
+ timeout.tv_usec = 0;
+ FD_ZERO(&fdset);
+ FD_SET(sockfd, &fdset);
+ res = select(sockfd + 1, &fdset, NULL, NULL, &timeout);
+ if (res > 0) {
+ if ((numbytes = recv(sockfd, recvbuf, MAXDATASIZE - 1, 0)) == -1) {
+ perror("recv a3");
+ fail++;
+ break;
+ }
+ }
+ recvbuf[numbytes] = '\0';
+ if (strstr(recvbuf, "a3 OK") == NULL) {
+ ERR("IMAP logout failed: %s", recvbuf);
+ fail++;
+ break;
+ }
+ }
} while (0);
if ((fstat(sockfd, &stat_buf) == 0) && S_ISSOCK(stat_buf.st_mode)) {
/* if a valid socket, close it */
char sendbuf[MAXDATASIZE];
char *reply;
unsigned int fail = 0;
- unsigned int old_unseen = UINT_MAX;
+ unsigned long old_unseen = ULONG_MAX;
struct stat stat_buf;
struct hostent he, *he_res = 0;
int he_errno;
}
break;
#endif
+#ifdef MOC
+ case OBJ_moc_state:
+ case OBJ_moc_file:
+ case OBJ_moc_title:
+ case OBJ_moc_artist:
+ case OBJ_moc_song:
+ case OBJ_moc_album:
+ case OBJ_moc_totaltime:
+ case OBJ_moc_timeleft:
+ case OBJ_moc_curtime:
+ case OBJ_moc_bitrate:
+ case OBJ_moc_rate:
+ free_moc(&info.moc);
+ break;
+#endif
case OBJ_scroll:
free(obj->data.scroll.text);
break;
obj->data.i = 0;
}
#endif /* MPD */
+#ifdef MOC
+ END OBJ_THREAD(moc_state, INFO_MOC)
+ END OBJ_THREAD(moc_file, INFO_MOC)
+ END OBJ_THREAD(moc_title, INFO_MOC)
+ END OBJ_THREAD(moc_artist, INFO_MOC)
+ END OBJ_THREAD(moc_song, INFO_MOC)
+ END OBJ_THREAD(moc_album, INFO_MOC)
+ END OBJ_THREAD(moc_totaltime, INFO_MOC)
+ END OBJ_THREAD(moc_timeleft, INFO_MOC)
+ END OBJ_THREAD(moc_curtime, INFO_MOC)
+ END OBJ_THREAD(moc_bitrate, INFO_MOC)
+ END OBJ_THREAD(moc_rate, INFO_MOC)
+#endif /* MOC */
#ifdef XMMS2
END OBJ(xmms2_artist, INFO_XMMS2)
END OBJ(xmms2_album, INFO_XMMS2)
END OBJ(scroll, 0)
int n;
- if (arg && sscanf(arg, "%u %n", &obj->data.scroll.show, &n) > 0) {
+ obj->data.scroll.step = 1;
+ if (arg && sscanf(arg, "%u %u %n", &obj->data.scroll.show, &obj->data.scroll.step, &n) > 0) {
obj->data.scroll.text = strndup(arg + n, text_buffer_size);
obj->data.scroll.start = 0;
} else {
- CRIT_ERR("scroll needs arguments: <length> <text>");
+ CRIT_ERR("scroll needs arguments: <length> [<step>] <text>");
}
#ifdef NVIDIA
END OBJ(nvidia, 0)
}
#endif
+#ifdef MOC
+ OBJ(moc_state) {
+ snprintf(p, p_max_size, "%s", (cur->moc.state ? cur->moc.state : "??"));
+ }
+ OBJ(moc_file) {
+ snprintf(p, p_max_size, "%s", (cur->moc.file ? cur->moc.file : "no file"));
+ }
+ OBJ(moc_title) {
+ snprintf(p, p_max_size, "%s", (cur->moc.title ? cur->moc.title : "no title"));
+ }
+ OBJ(moc_artist) {
+ snprintf(p, p_max_size, "%s", (cur->moc.artist ? cur->moc.artist : "no artist"));
+ }
+ OBJ(moc_song) {
+ snprintf(p, p_max_size, "%s", (cur->moc.song ? cur->moc.song : "no song"));
+ }
+ OBJ(moc_album) {
+ snprintf(p, p_max_size, "%s", (cur->moc.album ? cur->moc.album : "no album"));
+ }
+ OBJ(moc_totaltime) {
+ snprintf(p, p_max_size, "%s", (cur->moc.totaltime ? cur->moc.totaltime : "0:00"));
+ }
+ OBJ(moc_timeleft) {
+ snprintf(p, p_max_size, "%s", (cur->moc.timeleft ? cur->moc.timeleft : "0:00"));
+ }
+ OBJ(moc_curtime) {
+ snprintf(p, p_max_size, "%s", (cur->moc.curtime ? cur->moc.curtime : "0:00"));
+ }
+ OBJ(moc_bitrate) {
+ snprintf(p, p_max_size, "%s", (cur->moc.bitrate ? cur->moc.bitrate : "0Kbps"));
+ }
+ OBJ(moc_rate) {
+ snprintf(p, p_max_size, "%s", (cur->moc.rate ? cur->moc.rate : "0KHz"));
+ }
+#endif /* MOC */
#ifdef XMMS2
OBJ(xmms2_artist) {
snprintf(p, p_max_size, "%s", cur->xmms2.artist);
unsigned int j;
char *tmp;
parse_conky_vars(obj->data.scroll.text, p, cur);
+
+ if (strlen(p) <= obj->data.scroll.show) {
+ break;
+ }
#define LINESEPARATOR '|'
//place all the lines behind each other with LINESEPARATOR between them
for(j = 0; p[j] != 0; j++) {
p[obj->data.scroll.show] = 0;
}
//next time, scroll a place more or reset scrolling if we are at the end
- obj->data.scroll.start++;
- if(obj->data.scroll.start == j){
+ obj->data.scroll.start += obj->data.scroll.step;
+ if(obj->data.scroll.start >= j){
obj->data.scroll.start = 0;
}
}
static void main_loop(void)
{
#ifdef SIGNAL_BLOCKING
- sigset_t newmask, oldmask;
+ sigset_t newmask;
#endif
double t;
#ifdef X11
}
#endif
+#ifdef MOC
+ free_moc(&info.moc);
+#endif
+
#ifdef X11
free_fonts();
#endif /* X11 */
memset(text_buffer, 0, max_user_text);
update_text();
}
+ sigemptyset(&oldmask);
}
void clean_up(void)
info.mpd.name = NULL;
info.mpd.file = NULL;
#endif
+#ifdef MOC
+ init_moc(&info.moc);
+#endif
#ifdef XMMS2
info.xmms2.artist = NULL;
info.xmms2.album = NULL;
g_signal_pending = 0;
memset(&info, 0, sizeof(info));
+ clear_net_stats();
#ifdef TCP_PORT_MONITOR
tcp_port_monitor_args.max_port_monitor_connections =
act.sa_flags |= SA_RESTART;
#endif
- if (sigaction(SIGINT, &act, &oact) < 0
- || sigaction(SIGUSR1, &act, &oact) < 0
- || sigaction(SIGHUP,&act,&oact) < 0
- || sigaction(SIGTERM, &act, &oact) < 0) {
+ if ( sigaction(SIGINT, &act, &oact) < 0
+ || sigaction(SIGUSR1, &act, &oact) < 0
+ || sigaction(SIGHUP, &act, &oact) < 0
+ || sigaction(SIGTERM, &act, &oact) < 0) {
ERR("error setting signal handler: %s", strerror(errno));
}
- /* *************** *
- * MAIN CONKY LOOP *
- * *************** */
main_loop();
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include "mpd.h"
#endif
+#ifdef MOC
+#include "moc.h"
+#endif
+
#ifdef XMMS2
#include "xmms2.h"
#endif
#ifdef X11
INFO_X11 = 29,
#endif
- INFO_DNS = 30
-
+ INFO_DNS = 30,
+#ifdef MOC
+ INFO_MOC = 31
+#endif
};
/* get_battery_stuff() item selector */
#ifdef MPD
struct mpd_s mpd;
#endif
+#ifdef MOC
+ struct moc_s moc;
+#endif
#ifdef XMMS2
struct xmms2_s xmms2;
int xmms2_conn_state;
void *(*start_routine)(void *); /* thread function to run */
void *arg; /* thread function argument */
struct timespec interval_time; /* interval_usecs as a struct timespec */
- struct timespec wait_time; /* absolute future time next timed_thread_test will wait until */
+ struct timespec wait_time; /* absolute future time next timed_thread_test will wait until */
};
/* linked list of created threads */