mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-04-01 15:31:52 +00:00
added $texeci, fixed a bug with own_winodw and double buffer
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@236 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
93d9e8c7b1
commit
7b33986b3c
@ -1,5 +1,9 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
|
2005-08-27
|
||||||
|
* added threaded execi, $texeci
|
||||||
|
* feature freeze
|
||||||
|
|
||||||
2005-08-26
|
2005-08-26
|
||||||
* Fixed slight vertical misalignment of bars/graphs (sf.net 1273994)
|
* Fixed slight vertical misalignment of bars/graphs (sf.net 1273994)
|
||||||
* Diskio fixes (sf.net 1274140)
|
* Diskio fixes (sf.net 1274140)
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<kdevautoproject>
|
<kdevautoproject>
|
||||||
<general>
|
<general>
|
||||||
<activetarget>conky</activetarget>
|
<activetarget>conky</activetarget>
|
||||||
<useconfiguration>debug</useconfiguration>
|
<useconfiguration>debug-no-x</useconfiguration>
|
||||||
</general>
|
</general>
|
||||||
<run>
|
<run>
|
||||||
<mainprogram>conky</mainprogram>
|
<mainprogram>conky</mainprogram>
|
||||||
@ -66,20 +66,20 @@
|
|||||||
</debug>
|
</debug>
|
||||||
<debug-no-x>
|
<debug-no-x>
|
||||||
<envvars/>
|
<envvars/>
|
||||||
<configargs>--enable-debug=full --prefix=/usr --enable-mpd --enable-xft --enable-seti --enable-double-buffer --enable-own-window --enable-metar --enable-mldonkey --disable-x11</configargs>
|
<configargs>--enable-debug=full --prefix=/usr --enable-mpd --enable-xft --enable-seti --enable-double-buffer --enable-own-window --enable-metar --enable-mldonkey --disable-x11 --without-x</configargs>
|
||||||
<builddir>debug-no-x</builddir>
|
<builddir>debug-no-x</builddir>
|
||||||
<topsourcedir/>
|
<topsourcedir></topsourcedir>
|
||||||
<cppflags/>
|
<cppflags></cppflags>
|
||||||
<ldflags/>
|
<ldflags></ldflags>
|
||||||
<ccompiler>kdevgccoptions</ccompiler>
|
<ccompiler>kdevgccoptions</ccompiler>
|
||||||
<cxxcompiler>kdevgppoptions</cxxcompiler>
|
<cxxcompiler>kdevgppoptions</cxxcompiler>
|
||||||
<f77compiler>kdevpgf77options</f77compiler>
|
<f77compiler>kdevpgf77options</f77compiler>
|
||||||
<ccompilerbinary/>
|
<ccompilerbinary></ccompilerbinary>
|
||||||
<cxxcompilerbinary/>
|
<cxxcompilerbinary></cxxcompilerbinary>
|
||||||
<f77compilerbinary/>
|
<f77compilerbinary></f77compilerbinary>
|
||||||
<cflags>-O2 -Wall -fexceptions -fomit-frame-pointer -fshort-enums -ggdb</cflags>
|
<cflags>-O2 -Wall -fexceptions -fomit-frame-pointer -fshort-enums -ggdb</cflags>
|
||||||
<cxxflags/>
|
<cxxflags></cxxflags>
|
||||||
<f77flags/>
|
<f77flags></f77flags>
|
||||||
</debug-no-x>
|
</debug-no-x>
|
||||||
</configurations>
|
</configurations>
|
||||||
<make>
|
<make>
|
||||||
|
@ -245,7 +245,7 @@
|
|||||||
<option>interval command</option>
|
<option>interval command</option>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
Same as exec but with specific interval. Interval can't be less than update_interval in configuration.
|
Same as exec but with specific interval. Interval can't be less than update_interval in configuration. See also $texeci
|
||||||
<para></para></listitem>
|
<para></para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
@ -921,6 +921,16 @@
|
|||||||
<para></para></listitem>
|
<para></para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<command><option>texeci</option></command>
|
||||||
|
<option>interval command</option>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
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 updating. 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 interval at least 6 seconds. See also $execi.
|
||||||
|
<para></para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<command><option>offset</option></command>
|
<command><option>offset</option></command>
|
||||||
|
87
src/conky.c
87
src/conky.c
@ -17,6 +17,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <pthread.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#if HAVE_DIRENT_H
|
#if HAVE_DIRENT_H
|
||||||
@ -725,6 +726,7 @@ enum text_object_type {
|
|||||||
OBJ_endif,
|
OBJ_endif,
|
||||||
OBJ_exec,
|
OBJ_exec,
|
||||||
OBJ_execi,
|
OBJ_execi,
|
||||||
|
OBJ_texeci,
|
||||||
OBJ_execbar,
|
OBJ_execbar,
|
||||||
OBJ_execgraph,
|
OBJ_execgraph,
|
||||||
OBJ_execibar,
|
OBJ_execibar,
|
||||||
@ -905,6 +907,27 @@ struct text_object {
|
|||||||
static unsigned int text_object_count;
|
static unsigned int text_object_count;
|
||||||
static struct text_object *text_objects;
|
static struct text_object *text_objects;
|
||||||
|
|
||||||
|
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
void *threaded_exec( struct text_object *obj ) {
|
||||||
|
char *p2 = obj->data.execi.buffer;
|
||||||
|
FILE *fp = popen(obj->data.execi.cmd,"r");
|
||||||
|
pthread_mutex_lock( &mutex1 );
|
||||||
|
int n2 = fread(p2, 1, TEXT_BUFFER_SIZE, fp);
|
||||||
|
(void) pclose(fp);
|
||||||
|
p2[n2] = '\0';
|
||||||
|
if (n2 && p2[n2 - 1] == '\n')
|
||||||
|
p2[n2 - 1] = '\0';
|
||||||
|
|
||||||
|
while (*p2) {
|
||||||
|
if (*p2 == '\001')
|
||||||
|
*p2 = ' ';
|
||||||
|
p2++;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock( &mutex1 );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* new_text_object() allocates a new zeroed text_object */
|
/* new_text_object() allocates a new zeroed text_object */
|
||||||
static struct text_object *new_text_object()
|
static struct text_object *new_text_object()
|
||||||
{
|
{
|
||||||
@ -975,6 +998,10 @@ static void free_text_objects()
|
|||||||
free(text_objects[i].data.execi.cmd);
|
free(text_objects[i].data.execi.cmd);
|
||||||
free(text_objects[i].data.execi.buffer);
|
free(text_objects[i].data.execi.buffer);
|
||||||
break;
|
break;
|
||||||
|
case OBJ_texeci:
|
||||||
|
free(text_objects[i].data.execi.cmd);
|
||||||
|
free(text_objects[i].data.execi.buffer);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1166,6 +1193,20 @@ if (s[0] == '#') {
|
|||||||
obj->data.execi.buffer =
|
obj->data.execi.buffer =
|
||||||
(char *) calloc(1, TEXT_BUFFER_SIZE);
|
(char *) calloc(1, TEXT_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
END OBJ(texeci, 0) unsigned int n;
|
||||||
|
|
||||||
|
if (!arg
|
||||||
|
|| sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
|
||||||
|
char buf[256];
|
||||||
|
ERR("${texeci <interval> command}");
|
||||||
|
obj->type = OBJ_text;
|
||||||
|
snprintf(buf, 256, "${%s}", s);
|
||||||
|
obj->data.s = strdup(buf);
|
||||||
|
} else {
|
||||||
|
obj->data.execi.cmd = strdup(arg + n);
|
||||||
|
obj->data.execi.buffer =
|
||||||
|
(char *) calloc(1, TEXT_BUFFER_SIZE);
|
||||||
|
}
|
||||||
END OBJ(pre_exec, 0) obj->type = OBJ_text;
|
END OBJ(pre_exec, 0) obj->type = OBJ_text;
|
||||||
if (arg) {
|
if (arg) {
|
||||||
FILE *fp = popen(arg, "r");
|
FILE *fp = popen(arg, "r");
|
||||||
@ -2205,6 +2246,25 @@ static void generate_text()
|
|||||||
current_update_time;
|
current_update_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
OBJ(texeci) {
|
||||||
|
static int running = 0;
|
||||||
|
if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
|
||||||
|
snprintf(p, n, "%s", obj->data.execi.buffer);
|
||||||
|
} else {
|
||||||
|
static pthread_t execthread;
|
||||||
|
if (!running) {
|
||||||
|
running = 1;
|
||||||
|
pthread_create( &execthread, NULL, (void*)threaded_exec, (void*) obj);
|
||||||
|
pthread_mutex_lock( &mutex1 );
|
||||||
|
obj->data.execi.last_update = current_update_time;
|
||||||
|
pthread_mutex_unlock( &mutex1 );
|
||||||
|
} else {
|
||||||
|
pthread_join( execthread, NULL);
|
||||||
|
running = 0;
|
||||||
|
}
|
||||||
|
snprintf(p, n, "%s", obj->data.execi.buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
OBJ(fs_bar) {
|
OBJ(fs_bar) {
|
||||||
if (obj->data.fs != NULL) {
|
if (obj->data.fs != NULL) {
|
||||||
@ -2931,8 +2991,9 @@ static void set_font()
|
|||||||
{
|
{
|
||||||
#ifdef XFT
|
#ifdef XFT
|
||||||
if (use_xft) {
|
if (use_xft) {
|
||||||
if (window.xftdraw != NULL)
|
if (window.xftdraw != NULL) {
|
||||||
XftDrawDestroy(window.xftdraw);
|
XftDrawDestroy(window.xftdraw);
|
||||||
|
}
|
||||||
window.xftdraw = XftDrawCreate(display, window.drawable,
|
window.xftdraw = XftDrawCreate(display, window.drawable,
|
||||||
DefaultVisual(display,
|
DefaultVisual(display,
|
||||||
screen),
|
screen),
|
||||||
@ -3196,12 +3257,14 @@ static void draw_string(const char *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef X11
|
||||||
if (text_width == maximum_width) {
|
if (text_width == maximum_width) {
|
||||||
/* this means the text is probably pushing the limit, so we'll chop it */
|
/* this means the text is probably pushing the limit, so we'll chop it */
|
||||||
while (cur_x + get_string_width(tmpstring2) - text_start_x > maximum_width && strlen(tmpstring2) > 0) {
|
while (cur_x + get_string_width(tmpstring2) - text_start_x > maximum_width && strlen(tmpstring2) > 0) {
|
||||||
tmpstring2[strlen(tmpstring2)-1] = '\0';
|
tmpstring2[strlen(tmpstring2)-1] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* X11 */
|
||||||
s = tmpstring2;
|
s = tmpstring2;
|
||||||
#ifdef X11
|
#ifdef X11
|
||||||
#ifdef XFT
|
#ifdef XFT
|
||||||
@ -3561,7 +3624,7 @@ static void draw_line(char *s)
|
|||||||
selected_font = specials[special_index].font_added;
|
selected_font = specials[special_index].font_added;
|
||||||
cur_y += font_ascent();
|
cur_y += font_ascent();
|
||||||
#ifdef XFT
|
#ifdef XFT
|
||||||
if (!use_xft)
|
if (!use_xft || use_xdbe)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
set_font();
|
set_font();
|
||||||
@ -3734,8 +3797,9 @@ static void draw_stuff()
|
|||||||
static void clear_text(int exposures)
|
static void clear_text(int exposures)
|
||||||
{
|
{
|
||||||
#ifdef XDBE
|
#ifdef XDBE
|
||||||
if (use_xdbe)
|
if (use_xdbe) {
|
||||||
return; /* The swap action is XdbeBackground, which clears */
|
return; /* The swap action is XdbeBackground, which clears */
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
/* there is some extra space for borders and outlines */
|
/* there is some extra space for borders and outlines */
|
||||||
XClearArea(display, window.drawable,
|
XClearArea(display, window.drawable,
|
||||||
@ -3885,13 +3949,13 @@ static void main_loop()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef OWN_WINDOW
|
#ifdef OWN_WINDOW
|
||||||
/*case ReparentNotify:
|
case ReparentNotify:
|
||||||
set background to ParentRelative for all parents
|
/* set background to ParentRelative for all parents */
|
||||||
if (own_window) {
|
if (own_window) {
|
||||||
set_transparent_background(window.
|
set_transparent_background(window.
|
||||||
window);
|
window);
|
||||||
}
|
}
|
||||||
break;*/
|
break;
|
||||||
|
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
if (own_window) {
|
if (own_window) {
|
||||||
@ -3975,8 +4039,9 @@ static void main_loop()
|
|||||||
#endif
|
#endif
|
||||||
XSetRegion(display, window.gc, region);
|
XSetRegion(display, window.gc, region);
|
||||||
#ifdef XFT
|
#ifdef XFT
|
||||||
if (use_xft)
|
if (use_xft) {
|
||||||
XftDrawSetClip(window.xftdraw, region);
|
XftDrawSetClip(window.xftdraw, region);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* X11 */
|
#endif /* X11 */
|
||||||
draw_stuff();
|
draw_stuff();
|
||||||
@ -3984,14 +4049,9 @@ static void main_loop()
|
|||||||
XDestroyRegion(region);
|
XDestroyRegion(region);
|
||||||
region = XCreateRegion();
|
region = XCreateRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* X11 */
|
#endif /* X11 */
|
||||||
|
|
||||||
}
|
}
|
||||||
#ifdef X11
|
|
||||||
XDestroyRegion(region);
|
|
||||||
#endif /* X11 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void load_config_file(const char *);
|
static void load_config_file(const char *);
|
||||||
@ -4019,8 +4079,9 @@ static void clean_up()
|
|||||||
{
|
{
|
||||||
#ifdef X11
|
#ifdef X11
|
||||||
#ifdef XDBE
|
#ifdef XDBE
|
||||||
if (use_xdbe)
|
if (use_xdbe) {
|
||||||
XdbeDeallocateBackBufferName(display, window.back_buffer);
|
XdbeDeallocateBackBufferName(display, window.back_buffer);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef OWN_WINDOW
|
#ifdef OWN_WINDOW
|
||||||
if (own_window)
|
if (own_window)
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef X11
|
||||||
|
|
||||||
#include "conky.h"
|
#include "conky.h"
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
@ -366,3 +368,5 @@ void create_gc()
|
|||||||
window.gc = XCreateGC(display, window.drawable,
|
window.gc = XCreateGC(display, window.drawable,
|
||||||
GCFunction | GCGraphicsExposures, &values);
|
GCFunction | GCGraphicsExposures, &values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* X11 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user