diff options
author | Erich Eckner <git@eckner.net> | 2017-02-16 10:45:04 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2017-02-16 10:45:04 +0100 |
commit | ef9b4497d719b5f387dbe81b494940cc2426c3df (patch) | |
tree | e6397894f2566e6435befaf68987da8db6785885 /conky/irc_lines.patch | |
parent | 89617cbd1fa25607f37374f16cbf15de17d23f8d (diff) | |
download | archlinuxewe.git.save-ef9b4497d719b5f387dbe81b494940cc2426c3df.tar.xz |
conky mit irc neu
Diffstat (limited to 'conky/irc_lines.patch')
-rw-r--r-- | conky/irc_lines.patch | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/conky/irc_lines.patch b/conky/irc_lines.patch new file mode 100644 index 00000000..d7ed7d3a --- /dev/null +++ b/conky/irc_lines.patch @@ -0,0 +1,102 @@ +diff --git a/doc/variables.xml b/doc/variables.xml +index effc5880..f07ef893 100644 +--- a/doc/variables.xml ++++ b/doc/variables.xml +@@ -1756,11 +1756,12 @@ + <command> + <option>irc</option> + </command> +- <option>server(:port) #channel</option> ++ <option>server(:port) #channel (max_msg_lines)</option> + </term> + <listitem>Shows everything that's being told in #channel on IRCserver + 'server'. TCP-port 6667 is used for the connection unless 'port' is +- specified. ++ specified. Shows everything since the last time or the last ++ 'max_msg_lines' entries if specified. + <para /></listitem> + </varlistentry> + <varlistentry> +diff --git a/src/irc.cc b/src/irc.cc +index 17b81d73..ad5cb846 100644 +@@ -44,6 +44,7 @@ struct obj_irc { + + struct ctx { + char *chan; ++ int max_msg_lines; + struct ll_text *messages; + }; + +@@ -69,6 +70,22 @@ void addmessage(struct ctx *ctxptr, char *nick, const char *text) { + } + lastmsg->next = newmsg; + } ++ if(ctxptr->max_msg_lines>0) { ++ int msgcnt = 0; ++ newmsg = ctxptr->messages; ++ while(newmsg) { ++ newmsg = newmsg->next; ++ msgcnt++; ++ } ++ msgcnt -= ctxptr->max_msg_lines; ++ while(msgcnt>0) { ++ msgcnt--; ++ newmsg = ctxptr->messages->next; ++ free(ctxptr->messages->text); ++ free(ctxptr->messages); ++ ctxptr->messages = newmsg; ++ } ++ } + } + + void ev_talkinchan(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count) { +@@ -95,7 +112,7 @@ void ev_num(irc_session_t *session, unsigned int event, const char *origin, cons + if(origin || count) {} //fix gcc warnings + } + +-#define IRCSYNTAX "The correct syntax is ${irc server(:port) #channel}" ++#define IRCSYNTAX "The correct syntax is ${irc server(:port) #channel (max_msg_lines)}" + #define IRCPORT 6667 + #define IRCNICK "conky" + #define IRCSERVERPASS NULL +@@ -108,6 +125,7 @@ void *ircclient(void *ptr) { + irc_callbacks_t callbacks; + char *server; + char *strport; ++ char *str_max_msg_lines; + unsigned int port; + + memset (&callbacks, 0, sizeof(callbacks)); +@@ -120,6 +138,10 @@ void *ircclient(void *ptr) { + if( ! ctxptr->chan) { + NORM_ERR("irc: %s", IRCSYNTAX); + } ++ str_max_msg_lines = strtok(NULL, " "); ++ if(str_max_msg_lines) { ++ ctxptr->max_msg_lines = strtol(str_max_msg_lines, NULL, 10); ++ } + ctxptr->messages = NULL; + irc_set_ctx(ircobj->session, ctxptr); + server = strtok(server, ":"); +@@ -169,14 +191,18 @@ void print_irc(struct text_object *obj, char *p, int p_max_size) { + while(curmsg) { + nextmsg = curmsg->next; + strncat(p, curmsg->text, p_max_size - strlen(p) - 1); +- free(curmsg->text); +- free(curmsg); ++ if(!ctxptr->max_msg_lines) { ++ free(curmsg->text); ++ free(curmsg); ++ } + curmsg = nextmsg; + } + if(p[0] != 0) { + p[strlen(p) - 1] = 0; + } +- ctxptr->messages = NULL; ++ if(!ctxptr->max_msg_lines) { ++ ctxptr->messages = NULL; ++ } + } + + void free_irc(struct text_object *obj) { |