Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Status
Not open for further replies.
Create todo list from evernote using rss and displaying with geektool.

I am trying to create a todo list based out of Evernote with the RSS feature to display on my desktop with geektool.

Fairly new to geektool, but loving it. I also use evernote a lot. I created a new notebook inside evernote and was able to get an RSS for the feed. I have been able to get geektool to read and display the feed but I am having a hard time getting it to parse the text correctly.

My bash file is based on news.sh but I need to change the sed commands for it to display correctly. I have included the code below.

Any help on where I might be able to get some direction on how to construct my sed commands would be extremely helpful.

Code:
#!/bin/sh

URL="http://www.evernote.com/shard/s41/pub/4362876/......./todo/rss.jsp?max=25&sort=2&search="

if [ $# -eq 1 ] ; then
  headarg=$(( $1 * 2 ))
else
  headarg="-8"
fi

curl --silent "$URL" | grep -E '(title>|description>)' | \
  sed -n '4,$p' | \
  sed -e 's/<title>//' -e 's/<\/title>//' -e 's/<description>/   /' \
      -e 's/<\/description>//' | \
  sed -e 's/<!\[CDATA\[//g' |            
  sed -e 's/\]\]>//g' |     
     
  sed -e 's/<[^>]*>//g' |      
  head $headarg | sed G | fmt
2010-11-02_1_23_27_AM.png
 
About to pull my hair out

Can someone post the script for the yahoo weather code for Vancouver, B.C. Canada

I have tried inputting just the last 4 numerals but it won't take. I used the code for Toronto which had CA in front the numerals that was posted way back in this thread and that showed up on the desktop but the moment I tried deleting that code and putting in the vancouver one all I get is a blank box.. please help
 
Can someone post the script for the yahoo weather code for Vancouver, B.C. Canada

I have tried inputting just the last 4 numerals but it won't take. I used the code for Toronto which had CA in front the numerals that was posted way back in this thread and that showed up on the desktop but the moment I tried deleting that code and putting in the vancouver one all I get is a blank box.. please help


Here is the web addresses for Yahoo weather for Vancouver BC...

For Celsius

Code:
http://xml.weather.yahoo.com/forecastrss?p=CAXX0518&u=c

For Fahrenheit

Code:
http://xml.weather.yahoo.com/forecastrss?p=CAXX0518&u=f
 
Here is the web addresses for Yahoo weather for Vancouver BC...

For Celsius

Code:
http://xml.weather.yahoo.com/forecastrss?p=CAXX0518&u=c

For Fahrenheit

Code:
http://xml.weather.yahoo.com/forecastrss?p=CAXX0518&u=f

Thanks sooo very much... this is a perfect
 
I am trying to create a todo list based out of Evernote with the RSS feature to display on my desktop with geektool.

Fairly new to geektool, but loving it. I also use evernote a lot. I created a new notebook inside evernote and was able to get an RSS for the feed. I have been able to get geektool to read and display the feed but I am having a hard time getting it to parse the text correctly.

My bash file is based on news.sh but I need to change the sed commands for it to display correctly. I have included the code below.

Any help on where I might be able to get some direction on how to construct my sed commands would be extremely helpful.

Code:
#!/bin/sh

URL="http://www.evernote.com/shard/s41/pub/4362876/......./todo/rss.jsp?max=25&sort=2&search="

if [ $# -eq 1 ] ; then
  headarg=$(( $1 * 2 ))
else
  headarg="-8"
fi

curl --silent "$URL" | grep -E '(title>|description>)' | \
  sed -n '4,$p' | \
  sed -e 's/<title>//' -e 's/<\/title>//' -e 's/<description>/   /' \
      -e 's/<\/description>//' | \
  sed -e 's/<!\[CDATA\[//g' |            
  sed -e 's/\]\]>//g' |     
     
  sed -e 's/<[^>]*>//g' |      
  head $headarg | sed G | fmt
2010-11-02_1_23_27_AM.png

A python script that can accurately parse the xml without requiring regular expressions is what you need. The xml.dom.minidom library can do just that. Reference my post above for the Twylights myepisode rss feed parser. If you know the xml structure it shouldn't be too hard.

If you provide a raw xml dump of the feed, I could possibly make a parser quick for you.
 
A python script that can accurately parse the xml without requiring regular expressions is what you need. The xml.dom.minidom library can do just that. Reference my post above for the Twylights myepisode rss feed parser. If you know the xml structure it shouldn't be too hard.

If you provide a raw xml dump of the feed, I could possibly make a parser quick for you.

Writing a pyton script might be a little beyond me... Here is the link for the feed. Thanks a ton.

http://www.evernote.com/shard/s41/pub/4362876/robfrye/todo/rss.jsp?max=25&sort=2&search=
 
Writing a pyton script might be a little beyond me... Here is the link for the feed. Thanks a ton.

http://www.evernote.com/shard/s41/pub/4362876/robfrye/todo/rss.jsp?max=25&sort=2&search=

Here's the Evernote feed script. Save the code as evernote_feedgrabber.py and in the command line chmod +x the file to make it executable.
Code:
#!/usr/bin/env python

# MODULE IMPORTS
import xml.dom.minidom
import re

# CLASS TO HOLD THE DATA FOR A TO DO GROUP
class toDo():
    def __init__(self):
        self.groupname = ""
        self.link = ""
        self.pubdate = ""
        self.tasklist = []

# GET THE FEED - UPDATE TO CMD LINE ARGUMENT
# BE SURE TO HAVE THE URL REDIRECT THE URL FROM THE COMMAND LINE WITH 
# THE FOLLOWING COMMAND
# curl --silent "url goes here in quotations or else it won't work" > /tmp/evernote_feed.xml
dom = xml.dom.minidom.parse("/tmp/evernote_feed.xml")

# LIST TO HOLD ALL THE TASKS (toDo CLASS)
tasks = []

# INLINE FUNCTIONS - DON'T FEEL LIKE CLASSING THIS UP
def getText(nodelist):
    rc = []
    for node in nodelist:
        if node.nodeType == node.TEXT_NODE:
            rc.append(node.data)
    return ''.join(rc)

def handleFeed(feed,tasks):
    items = feed.getElementsByTagName("item")
    handleSubjects(items,tasks)

def handleSubjects(items,tasks):
    for item in items:
        # CREATE TEMPORARY TODO
        tmpToDo = toDo()
        # GET THE DATA FROM THE CURRENT ITEM
        title = item.getElementsByTagName("title")[0]
        link = item.getElementsByTagName("link")[0]
        pubdate = item.getElementsByTagName("pubDate")[0]
        # DESCRIPTION IS DIFFERENT DUE TO THE CDATA IN THE XML
        desc = item.getElementsByTagName("description")[0].firstChild.data.strip()
        # GET THE TITLE FROM THE TITLE TAG
        titleText = getText(title.childNodes)
        # GET THE LINK FROM THE LINK TAG
        linkText = getText(link.childNodes)
        # GET THE PUB DATE FROM THE PUBDATE TAG
        pubDText = getText(pubdate.childNodes)
        # SET UP TITLE, LINK, AND PUBDATE IN THE TMP TODO VARIABLE
        tmpToDo.groupname = titleText
        tmpToDo.link = linkText
        tmpToDo.pubdate = pubDText
        # REGULAR EXPRESSIONS TO REMOVE THE <div class="ennote">, <div>, and </div> TAGS  
        # AND REPLACE WITH APPROPRIATE VALUES TO GET A COMMA DELIMITED LIST
        descCopy = desc
        tmp = re.sub('\n',",",descCopy)
        tmp = re.sub('<div class="ennote">',"",tmp)
        # REMOVE THE DOUBLE </div> TAGS, ACCOUNT FOR BOTH POSSIBILITIES EVEN THOUGH THE FIRST
        # RE WILL REMOVE THE RETURN LINES
        tmp = re.sub("</div>,</div>",",",tmp)
        tmp = re.sub("</div></div>","",tmp)
        # REMOVE THE LEADING <div> TAGS
        tmp = re.sub("<div>","",tmp)
        # REMOVE THE SINGLE </div> AND REPLACE WITH THE COMMAS
        tmp = re.sub("</div>,",",",tmp)
        # MAKE tmp A LIST
        tmp = tmp.split(',')
        # SET THE LIST TO THE LIST IN TEMP TODO
        tmpToDo.tasklist = tmp
        # APPEND TMP TODO TO TASKS
        tasks.append(tmpToDo)
        
# HANDLE THE XML
handleFeed(dom,tasks)

# PRINT OUT THE TASKS
# THIS IS CUSTOMIZABLE
for i in range(len(tasks)):
    # PRINT OUT TASK GROUP
    print tasks[i].groupname
    # PRINT OUT TASK PUB DATE
    #print "|- Updated: ", tasks[i].pubdate
    # PRINT OUT TASK LINK
    #print "|- Link: ", tasks[i].link
    # PRINT OUT ACTUAL TASKS
    for j in range(len(tasks[i].tasklist)):
        d2print = tasks[i].tasklist[j]
        if d2print != "":
            print "|-", d2print

For Geektool, use the following commands (make sure the rss feed url is contained between the quotes):
Code:
curl --silent "your evernote rss feed here" > /tmp/evernote_feed.xml;
python /path/to/your/script/evernote_feedgrabber.py

I decided to move away from my /tmp/geektool directory as the geektool folder in /tmp is removed occasionally on power cycles of the computer. /tmp is always there, so there is no worry that the data won't show up.
The section of code that prints the data out is customizable and it set to output the data as follows:
Code:
Task group 1
|- task 1
|- task 2
Task group 2
|- task 1

The XML feed was a little off, but I think I was able to take care of every possible outcome of the data contained in the description tags. Let me know if it doesn't work.
 
Last edited:
So Dunkm1n asked in this thread about a digg news feed reader for geektool.

I got bored and made one, here it is for everybody to use (all these readers are based off the same code, it's really trivial to get the info you need from Python).

Save the code as digg_news_grabber.py and chmod +x the file.
Code:
#!/usr/bin/env python

# MODULE IMPORTS
import xml.dom.minidom
import re

# CLASS TO HOLD THE DATA FOR A TO DO GROUP
class diggNewsItem():
    def __init__(self):
        self.title = ""
        self.link = ""
        self.desc = ""
        self.pubdate = ""
        self.dcount = ""
        self.dcategory = ""

# GET THE FEED - UPDATE TO CMD LINE ARGUMENT
# BE SURE TO HAVE THE URL REDIRECT THE URL FROM THE COMMAND LINE WITH 
# THE FOLLOWING COMMAND
# curl --silent "url goes here in quotations or else it won't work" > /tmp/digg_news_feed.xml
dom = xml.dom.minidom.parse("/tmp/digg_news_feed.xml")

# LIST TO HOLD ALL THE TASKS (toDo CLASS)
diggNews = []

# INLINE FUNCTIONS - DON'T FEEL LIKE CLASSING THIS UP
def getText(nodelist):
    rc = []
    for node in nodelist:
        if node.nodeType == node.TEXT_NODE:
            rc.append(node.data)
    return ''.join(rc)

def handleFeed(feed,diggNews):
    items = feed.getElementsByTagName("item")
    handleNewsItem(items,diggNews)

def handleNewsItem(items,diggNews):
    for item in items:
        # CREATE TEMPORARY TODO
        tmpCls = diggNewsItem()
        # GET THE DATA FROM THE CURRENT ITEM
        title = item.getElementsByTagName("title")[0]
        link = item.getElementsByTagName("link")[0]
        pubdate = item.getElementsByTagName("pubDate")[0]
        desc = item.getElementsByTagName("description")[0]
        dcount = item.getElementsByTagName("digg:diggCount")[0]
        dcat = item.getElementsByTagName("digg:category")[0]
        # GET THE VALUES FROM THE TAGS
        tmpCls.title = getText(title.childNodes).strip()
        tmpCls.link = getText(link.childNodes).strip()
        tmpCls.desc = getText(desc.childNodes).strip()
        tmpCls.pubdate = getText(pubdate.childNodes).strip()
        tmpCls.dcount = getText(dcount.childNodes).strip()
        tmpCls.dcategory = getText(dcat.childNodes).strip()
        # APPEND TEMP DIGG NEWS CLASS TO DIGG NEWS LIST
        diggNews.append(tmpCls)
        
# HANDLE THE XML
handleFeed(dom,diggNews)

# PRINT OUT THE TASKS
# THIS IS CUSTOMIZABLE
for i in range(len(diggNews)):
    # PRINT OUT THE DATA HOWEVER YOU WANT
    # DATA STORED IN EACH diggNews SEGMENT
    # diggNews[i].title   = TITLE OF THE NEWS ITEM
    # diggNews[i].desc    = DESCRIPTION OF THE NEWS ITEM
    # diggNews[i].link    = NEWS ITEM LINK
    # diggNews[i].pubdate = DATE THE NEWS ITEM WAS PUBLISHED
    # diggNews[i].dcount  = NUMBER OF DIGG COUNTS
    # diggNews[i].dcat    = CATEGORY
    # CURRENTLY SET TO PRINT THE DIGG COUNT AND THEN THE TITLE
    print "(" + diggNews[i].dcount + ") " + diggNews[i].title

For Geektool, use the following commands. Dunkm1n wanted the top news, but if you have a digg account, you could probably pull one of your feeds through, just place it between the quotes in the curl statement.
Code:
curl --silent "http://services.digg.com/2.0/story.getTopNews?type=rss" > /tmp/digg_news_feed.xml;
python /path/to/your/script/digg_news_grabber.py

Output is customizable (available variables are detailed in the script), I pulled the important information from the XML. The default output is as follows:
Code:
(103) How Science Saved My Soul [Video]
(103) 8 Great Laptops With WiMAX 4G
(102) What Are Capital Gains? (Graphic)
(106) Pervert Paid Pack of 12y/o Girls Thousands of Dollars to Fulfill His Sexual Wish List
(115) In Case You Still Don’t Understand What Happened November 2
(101) Facebook fan numbers accurately predict 81% of midterm election results
(116) It's time you wear brown ribons [Pic]
(134) Men Are So Under Appreciated (Pic)
(111) Exactly what kind of people watch Leno, Conan, and Letterman?
(102) The Top 8 Songs To Listen To While Punching Yourself in the Face
(108) Michael Douglas’ 7 Year-Old Daughter Takes Care Of Him, Makes Him Smoothies So He’ll Gain Weight!
(105) Scientists Make Breakthrough in Invisibility Clothing, Stalkers Rejoice
(111) 10 Toys That Will Permanently Screw Up Your Kid
(126) Fiscal Responsibility And Runaway Military Spending Are Not Compatible
(182) Is Xbox Kinect Racist? Not Even Close (Screw You Gamespot)
(119) Startup Turns 10,000 Lbs of Landfill-Bound Coffee Grounds into Oyster Mushrooms
(120) People who swallow foreign objects: Medical treatment is costly
(107) First look at the new 'Tron' costumes (pics)
(130) Attempted Abduction of 11-Year-Old Girl a Hoax; Girl Made Up Story
(125) Shirtless Toolbag gets Tased at a Subway (Video)
(The output is the current news when I pulled the feed down with the curl redirect)
 
Last edited:
Here's my desktop :) The thing to keep in mind with this setup is that it works with practically any wallpaper...I have 800 and my wallpaper changes every 5 mins. Let me know if you want scripts for anything.

Horizontal calendar is DateLine (http://machinecodex.com/dateline/), iTunes info is BowTie (http://bowtieapp.com/), everything else (including the white lines and translucent backgrounds to the info) is Geektool.

The processes in the top left are my top 3 memory hogs with their appropriate memory usages. The uptime script adapts gracefully from uptimes that have 0 hours to uptimes that have hours in them.

Let me know what you think!

Please tell me you can post that wallpaper here. :) I must have it.
+1

That wallpaper is epic!
 

Attachments

  • myDesktop.png
    myDesktop.png
    1 MB · Views: 1,056
Last edited by a moderator:
I was wondering if it's possible to show the currently playing song in VLC. I've searched this thread and others, but I haven't found anything that works so far.
 
I was wondering if it's possible to show the currently playing song in VLC. I've searched this thread and others, but I haven't found anything that works so far.

i'd go for applescript. this thing does everything... :p

edit: applescript doesnt seem to work... :(
 
Last edited:
i'd go for applescript. this thing does everything... :p

edit: applescript doesnt seem to work... :(

Well, I just found this thread on a forum (http://www.apfeltalk.de/forum/vlc-now-playing-t236472.html). If you want to see what the people are actually saying just run the page through Google translate, but the AppleScript is there.

Code:
on linkinuscmd(cmd)
	-- Let's see  if VLC is around..
	set AppleScript's text item delimiters to ""
	set vlc_active to false
	set theString to "/me is not currently running VLC."
	
	tell application "Finder"
		if (get name of every process) contains "VLC" then set vlc_active to true
	end tell
	
	if vlc_active then
		
		-- Ok, VLC is running.  Let's find out what's playing...
		try
			tell application "System Events"
				tell process "VLC"
					tell menu 1 of menu bar item "Wiedergabe" of menu bar 1
						get title of menu item 1
						set play_pause_btn to the result
						get enabled of menu item 2
						set stop_enabled to result
					end tell
				end tell
			end tell
			
			set theString to "/me is currently not playing anything in VLC."
			
			-- We're only interested if VLC is playing.
			if stop_enabled is true and play_pause_btn is "pause" then
				try
					tell application "VLC"
						set theTitle to name of first window whose id is not -1 and name is not "VLC media player" and zoomable is true
						set theString to "/me is running VLC: " & theTitle
					end tell
				end try
			end if
		end try
		
	end if -- end of VLC being active
	
	return theString
end linkinuscmd

What it does is return the title of the now playing window (so you get the file name of the playing file). Not the most ideal situatuation (ie you can't get separate title and artist information).

Although.....just musing here....if you are playing music, as long as you have a standard naming format (eg title-artist.mp3) then you could run the output from the Applescript through sed and filter the results....
 
Nah, that didn't work too well.
If anyone has any other ideas, lemme know. It'd be awesome to have black and white weather images.

Attached are final version and the one with black overlay.


EDIT: One last thing, does anyone know how to make the hard drive space display as 40GB instead of 40GI?

Awesome job!
 
Well, I just found this thread on a forum (http://www.apfeltalk.de/forum/vlc-now-playing-t236472.html). If you want to see what the people are actually saying just run the page through Google translate, but the AppleScript is there.

Code:
on linkinuscmd(cmd)
	-- Let's see  if VLC is around..
	set AppleScript's text item delimiters to ""
	set vlc_active to false
	set theString to "/me is not currently running VLC."
	
	tell application "Finder"
		if (get name of every process) contains "VLC" then set vlc_active to true
	end tell
	
	if vlc_active then
		
		-- Ok, VLC is running.  Let's find out what's playing...
		try
			tell application "System Events"
				tell process "VLC"
					tell menu 1 of menu bar item "Wiedergabe" of menu bar 1
						get title of menu item 1
						set play_pause_btn to the result
						get enabled of menu item 2
						set stop_enabled to result
					end tell
				end tell
			end tell
			
			set theString to "/me is currently not playing anything in VLC."
			
			-- We're only interested if VLC is playing.
			if stop_enabled is true and play_pause_btn is "pause" then
				try
					tell application "VLC"
						set theTitle to name of first window whose id is not -1 and name is not "VLC media player" and zoomable is true
						set theString to "/me is running VLC: " & theTitle
					end tell
				end try
			end if
		end try
		
	end if -- end of VLC being active
	
	return theString
end linkinuscmd

What it does is return the title of the now playing window (so you get the file name of the playing file). Not the most ideal situatuation (ie you can't get separate title and artist information).

Although.....just musing here....if you are playing music, as long as you have a standard naming format (eg title-artist.mp3) then you could run the output from the Applescript through sed and filter the results....

Thanks for the reply, but I've tried that script, and unfortunately it doesn't work for me.
 
Thanks for the reply, but I've tried that script, and unfortunately it doesn't work for me.

O ok, well sorry I couldn't be of more help :) Good luck and I'll post if I find something that does work! (or if I can concoct anything myself for that matter....)
 
I have a geektool script for the day/month/date and one for a calender. When my computer clock changes at midnight.. the geektool still takes a while. How can i have all sync at midnight?
 
I have a geektool script for the day/month/date and one for a calender. When my computer clock changes at midnight.. the geektool still takes a while. How can i have all sync at midnight?

Set the refresh to 1 second for all of those scripts. You should know that this may have side effects. If your computer slows or otherwise starts acting weird after doing this, then increase the refresh time.
 
Set the refresh to 1 second for all of those scripts. You should know that this may have side effects. If your computer slows or otherwise starts acting weird after doing this, then increase the refresh time.

Thank you
 
I copied the script into the Script Editor and tried running it, but I didn't get any output when VLC was open or closed. I don't know much about Applescripts - am I doing something wrong?

open the Applescript Editor (in Applications/Utilities)
copy paste the script and save it somewhere (~/Geektool/scriptVLC.scpt for example)
then in geektool, type "osascript ~/Geektool/scriptVLC.scpt" without the quotation marks. and it should work.
 
Thanks to everyone on here who posted their setups & scripts –*here's what I've applied to my work machine:

Screen shot 2010-11-09 at 14.15.34 (2).pngScreen shot 2010-11-09 at 14.15.34.jpg
Secondary on the left, primary display on the right.

Uses date, weather and sunset scripts, all in Myriad Pro lowercase.
 
Would anyone know what to add in order for it to return the numbers under Peak and Offpeak in gigabytes (1GB = 1 000 000 000) and for it to be to the nearest two decimals? (Eg: "Peak: 11.20GB / 100GB used")

This should get you started...

echo $peak |awk '{ printf "Peak: %.2f / 100GB used\n", $1/1000000000 }'
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.