You are not logged in.

#1 2013-01-18 02:26:19

syamajala
Member
From: here, there, everywhere
Registered: 2005-01-25
Posts: 604
Website

rss reader for systray

Started working on a little project. An rss reader that sits in the systray. Its pretty bare right now, but its downloading feeds and opens them in the browser when i click on them.

http://i.imgur.com/ldvS3.jpg


-- mod edit: read the Forum Etiquette and only post thumbnails http://wiki.archlinux.org/index.php/For … s_and_Code [jwr] --

Offline

#2 2013-01-18 02:36:28

Hspasta
Member
Registered: 2011-12-24
Posts: 187
Website

Re: rss reader for systray

Is your code hosted somewhere? i.e github, bitbucket, etc.

Offline

#3 2013-01-18 03:10:26

syamajala
Member
From: here, there, everywhere
Registered: 2005-01-25
Posts: 604
Website

Re: rss reader for systray

i uploaded it to github just now, https://github.com/syamajala/rsstray the code is very rough. i don't know gtk at all, so i've just been taking code from random examples i find online. i used to use this app on os x and couldn't find anything like it on linux, http://www.macupdate.com/app/mac/17216/rss-menu

Offline

#4 2013-01-18 04:32:20

Onyros
Member
From: Lisbon, Portugal
Registered: 2007-10-11
Posts: 294

Re: rss reader for systray

Pretty cool, I like it.

Now you just have to add a way for it to read a list of feeds from file (and generate menu items and submenus for each one) and it's a great start wink

taDRicw

Last edited by Onyros (2013-01-18 04:42:01)

Offline

#5 2013-01-18 08:06:07

syamajala
Member
From: here, there, everywhere
Registered: 2005-01-25
Posts: 604
Website

Re: rss reader for systray

im working on having it update feeds every however many minutes and hopefully show a little pop up using libnotify. it should be able to handle multiple feeds then. also i didn't notice this before but there seems to be a bug, when you click on a specific article it opens the page for the last article it added to the submenu. guess i don't completely understand how connect works.

Offline

#6 2013-01-18 10:37:11

Onyros
Member
From: Lisbon, Portugal
Registered: 2007-10-11
Posts: 294

Re: rss reader for systray

Keep digging! I love the idea of having a systray RSS reader like this. Sorry I can't help in any way, as I'm absolutely code blind...

Offline

#7 2013-01-18 11:33:35

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: rss reader for systray

Fixed that bug, kind of, i'm not sure if it's the proper solution, but it seems to work. Relevant code:

    def build_submenu(self, feed):
        menu = Gtk.Menu()

        for i in feed.entries:
            menuitem = Gtk.MenuItem()
            menuitem.set_label(i.title)
            menuitem.connect("activate", self.construct_command(i.link))
            menu.append(menuitem)

        return menu
        
    def construct_command(self, link):
        def open_link(self):
            webbrowser.open(link)
        return open_link

Lambda expression inside a loop seems to overwrite itself during every iteration, like here:

l = []
for i in range(10):
    l.append(id(lambda x: x*i))
print(l)
# OUT: [139721358186400, 139721358186400, 139721358186400, 139721358186400, 139721358186400, 139721358186400, 139721358186400, 139721358186400, 139721358186400, 139721358186400]
print(l.count(l[0]))
# OUT: 10

As you can see, id of the lambda expression is the same in every iteration, despite being a different function (i is different in each lambda), so when the for loop finishes, you'll end up with only one callable object, that every menu item executes on activation.

EDIT:
After a bit of screwing around, i found that this also works:

menuitem.link = i.link
menuitem.connect("activate", lambda x: webbrowser.open(x.link))

Instead of passing the arbitrary address to the lambda it just extracts link from the menu entry itself.

Last edited by kaszak696 (2013-01-18 16:02:15)


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#8 2013-01-18 17:59:20

syamajala
Member
From: here, there, everywhere
Registered: 2005-01-25
Posts: 604
Website

Re: rss reader for systray

thanks for that!

i made a bit of progress. its updating feeds every x seconds and printing notifications using libnotify when it does the updates. still need to fix a few things though. right now it makes a whole new submenu for each feed when it does the update so feeds appear multiple times. the quit button also isn't working because of the threading stuff i needed to have it do the updates. also, its doing multiple feeds now.

Offline

#9 2013-01-18 18:07:26

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: rss reader for systray

If the threads don't have to exit cleanly, you can make them daemons. This way, when the main event loop exits, daemon threads are killed automatically.


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#10 2013-01-18 20:28:42

syamajala
Member
From: here, there, everywhere
Registered: 2005-01-25
Posts: 604
Website

Re: rss reader for systray

got all that stuff working and did a push. it would be nice if when it did updates, it kept track of which articles in a feed are new. also, which articles have already been read and which haven't.

Offline

#11 2013-01-19 01:27:24

Onyros
Member
From: Lisbon, Portugal
Registered: 2007-10-11
Posts: 294

Re: rss reader for systray

Aaah, I knew I had tried something similar to this some time ago...

AvalonRSSNotify - you can grab some ideas from here and expand a little on it: keep it simple, keep it classy tongue

In my view, notifications should be optional. Some people, like myself, don't run a notification daemon and would rather just have it sit on the systray. A change in colour whenever there are new items to read would be more than enough for me. And for those who want fancy notifications... just enable them. Also, being able to choose the browser is also a good one.

Offline

#12 2013-01-19 08:40:23

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: rss reader for systray

Onyros wrote:

Also, being able to choose the browser is also a good one.

Technically, you can. Webbrowser module uses xdg-open on Linux to detect default browser, so you just have to change xdg-open settings to pick a different one.


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#13 2013-01-20 22:09:37

Onyros
Member
From: Lisbon, Portugal
Registered: 2007-10-11
Posts: 294

Re: rss reader for systray

Yup, I know. I meant within the application itself. I may not want to open links for the rss reader on my default browser (I actually don't, really). You can also register browsers which are not by default registered on the module. Python2 still didn't have Chromium/Chrome but it's pretty simple to register.

Offline

Board footer

Powered by FluxBB