Ubuntu 8.10 beta Intrepid Ibis GNU/Linux
Seems to be working smoothly. I updated my .conkyrc file to grab the first 22 letters of the song title followed by fake ellipses. Why? Why Knot?
BTW: The river stage is at Memphis on the Mississippi River. I think I covered that in an earlier post.
#.conkyrc 8 Oct 08 - Add support for audacious
# … normal conkyrc stuff deleted for brevity
#
TEXT
${color #F9F99F}${time %A} ${time %F} ${time %k:%M}
${color #f8a310}${execi 1759 /home/art/scripts/weather/weather.sh 38053}
${color #6be457}${execi 1759 /home/art/scripts/weather/weather-cc.sh 38053}
${color #f9f479}${execi 1759 /home/art/scripts/weather/weather-2.sh 38053}
${color #f9f479}UpTime: ${color f8a310}$uptime
${color #f9f479}${execi 7200 /home/art/scripts/river/myriver.pl}
${if_running audacious}${color #A7D7BB}${exec audtool –current-song|cut -b-22}…$endif
#!/bin/sh
#weather.sh
LOCID=$1
# s=standard units, m=metric units
UNITS=s
# where this script and the XSLT lives
RUNDIR=/home/art/scripts/weather
CURLCMD=/usr/bin/curl
# get it at http://xmlsoft.org/XSLT/
XSLTCMD=/usr/bin/xsltproc
CURLURL="http://xoap.weather.com/weather/local/$LOCID?cc=*&unit=$UNITS&dayf=2"
XSLT=$RUNDIR/loc.xslt
#####
eval "$CURLCMD \"$CURLURL\" 2>/dev/null| $XSLTCMD $XSLT - $FILTER"
#loc.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output method="text" disable-output-escaping="yes"/>
<xsl:template match="weather">
<xsl:apply-templates select="loc"/>
</xsl:template>
<xsl:template match="loc">
<xsl:text>
Millington, TN 38053</xsl:text>
<xsl:text>
S/R: </xsl:text><xsl:value-of select="sunr"/><xsl:text> S/S: </xsl:text><xsl:value-of select="suns"/>
<xsl:text>
Lat: </xsl:text><xsl:value-of select="lat"/><xsl:text> Long: </xsl:text><xsl:value-of select="lon"/>
</xsl:template> <!– end of template "loc" –>
</xsl:stylesheet>
#weather.xslt
<xsl:text>
Sunrise: </xsl:text><xsl:value-of select="sunr"/><xsl:value-of select="/weather/head/t"/>
<xsl:text>
Sunset : </xsl:text><xsl:value-of select="suns"/><xsl:value-of select="/weather/head/t"/>
–>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output method="text" disable-output-escaping="yes"/>
<xsl:template match="weather">
<xsl:apply-templates select="cc"/>
<xsl:apply-templates select="dayf/day[@d=’1′]"/>
</xsl:template>
<xsl:template match="cc">
<xsl:value-of select="obst"/>
<xsl:text>
</xsl:text>
<xsl:text>Temperature: </xsl:text><xsl:value-of select="tmp"/><xsl:value-of select="/weather/head/ut"/>
<xsl:if test="tmp != flik">
<xsl:text>
Feels Like: </xsl:text><xsl:value-of select="flik"/><xsl:value-of select="/weather/head/ut"/>
</xsl:if>
<xsl:text>
Conditions: </xsl:text><xsl:value-of select="t"/>
<xsl:text>
Wind: </xsl:text>
<xsl:value-of select="wind/s"/>
<xsl:value-of select="/weather/head/us"/>
<xsl:text> (</xsl:text><xsl:value-of select="wind/t"/>
<xsl:text>)</xsl:text>
</xsl:template>
<xsl:template match="dayf/day[@d=’1′]">
<xsl:text>
Tomorrow: </xsl:text><xsl:value-of select="low"/><xsl:value-of select="/weather/head/ut"/>
<xsl:text>
- </xsl:text><xsl:value-of select="hi"/><xsl:value-of select="/weather/head/ut"/>
<xsl:text>
, </xsl:text>
<xsl:text> …</xsl:text>
<xsl:value-of select="part[@p=’d']/t"/>
</xsl:template>
</xsl:stylesheet>
#cc.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output method="text" disable-output-escaping="yes"/>
<xsl:template match="weather">
<xsl:apply-templates select="cc"/>
</xsl:template>
<xsl:template match="cc">
<xsl:text>
Temp: </xsl:text><xsl:value-of select="tmp"/><xsl:value-of select="/weather/head/ut"/>
<xsl:text>
F/L: </xsl:text><xsl:value-of select="flik"/><xsl:value-of select="/weather/head/ut"/>
<xsl:text>
Cond: </xsl:text><xsl:value-of select="t"/>
<xsl:text>
Wind: </xsl:text><xsl:value-of select="wind/s"/><xsl:text> </xsl:text><xsl:value-of select="/weather/head/us"/><xsl:text> - </xsl:text><xsl:value-of select="wind/t"/>
</xsl:template><!– end of template "cc" –>
</xsl:stylesheet>
#tomorrow.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output method="text" disable-output-escaping="yes"/>
<xsl:template match="weather">
<xsl:apply-templates select="dayf/day[@d=’1′]"/>
</xsl:template>
<xsl:template match="dayf/day[@d=’1′]">
<xsl:text>
Tomorrow: </xsl:text><xsl:value-of select="low"/><xsl:value-of select="/weather/head/ut"/><xsl:text> - </xsl:text><xsl:value-of select="hi"/><xsl:value-of select="/weather/head/ut"/>
<xsl:text>
</xsl:text><xsl:value-of select="part[@p=’d']/t"/>
</xsl:template><!– end of template "dayf/day[@d=’1′]" –>
</xsl:stylesheet>
#!/bin/sh
#weather-cc.sh
LOCID=$1
# s=standard units, m=metric units
UNITS=s
# where this script and the XSLT lives
RUNDIR=/home/art/scripts/weather
CURLCMD=/usr/bin/curl
# get it at http://xmlsoft.org/XSLT/
XSLTCMD=/usr/bin/xsltproc
CURLURL="http://xoap.weather.com/weather/local/$LOCID?cc=*&unit=$UNITS&dayf=2"
XSLT=$RUNDIR/cc.xslt
#####
eval "$CURLCMD \"$CURLURL\" 2>/dev/null| $XSLTCMD $XSLT - $FILTER"
#!/bin/sh
#weather-2.sh
LOCID=$1
# s=standard units, m=metric units
UNITS=s
# where this script and the XSLT lives
RUNDIR=/home/art/scripts/weather
CURLCMD=/usr/bin/curl
# get it at http://xmlsoft.org/XSLT/
XSLTCMD=/usr/bin/xsltproc
CURLURL="http://xoap.weather.com/weather/local/$LOCID?cc=*&unit=$UNITS&dayf=2"
XSLT=$RUNDIR/tomorrow.xslt
#####
eval "$CURLCMD \"$CURLURL\" 2>/dev/null| $XSLTCMD $XSLT - $FILTER"
########### River Stage Stuff follows
#!/bin/bash
# *** Header ***
# Script to get river stage data and make information available when called by ~./conkyrc
# example: ${color #98907E}${execi 1800 /home/art/scripts/river.sh}
# Art Murphy - http://doghouse.blogsome.com/
# Use this. Abuse this. Have fun.
# No revision information at this point 18 January, 2006 @ Memphis, TN USA
# *** end Header ***
#
# *** Global Declarations ***
# No global declarations at this point.
# *** end Global Declarations ***
#
# Gets the river stage data from noaa.gov and writes data to a file named RVAORN.
# *** Sanity Check to see if an old river data file exists.
if [ -e "/home/art/scripts/data/RVAORN" ];
then
# If an old river stage data file exists, then, remove the file.
rm /home/art/scripts/data/RVAORN;
# Now get a new river stage data file and write it to my data directory.
wget -O /home/art/scripts/data/RVAORN http://www.srh.noaa.gov/data/ORN/RVAORN;
else
# If no old river data stage file exists then get one and write it to my data.
wget -O /home/art/scripts/data/RVAORN http://www.srh.noaa.gov/data/ORN/RVAORN;
# Finished with this part.
fi
#
# Okay now we must parse the text file (RVAORN)to extract
# pertinent information. I’m interested in the Mississippi
# River as it flows by where Jeff Buckley drowned.
#
# More housekeeping. Get rid of the old file.
#
# *** Sanity Check to see if an old river data file exists.
if [ -e "/home/art/scripts/data/memphis.txt" ];
then
# If an old river stage data file exists, then, remove the file.
rm /home/art/scripts/data/memphis.txt;
# This perl script parses the line for the Mississippi at Memphis, Tennessee.
/home/art/scripts/river/parseriverstagedata.pl < /home/art/scripts/data/RVAORN > /home/art/scripts/data/memphis.txt
else
# If no old river data stage file exists then get one.
# This perl script parses the line for the Mississippi at Memphis, Tennessee.
/home/art/scripts/river/parseriverstagedata.pl < /home/art/scripts/data/RVAORN > /home/art/scripts/data/memphis.txt
# Finished with this part.
fi
# Read the info from memphis.txt so that conkyrc command will be able display the info.
cat /home/art/scripts/data/memphis.txt
##########################
#!/usr/bin/perl -w
#parseriverstagedata.pl
use strict;
my $file = "/home/art/scripts/data/RVAORN";
use warnings;
# can I use the wget command here instead of writing to a file.?
while () {
next if (! /^MEMPHIS/ ); # match the line starting with ‘MEMPHIS’
#
# This is the river stage data format:
# MEMPHIS 34 23.1 +0.8 23.7 24.5 25.7 26.9 27.5 28.5 1/25P
# I just need the second number which is 23.1 in this example.
# Note: Extract the riverstage for the current day here.
# How can I do that?
# Tell perl to stript the text, following spaces and first number which is the flood stage.
# That would leave:
# 23.1 +0.8 23.7 24.5 25.7 26.9 27.5 28.5 1/25
s/[[:alpha:]]* [[:space:]]* [+-]? \d+(\.\d+)? [[:space:]]*//;
# "What does that mean?
# s/ - start and strip. Okay, strip what?
# [[:alpha:]]* - zero or more occurances of letters such as MEMPHIS.
# [[:space:]]* - zero or more occurances of space(s).
# [+-]? - optional plus or minus sign. Not really needed but…
# \d+ - one or more digits such as 34.
# (\.\d+)? - optional period optional one or more digits such as ".12".
# [[:space:]]* - zero or more occurances of space(s).
# //; end of perl regex operation.
#
# Next:
# Tell perl I only want the first number in the line and a plus or minus sign if provided.
/([+-]?\d+(\.\d+)?)/;
# One or more digits, an optional decimal point and an optional trailing one or more digits.
#
print"River stage: ","$1"," ft.";
}
########################
#!/usr/bin/perl
# myriver.pl
use strict;
use warnings;
use LWP::Simple;
my $index=0;
my @sentences = split(/\n/m, get("http://www.srh.noaa.gov/data/ORN/RVAORN"));
for($index=0; $index<@sentences; $index++) {
if (substr(($sentences[$index]),0,7) eq "MEMPHIS") {
print"River stage: ",substr(($sentences[$index]),19,5)," ft.";
}
}