LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-23-2016, 09:05 AM   #1
jakfish
Member
 
Registered: Aug 2016
Posts: 52

Rep: Reputation: Disabled
Conky: Maintain Curl Output When Off-line?


On my Chromebook Acer C720, running GalliumOS (Xubuntu 16.04), I run a simple conky for weather temperature:

Code:
$color${execi 300 /home/jake/Scripts_Icons/weather 20902}
This calls a weather script, which is this:

Code:
curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1 \
| sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3 \1/p'
This works, but if I disable wifi, the script obviously can't go on-line to get the weather and conky goes blank.

When off-line, is there a way to maintain the print-out of the last retrieved weather temperature?

Thank you,
Jake

Last edited by jakfish; 09-23-2016 at 09:32 AM. Reason: code tages
 
Old 09-23-2016, 09:12 AM   #2
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Save the data to a file, then pull the weather data from the cache. BTW, please use code tags, makes code easier to read.

Give this a try:

Code:
#!/bin/env bash
wxcache=${HOME}/tmp/wxdata-cached

curl -o ${wxcache} -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1
sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3 \1/p' ${wxcache}

Last edited by goumba; 09-23-2016 at 09:20 AM.
 
1 members found this post helpful.
Old 09-23-2016, 09:46 AM   #3
jakfish
Member
 
Registered: Aug 2016
Posts: 52

Original Poster
Rep: Reputation: Disabled
That absolutely did it You script guys are amazing. (I edited original post to add code tags)

Many, many thanks,
Jake
 
Old 09-23-2016, 10:03 AM   #4
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
You know it's possible that the data downloaded may be valid but not contain weather data (URL Moved?). In that case you will lose your conky display, but in that case you'll at least something's seriously wrong.

Now if you want to get fancy... you can just have it cache the old data and not overwrite it unless valid data is found. You can also only cache the weather info and not the whole page as I simply did above (however in doing so you can pull any cached data at any time, not just the temperature and conditions).
 
1 members found this post helpful.
Old 09-24-2016, 04:54 PM   #5
jakfish
Member
 
Registered: Aug 2016
Posts: 52

Original Poster
Rep: Reputation: Disabled
Sorry for the late post, I was away. So far, your suggested setup has worked with wifi on or off.

My conky interval is:
Code:
update_interval = 1.0,
But it would be appear by looking at the cached data that the interval for temperature retrieval is far greater, maybe 10+ minutes. That's okay, but I was wondering why. The curl command doesn't appear to have a built-in interval.

Jake

Last edited by jakfish; 09-24-2016 at 04:56 PM.
 
Old 09-24-2016, 07:48 PM   #6
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
Quote:
Code:
execi 300
You're calling the script every 300 seconds.
 
1 members found this post helpful.
Old 09-24-2016, 10:19 PM   #7
jakfish
Member
 
Registered: Aug 2016
Posts: 52

Original Poster
Rep: Reputation: Disabled
That would explain it

Thanks,
Jake
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Conky: not updating the output for the cpu object TobiSGD Linux - Software 2 11-28-2011 03:25 PM
[SOLVED] Is there any way to get conky to only output to console (no X window)? Allamgir Slackware 5 12-24-2009 12:19 PM
Conky Script-Output Problem ganimo Linux - General 2 05-10-2009 07:15 AM
conky not showing all output wilsid Linux - Software 0 06-05-2008 03:54 PM
curl scrape javascript output pld Programming 4 04-13-2005 03:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration