- This topic has 3 replies, 2 voices, and was last updated Mar 31-12:33 pm by blur13.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
Forum for users of antiX Linux. Mean and Lean and Proudly anti-fascist.
Forum › Forums › New users › New Users and General Questions › conky with conditionals
Hi!
So here is the problem. I use wttr.in to get weather data to output display in conky. For example:
${execi 1200 curl -sm 2 wttr.in/stockholm?format="%w"\&M}
the -m 2 gives 2 seconds before the operation times out. Otherwise I’ve found that conky gets stuck when the curl command never finishes and nothing is displayed. I have to manually kill the curl processes in htop to get it to move on. And then the same thing repeats 20 min later. So -m 2 solves that problem. However, I have about five curl commands to wttr and some formatting and text that looks weird when nothing is returned from wttr. I’ve found wttr to be somewhat unreliable so this happens a lot. Enough times that I want to make a conditional along the lines of, “if curl times out, then…”. The exit code when curl times out is 28. So basically, when executing the above command, and the exit code is 28, then I dont want conky to use any of the code below. Any way to do this?
Maybe a smarter approach would be to use a shell script, run the above curl command and then, depending on the exit code, either run conky -c .conkyrc
conky -c .conkyrc2
where .conkyrc2 would be free from any curl wttr references. Anyone here good at scripting?
Hm, ‘conky -c’ is nice.
How about the following usage of special variable ‘$?’ in BASH
#!/bin/bash
curl <whatever>
exitcode="$?"
if [ "${exitcode}" -eq 28 ]; then
conky -c <config one>
else
conky -c <config two>
fi
See e.g. https://devhints.io/bash
Thank you! That is excellent. I simplified it to:
#!/bin/bash
curl <whatever>
if [ $? -eq 28 ]; then
conky -c <config one>
else
conky -c <config two>
fi
works great!
| Cookie | Duration | Description |
|---|---|---|
| cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
| cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
| cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
| cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
| cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
| viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |