LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   conky help (http://www.linuxquestions.org/questions/slackware-14/conky-help-4175463304/)

SeRi@lDiE 05-24-2013 07:05 AM

conky help
 
I have a web enable irrigation system.

The system has an api that allows you to curl the data.

I am trying to use conky to curl the data and display it on my conky window.

The problem is that I dont know how to make the data readable.

Here is what I got on conkyrc.


#${voffset 4}${font PizzaDude Bullets:size=14}a${font} Status: ${alignr}${execi 3600 curl »irrigation:23456/status.json}

Here is the output that comes out the curl:


{"zoneNumber":0,"progNumber":0,"allowRun":true,"running":false,"useSensor1":true,"isRaining":false," zoneSecLeft":0,"progSecLeft":0,"maxZones":10}

How can I make the output be aligned and readable?

Thanks in advance for the help!

273 05-24-2013 07:31 AM

You could run the output through sed, for example, to change the formatting. I'm very new to sed so my solution would be using sed multiple times something like this:
Code:

|sed 's/\,/\n/g'| sed 's/\"//g'| sed 's/{//g'| sed 's/}//g'
Of course somebody who knows sed better could likely do this in one.
Or you could be more clever and if the isRaining part is true display a picture. I'm guessing you could use cut to obtain the relevant field then use the ${if_match} conky directive to decide what to display.

Didier Spaier 05-24-2013 08:11 AM

There is more than one way to skin a cat ;)
Code:

<curl_command>  | tr -d  '{' | tr -d '}' | tr -d '"' | tr ',' '\n' | tr -d ' '

273 05-24-2013 08:25 AM

Indeed, Didier, that is a bit neater :).

SeRi@lDiE 05-24-2013 10:36 AM

Thanks guys. This was perfect.
Does any body know how to tell conky to re size automatically instead of cutting?

273 05-24-2013 10:39 AM

I'm not sure what you mean? I tend to set the sizes in my conky manually just adjusting things until they fit.

SeRi@lDiE 05-24-2013 10:45 AM

Quote:

Originally Posted by 273 (Post 4958231)
I'm not sure what you mean? I tend to set the sizes in my conky manually just adjusting things until they fit.

Yup I got it a few seconds after the post.

Thanks!


All times are GMT -5. The time now is 09:39 PM.