Conky-Making decisions based on content of external file.

Forum rules
Before you post please read how to get help

Conky-Making decisions based on content of external file.

Postby colinmcc on Sat Dec 01, 2012 1:48 pm

Hi,

Some time ago I wrote a php script for a local fire brigade's page that parses the local government's 'Venting Index' page each day and tells folk if they can have open fires or not. It runs as a cron job once a day and outputs a page of html that is included in their site.

I am using Conky at home, (Mint maya on a Mint BoxPro) and thought to add the info in my desktop conky. So I altered my php to write the data to another file which I then access in Conky thus:

Code: Select all
${offset 240}${color cyan}VENTING INDEX:
${offset 240}${color yellow}${exec cat 30 /var/www/path_to/VI.txt}


As an example today's VI.txt contains:

Code: Select all
Today 7am: No Burning
Today 4pm: No Burning
Tomorrow 7am: Burning Permitted


I then wanted to make the "No Burning lines" red and "Burning Permitted" appear in green, so altered my php to add ${color red} and ${color green} depending on the parsed result.

Making my VI.txt now look like
Code: Select all
${color red}Today 7am: No Burning
${color red}Today 4pm: No Burning
 ${color green}Tomorrow 7am: Burning Permitted


Expecting that Conky would interpret the variables and color the lines, but it doesn't, it just outputs the text literally. Like this:


${color red}Today 7am: No Burning
${color red}Today 4pm: No Burning
${color green}Tomorrow 7am: Burning Permitted

When I want Conky to display:

Today 7am: No Burning
Today 4pm: No Burning
Tomorrow 7am: Burning Permitted

I've been trying to see how Conky can parse Conky Variables in an external file and act on it's content rather than just echo it out on the screen but am hitting a wall... Is it possible? Or, if not, can someone please point me at a how to?

Thanks..

(Venting Index info for anyone interested..) The Venting Index is a term used in air pollution meteorology. (It is also known as the Ventilation Index.) The Ventilation Index is a numerical value related to the potential of the atmosphere to disperse airborne pollutants, such as smoke from a fire. It is based on both the current wind speed in the mixed layer and the mixing height. The mixed layer is the surface layer of air that is turbulent and well mixed. The mixing height is the thickness (sometimes zero) of this mixed layer.
Stronger wind speeds and thicker mixed layers will produce higher venting indexes. For convenience, the Ventilation Index is converted to a scale of 0 to 100. On this scale, the capacity of the atmosphere to disperse pollutants is related to the following Ventilation Index values:
Ventilation Category
0 - 33 POOR ventilation
34 - 54 FAIR ventilation
55 - 100 GOOD ventilation

The Ministry of Environment's Venting Index (In Canada) contains smoke-control forecasts for the current and following day, as well as archived smoke-control forecasts for the last several years. If the Ventilation Index indicates POOR or FAIR, then smoke that results from burning will tend to build up, causing air pollution. To avoid such pollution, outdoor burning is restricted when the index is POOR or FAIR.
colinmcc
Level 1
Level 1
 
Posts: 16
Joined: Fri Oct 26, 2012 8:07 pm

Linux Mint is funded by ads and donations.
 

Re: Conky-Making decisions based on content of external file

Postby colinmcc on Mon Dec 10, 2012 7:05 pm

Update

Well, no one came forward with any suggestions so... I saw that if I changed anything in my .conkyrc, conky noticed that it had changed and restarted automatically using the new .conkyrc. (This is not what the website says, they say you have to stop conky and restart it after modifying the .conkyrc file).

So after thinking about it I realised that I could simply write a new .conkyrc file with my parsed results and colours in the same format as a conky text line and conky would notice the new .conkyrc and display corectly.. It works!

I moved all my unchanging .conkyrc into a separate file. conky.txt, and then in my php after creating the day's scrape of the venting index site and formatting it as 3 lines of conky text with the right colours I just concatinated it and the conky.txt file and wrote the result out as .conkyrc, overwriting the old one. it works, I get my results displayed and colored as I wished in my previous post. :D

I also get a xml feed of snow and weather from the local ski hill which I also parse with php and add to my conky desktop the same way. I store past data and colour the text depending on the trends, temp rising/falling, new snow etc.

Hope this helps anyone else.

Finally I've started to investigate Lua, whiach apparently integrates with conky, I've never used it (and, being comfortable with php probably won't,) but it will be interesting to see how it would go about the problem.
colinmcc
Level 1
Level 1
 
Posts: 16
Joined: Fri Oct 26, 2012 8:07 pm


Return to Compiz, Conky, Docks, & Widgets

Who is online

Users browsing this forum: No registered users and 6 guests