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.
At the end of your code to grab the disk space, add the following:
Code:
 | sed "s/Gi/GB/"

I'm assuming the original script outputs the disk space as Gi (mine did that), so that's why I left it lowercase. If it doesn't work, make the "i" in the sed command uppercase.

nice, that worked! thanks so much
 

Attachments

  • it worked!.gif
    it worked!.gif
    10 KB · Views: 4,423
nice, that worked! thanks so much

If you have it print out the total disk usage with the same command (Total / Used), you would need to change the pipe to:
Code:
 | sed "s/Gi/GB/g"
to make the replace global over the entire text you're feeding sed, otherwise it just does the first one it finds.

Only pointing this out because my script for disk usage only did the replace on the Total HD size and not the used space and I felt that I misled you.

Glad it worked out!
 
Hi,

I've been trying a lot of things, including this script to get RSS headlines on my desktop but just can't get it to work properly.

What i want is display the headlines of a feed from myepisodes.com, listing tomorrows episodes.
The output of such a RSS file is something like this:

Code:
[ The Big Bang Theory ][ S04E06 ][ The Irish Pub Formulation ][ 29 October ]

The Big Bang Theory
Episode Title:  The Irish Pub Formulation
Episode #	S04E06
Air Date:	29 October
Air Time:	02:00

[The Big Bang Theory] guide at www.tvrage.com
[The Irish Pub Formulation] episode guide at www.tvrage.com


[ Outsourced ][ S01E06 ][ Bolloween ][ 29 October ]

Outsourced
Episode Title:  Bolloween
Episode #	S01E06
Air Date:	29 October
Air Time:	03:30
Links:
[Outsourced] guide at www.tvrage.com
[Bolloween] episode guide at www.tvrage.com

Now what i would REALLY like is to just show me

Code:
The Big Bang Theory
Outsourced

But i recon that's probably not possible so
Code:
[ The Big Bang Theory ][ S04E06 ][ The Irish Pub Formulation ][ 29 October ]
[ Outsourced ][ S01E06 ][ Bolloween ][ 29 October ]

would also be fine i guess

I really hope someone could make this work, here's a demo RSS link to try it out with:
feed://myepisodes.com/rss.php?feed=...=demo&pwdmd5=fe01ce2a7fbac8fafaed7c982a04e229

Thanks in advance!! :D
 
Hi,

I've been trying a lot of things, including this script to get RSS headlines on my desktop but just can't get it to work properly.

What i want is display the headlines of a feed from myepisodes.com, listing tomorrows episodes.
The output of such a RSS file is something like this:

Add this to the end of your script command line.
Code:
 | grep "^\[ " | sed s'/\[ \([a-zA-Z0-9 ]*\) \].*$/\1/'
This at least worked from the command line when I tried it out.
 
Everytime I use geektool, i get a kernal panic. Anyone know why? I had 4 different shell commands, and all had different refresh rates.
 
Add this to the end of your script command line.
Code:
 | grep "^\[ " | sed s'/\[ \([a-zA-Z0-9 ]*\) \].*$/\1/'
This at least worked from the command line when I tried it out.
Hey thanks, but it doesn't work (or i'm doing it wrong)

without your part is shows this:

(see attachment 1)

with your part it shows nothing, but it does show a green indicator light...

(see attachment 2)

edit:
I now added just the
Code:
sed s'/\[ \([a-zA-Z0-9 ]*\) \].*$/\1/'
part to the actual script and it shows me the show names correctly! (awesome), it still shows the description though..

(see attachment 3)
 

Attachments

  • 1.png
    1.png
    506.6 KB · Views: 147
  • 2.png
    2.png
    120.4 KB · Views: 128
  • 3.png
    3.png
    537.7 KB · Views: 309
Hey thanks, but it doesn't work (or i'm doing it wrong)

From the attachment on the right it looks like it was entered right. For the script trying doing this for the curl command.
Code:
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' |
	grep "^\[ " |
	sed s'/\[ \([a-zA-Z0-9 ]*\) \].*$/\1/' |
	head $headerg | sed G | fmt
It's just embedding the grep command in there. The grep is filtering out only lines that start with "[ txt" which eliminates the description area.

This is another version to try.
Code:
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 $headerg | sed G | fmt |
	grep "^\[ " |
	sed s'/\[ \([a-zA-Z0-9 ]*\) \].*$/\1/'
 
From the attachment on the right it looks like it was entered right. For the script trying doing this for the curl command.
Code:
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' |
	grep "^\[ " |
	sed s'/\[ \([a-zA-Z0-9 ]*\) \].*$/\1/' |
	head $headerg | sed G | fmt
It's just embedding the grep command in there. The grep is filtering out only lines that start with "[ txt" which eliminates the description area.

This is another version to try.
Code:
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 $headerg | sed G | fmt |
	grep "^\[ " |
	sed s'/\[ \([a-zA-Z0-9 ]*\) \].*$/\1/'
Thanks, but both of them show nothing.. :(
 
I've been doing some research on the grep command myself online and fixed it!!!

Code:
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' |
  sed s'/\[ \([a-zA-Z0-9 ]*\) \].*$/\1/' |
  grep -i -v 'h3' |
  grep -i -v '\.'
  head $headarg | sed G | fmt

This works!

Code:
grep -i -v 'h3' |
this one is for when there are episodes in the feed, when there are no episodes it would show:
No Episodes
.There are currently no episodes in this feed

Code:
  grep -i -v '\.'

This one removes the second line!
 
What i want is display the headlines of a feed from myepisodes.com, listing tomorrows episodes.
The output of such a RSS file is something like this:

Code:
[ The Big Bang Theory ][ S04E06 ][ The Irish Pub Formulation ][ 29 October ]

The Big Bang Theory
Episode Title:  The Irish Pub Formulation
Episode #	S04E06
Air Date:	29 October
Air Time:	02:00

[The Big Bang Theory] guide at www.tvrage.com
[The Irish Pub Formulation] episode guide at www.tvrage.com


[ Outsourced ][ S01E06 ][ Bolloween ][ 29 October ]

Outsourced
Episode Title:  Bolloween
Episode #	S01E06
Air Date:	29 October
Air Time:	03:30
Links:
[Outsourced] guide at www.tvrage.com
[Bolloween] episode guide at www.tvrage.com

Now what i would REALLY like is to just show me

Code:
The Big Bang Theory
Outsourced
Pipe it into this maybe:

sed '/^\[ /!d;s///;s/ \].*$//'


 
Thanks, but both of them show nothing.. :(

I downloaded the script so I could get a better idea. It looks like the script was adding a space to the beginning of the line, which I believe my stuff wasn't handling. Here's an updated curl command if you want to try it. It may leave you with the same issue as the other solution provided though. I don't have your exact feed to try out.
Code:
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 |
  grep "^ [^ ]" |
  sed s'/\[ \([a-zA-Z0-9 ]*\) \].*$/\1/'
 
Hey,

I now have figured out how to remove the [ S01E01 ] part but with it it brings a new bug.

the code to remove the episode part is
Code:
sed 's/\[//g;s/\]//g;s/\S.*//g'

but now it moves the last ) bracket to the beginning of the line and turns it around, see:

7.png


Any solutions?..

P.S.
@angelwatt
the last script you posted doesn't show anything but no biggie i have it working except for this one bug, thanks!
 
Hey,

I now have figured out how to remove the [ S01E01 ] part but with it it brings a new bug.

the code to remove the episode part is
Code:
sed 's/\[//g;s/\]//g;s/\S.*//g'

but now it moves the last ) bracket to the beginning of the line and turns it around, see:

7.png


Any solutions?..

P.S.
@angelwatt
the last script you posted doesn't show anything but no biggie i have it working except for this one bug, thanks!

Did you not see my previous post?
[works fine here for the input file you provided.]
 
Hey, yeah sorry. i tried it but it is not showing anything..

i don't really know where to place the code though, i figured between the curl and head lines.
Well, in your original post you stipulated a specific sample input (which i also quoted in my first post), and you requested a particular output. If you pipe that same exact input you originally gave (regardless of where it's coming from) directly into my sed statement (i.e., do not include any of the various other sed suggestions given elsewhere), you will get the output you asked for.

[whether or not it will also work for *other* samples of input remains to be seen. i would need to study them.]
 
Hey,

I now have figured out how to remove the [ S01E01 ] part but with it it brings a new bug.

the code to remove the episode part is
Code:
sed 's/\[//g;s/\]//g;s/\S.*//g'

but now it moves the last ) bracket to the beginning of the line and turns it around, see:

7.png


Any solutions?..

P.S.
@angelwatt
the last script you posted doesn't show anything but no biggie i have it working except for this one bug, thanks!

I figured I'd make a python script that does this easily, that way you don't have to worry about piping everything to sed multiple times.

Save the following code as "myepisode_feedgrabber.py" and do a chmod +x on the file to make it executable.
Code:
#!/usr/bin/env python

# MODULE IMPORTS
import xml.dom.minidom
import re

# 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/geektool/myepisode_feed.xml
dom = xml.dom.minidom.parse("/tmp/geektool/myepisode_feed.xml")

# LIST TO HOLD ALL THE EPISODES
episodes = []

# 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 handleChannel(channel,episodes):
    items = channel.getElementsByTagName("item")
    handleToc(items,episodes)

def handleToc(items,episodes):
    for item in items:
        # GET THE TITLE TAG FROM THE CURRENT ITEM
        title = item.getElementsByTagName("title")[0]
        # GET THE TITLE DATA FROM THE TITLE TAG
        tmp = getText(title.childNodes)
        # REGULAR EXPRESSIONS TO REMOVE THE [ AND ] AND REPLACE WITH ,
        tmp = re.sub(" \]\[ ",",",tmp)
        tmp = re.sub("\[ ","",tmp)
        tmp = re.sub(" \]","",tmp)
        # APPEND A LIST OF 4 ITEMS TO THE EPISODE LIST
        episodes.append(tmp.split(","))

# HANDLE THE XML
handleChannel(dom,episodes)

# PRINT OUT THE SHOWS
for i in range(len(episodes)):
    # WHAT EACH PORTION OF THE EPISODE LIST MEANS
    #  - episode[i][0] = SHOW NAME
    #  - episode[i][1] = SHOW SEASON AND EPISODE NUMBER
    #  - episode[i][2] = EPISODE TITLE
    #  - episode[i][3] = AIR DATE
    # THE PRINT STATEMENT IS TOTALY CUSTOMIZABLE
    # PRINT OUT SHOW TITLE AND EPISODE NAME
    print episodes[i][0] + ' - "' + episodes[i][2] + '"'

In the Geektool shell, add the following code, but replace everything in quotes with your URL:
Code:
curl --silent "url goes here in quotations or else it won't work" > /tmp/geektool/myepisode_feed.xml; 
python /path/to/the/script/myepisode_feedgrabber.py

Make sure you create a folder in /tmp called geektool as this is where the redirect and python script send/look for the xml file.

Attached is a screen grab, disregard the fact that is shows "Desperate Housewives", I picked a show that I knew would be on tomorrow when I did the myepisodes demo for the Tomorrow RSS feed.
 

Attachments

  • test_myepisodegrabber.png
    test_myepisodegrabber.png
    89.7 KB · Views: 120
WOW this is awesome!!

works like a charm, thanks a lot dude!! :D

No problem!

I have run into one issue with how I use the /tmp directory. Sometimes (but not always) the /tmp/geektool directory gets deleted upon power cycle, so you may have to go re-create it.

Regular expressions are great to use for simple parsing; but it seems to me that new users to Geektool, that have no experience with the command line, get confused easily. A one off script that does exactly what you need is far easier to maintain then a ton of commands being piped to each other.
 
No problem!

I have run into one issue with how I use the /tmp directory. Sometimes (but not always) the /tmp/geektool directory gets deleted upon power cycle, so you may have to go re-create it.

Regular expressions are great to use for simple parsing; but it seems to me that new users to Geektool, that have no experience with the command line, get confused easily. A one off script that does exactly what you need is far easier to maintain then a ton of commands being piped to each other.
Hmm okay, i'll keep that in mind when it suddenly stops working ;)

I don't turn my computer off that often unless it needs a reboot for an update or if i'm going away for more than a couple of days. So it won't happen to me al lot :)

Thanks again ;)
 
uppercase date and month

Im sorry Im new to geektool..what's the script to display date and month in uppercase.. there are fonts that can do this but i wated to use a different font. :confused:
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.