Jump to content

Subway workflow


Recommended Posts

Posted

I have an old v1 extension that I used to get feedback on the London Tube network. It ran a script and outputted to Growl. Its very useful for getting an up to date status of the network.

 

I am trying to convert it into v2 workflow and have managed to output the text to notification centre, however, the code only shows 2 lines. How do I convert this to show all subway lines in the alfred window and not in notification centre?

 

Script is here (sorry I copied it from a web site somewhere and have lost the original creators address)

 

 

RESULT=$(curl -s "http://api.tubeupdates.com/?method=get.status&lines=all&format=xml" | cat | awk '/<status>/')
 
for index in Bakerloo Central Circle District DLR Jubilee Metropolitan Northern  Piccadilly Victoria Waterloo
do
      RESULT=$(echo $RESULT | sed "s/<status>/$index: /1" | sed "s/<\/status> /\\\n/g" | sed "s/<\/status>//g")
done
 
echo -e -n $RESULT
 
Thanks 
gr4z
Posted

I have an old v1 extension that I used to get feedback on the London Tube network. It ran a script and outputted to Growl. Its very useful for getting an up to date status of the network.

 

I am trying to convert it into v2 workflow and have managed to output the text to notification centre, however, the code only shows 2 lines. How do I convert this to show all subway lines in the alfred window and not in notification centre?

 

Script is here (sorry I copied it from a web site somewhere and have lost the original creators address)

 

 

RESULT=$(curl -s "http://api.tubeupdates.com/?method=get.status&lines=all&format=xml" | cat | awk '/<status>/')
 
for index in Bakerloo Central Circle District DLR Jubilee Metropolitan Northern  Piccadilly Victoria Waterloo
do
      RESULT=$(echo $RESULT | sed "s/<status>/$index: /1" | sed "s/<\/status> /\\\n/g" | sed "s/<\/status>//g")
done
 
echo -e -n $RESULT
 
Thanks 
gr4z

 

To show more than two lines of output, it seems you must set the 'Notification' object to use Growl.

 

You can use a script filter to feed results back into Alfred.

Posted (edited)

I have changed the Notification to Growl but it makes no difference. Sorry I am not sure what to do when using a Script Filter - can you be a bit more descriptive as to what to do? Thanks

Edited by gr4z
Posted

I have changed the Notification to Growl but it makes no difference. Sorry I am not sure what to do when using a Script Filter - can you be a bit more descriptive as to what to do? Thanks

To use a script filter, you echo an XML string with the necessary feedback items. This post (http://www.alfredforum.com/topic/5-generating-feedback-in-workflows/) by David Ferguson explains it better than I could.

As for Growl, have you set it to use Notification Center? If you have, it will not workproperly

Posted

I have changed the Notification to Growl but it makes no difference. Sorry I am not sure what to do when using a Script Filter - can you be a bit more descriptive as to what to do? Thanks

 

I haz a gift

 

londontube.png

 

Download

 

I don't know a full list of all the potential status messages yet. I sent the guy who made the API an email requesting that list. When I get that, I'll update this workflow again. Until then, if there are messages I haven't accounted for yet, the icon will show as a question mark.

  • 1 month later...
Posted

I just moved to Alfred 2, and wanted to convert my old extensions to workflows (where appropriate). Looks like I've been beaten to it (and with less hacky code), good work David

  • 9 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...