You are not logged in.

#1 2010-06-15 21:28:52

Cookie
Member
Registered: 2008-03-08
Posts: 119

Conky rss title length

Hi all,

I'm trying to make conky to show my  rss feeds horizontally at the bottom of the screen 2 titles each, however some of the titles so long that they get over lapped with other feed titles. I tried googling and searching on forums for possible solution but came up with nothing. hmm

So is there a way to limit  the title length ?

Thanks in advance

#avoid flicker
double_buffer yes
background no

#own window to run simultanious 2 or more conkys
#on_bottom yes
own_window  yes
own_window_transparent yes
own_window_type override
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

#borders
draw_borders no
border_outer_margin 0

#shades
draw_shades no

#position
gap_x 8
gap_y 29
alignment bottom_right
#behaviour
update_interval 2

#colour
default_color ffffff
color2 D8476A
color3 929292

#default_shade_color 000000
own_window_colour 000000

#font
use_xft yes
xftfont PF Tempesta Five Condensed:pixelsize=10

#to prevent window from moving
use_spacer none

TEXT
${image ~/.conky/background.png -p 188,2}

${offset 330}${voffset -25}Slashdot
${offset 205}${voffset 2}${color FF7700}${rss http://rss.slashdot.org/Slashdot/slashdot 10 item_title 0}
${offset 205}${rss http://rss.slashdot.org/Slashdot/slashdot 10 item_title 1}${color}${font}

${offset 500}${voffset -63}Engadget
${offset 500}${voffset 2}${color FF7700}${rss www.engadget.com/rss.xml 10 item_title 0}
${offset 500}${rss www.engadget.com/rss.xml 10 item_title 1}${color}${font}

${offset 900}${voffset -62}Guardian.co.uk
${offset 900}${voffset 2}${color FF7700}${rss http://feeds.guardian.co.uk/theguardian/rss 10 item_title 0}
${offset 900}${rss http://feeds.guardian.co.uk/theguardian/rss 10 item_title 1}${color}${font}

${offset 1150}${voffset -62}BBC News | UK
${offset 1150}${voffset 4}${color FF7700}${rss http://newsrss.bbc.co.uk/rss/newsplayer_uk_edition/uk/rss.xml 10 item_title 0}
${offset 1150}${rss http://newsrss.bbc.co.uk/rss/newsplayer_uk_edition/uk/rss.xml 10 item_title 1}${color}${font}

${offset 1370}${voffset -64}BBC News | World
${offset 1370}${voffset 4}${color FF7700}${rss http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml 10 item_title 0}
${offset 1370}${rss http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml 10 item_title 1}${color}${font}

Linux nabcake in training...
ArchLinux64

Offline

#2 2010-06-16 09:38:17

quigybo
Member
Registered: 2009-01-15
Posts: 223

Re: Conky rss title length

I can't help you with the conky rss object, but I have always written my own parsers to go with conky. Something using curl and xsltproc (part of libxslt in [extra]) and maybe a bit of sed to clean it up works well. I run it as a separate script and send the output to a text file that conky reads in, as this way you still get something on screen without a network connection. The script can be run either separately with cron or in conky with texeci.

Offline

#3 2010-06-16 10:52:40

Cookie
Member
Registered: 2008-03-08
Posts: 119

Re: Conky rss title length

I know nothing about script writing / programming but I'll give it a go. Thanks smile


Linux nabcake in training...
ArchLinux64

Offline

#4 2010-06-16 11:43:35

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: Conky rss title length

There's a little program called pixel_truncate.c on the dzen website that hopefully does what you want:

/* gcc length.c -lX11 -lXft `pkg-config --cflags xft` */

#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xft/Xft.h>

int main (int argc, char **argv)
{
    int screen, len, pixels;
    char *string, *sep = "...";
    Display *dpy;
    XftFont *font;
    XGlyphInfo extents;

    if (argc < 5) {
        printf ("Usage: %s <font> <size> <string> <pixels>\n", argv[0]);
        return 1;
    }

    pixels = atoi (argv[4]);
    len = strlen (argv[3]);

    dpy = XOpenDisplay (NULL);
    screen = XDefaultScreen (dpy);
    font = XftFontOpen (dpy, screen,
                        XFT_FAMILY, XftTypeString, argv[1],
                        XFT_SIZE, XftTypeDouble, atof (argv[2]),
                        NULL);
    XftTextExtents8 (dpy, font, (FcChar8 *)argv[3], len, &extents);

    if (extents.xOff <= pixels) {
        printf ("%s", argv[3]);
    } else {
        string = malloc ((sizeof (char) * len) + 3);
        strcpy (string, argv[3]);
        do {
            len--;
            memcpy (string + len, sep, strlen (sep) + 1);
            XftTextExtents8 (dpy, font, (FcChar8 *)string,
                             strlen (string), &extents);
        } while (extents.xOff > pixels);
        printf ("%s", string);
        free (string);
    }

    return 0;
}

Offline

#5 2010-06-16 11:44:24

quigybo
Member
Registered: 2009-01-15
Posts: 223

Re: Conky rss title length

Good stuff, best of luck to you. Just remember to do plenty of googling, read the man pages and have fun. Post up the results and I'm sure we will be able to help you out. Some of my first scripting was conky-related too tongue.

Offline

#6 2010-06-16 11:53:45

Cookie
Member
Registered: 2008-03-08
Posts: 119

Re: Conky rss title length

thanks guys smile I'll try it later on today big_smile


Linux nabcake in training...
ArchLinux64

Offline

Board footer

Powered by FluxBB