Workaround for the problem that $goto only moves the first rss-item by making
authorNikolas Garofil <garo@dunaldi.garofil.be>
Sat, 18 Apr 2009 22:42:01 +0000 (00:42 +0200)
committerNikolas Garofil <garo@dunaldi.garofil.be>
Sat, 18 Apr 2009 22:42:01 +0000 (00:42 +0200)
it possible to specify the number of spaces you want in front of each rss-item

ChangeLog
doc/conky.1
doc/variables.xml
src/conky.c
src/text_object.h

index d3d2c7e..d90afef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-04-19
+       * Make it possible to place spaces in front of RSS-items as a workaround
+       for the problem that $goto only moves the first RSS-item. This is only a
+       workaround and should be replaced by a permanent fix that makes $goto move
+       all RSS-items !
+
 2009-04-13
        * Fix broken compilation without X11
 
index 29b01e4..870cb60 100644 (file)
@@ -1416,8 +1416,8 @@ Runs a command at an interval inside a thread and displays the output. Same as $
 Move text over by N pixels. See also $voffset.
 
 .TP 
-\fB\*(T<\fBrss\fR\*(T>\fR \*(T<\fBurl delay_in_minutes action item_num\fR\*(T> 
-Download and parse RSS feeds. Action may be one of the following: feed_title, item_title (with num par), item_desc (with num par) and item_titles.
+\fB\*(T<\fBrss\fR\*(T>\fR \*(T<\fBurl delay_in_minutes action (num_par (spaces_in_front))\fR\*(T> 
+Download and parse RSS feeds. Action may be one of the following: feed_title, item_title (with num par), item_desc (with num par) and item_titles (when using this action and spaces_in_front is given conky places that many spaces in front of each item).
 
 .TP 
 \fB\*(T<\fBtab\fR\*(T>\fR \*(T<\fB(width, (start))\fR\*(T> 
index 14204e3..f5d5ab9 100644 (file)
        <varlistentry>
                <term>
                        <command><option>rss</option></command>
-                       <option>url delay_in_minutes action item_num</option>
+                       <option>url delay_in_minutes action (num_par (spaces_in_front))</option>
                </term>
                <listitem>
-                       Download and parse RSS feeds. Action may be one of the following: feed_title, item_title (with num par), item_desc (with num par) and item_titles.
+                       Download and parse RSS feeds. Action may be one of the following: feed_title, item_title (with num par), item_desc (with num par) and item_titles (when using this action and spaces_in_front is given conky places that many spaces in front of each item).
                        <para></para></listitem>
        </varlistentry>
 
index c9b084f..5ea77a5 100644 (file)
@@ -2475,20 +2475,22 @@ static struct text_object *construct_text_object(const char *s,
        END OBJ(rss, 0)
                if (arg) {
                        int argc, delay, act_par;
+                       unsigned int nrspaces = 0;
                        char *uri = (char *) malloc(128 * sizeof(char));
                        char *action = (char *) malloc(64 * sizeof(char));
 
-                       argc = sscanf(arg, "%127s %d %63s %d", uri, &delay, action,
-                                       &act_par);
+                       argc = sscanf(arg, "%127s %d %63s %d %u", uri, &delay, action,
+                                       &act_par, &nrspaces);
                        obj->data.rss.uri = uri;
                        obj->data.rss.delay = delay;
                        obj->data.rss.action = action;
                        obj->data.rss.act_par = act_par;
+                       obj->data.rss.nrspaces = nrspaces;
 
                        init_rss_info();
                } else {
                        CRIT_ERR("rss needs arguments: <uri> <delay in minutes> <action> "
-                                       "[act_par]");
+                                       "[act_par] [spaces in front]");
                }
 #endif
 #ifdef HDDTEMP
@@ -3890,6 +3892,10 @@ static void generate_text_internal(char *p, int p_max_size,
                                                if (data->item_count > 0) {
                                                        int itmp;
                                                        int show;
+                                                       //'tmpspaces' is a string with spaces too be placed in front of each title
+                                                       char *tmpspaces = malloc(obj->data.rss.nrspaces + 1);
+                                                       memset(tmpspaces, ' ', obj->data.rss.nrspaces);
+                                                       tmpspaces[obj->data.rss.nrspaces]=0;
 
                                                        p[0] = 0;
 
@@ -3912,9 +3918,11 @@ static void generate_text_internal(char *p, int p_max_size,
                                                                        if (str[strlen(str) - 1] == '\n') {
                                                                                str[strlen(str) - 1] = 0;
                                                                        }
+                                                                       strncat(p, tmpspaces, p_max_size);
                                                                        strncat(p, str, p_max_size);
                                                                }
                                                        }
+                                                       free(tmpspaces);
                                                }
                                        }
                                }
index 1d769e7..e36b31c 100644 (file)
@@ -482,6 +482,7 @@ struct text_object {
                        char *action;
                        int act_par;
                        int delay;
+                       unsigned int nrspaces;
                } rss;
 #endif
                struct {