SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2014-03-18 21:43:12

Joe90
#! Junkie
Registered: 2013-10-10
Posts: 337

[SOLVED!] Conky: display one text file after another and repeat

Hi

Working on a digital display, using my own content in text files, and what I want to achieve is for a conky to start up, display the contents of a text file for 30 seconds, then clear this, show the contents of another text file for 30 seconds, then clear this, and so on, probably for up to five text files, and then to start again.

Displaying the first / only one text file is straight forward:

${exec cat ~/file01.txt}

clearing this and replacing it with the next text file has me stumped. I tried a bash script

#!/bin/bash

while [ true ]; do

clear
cat file01.txt
sleep 30
clear
cat file02.txt
sleep 30
clear
cat file03.txt
sleep 30

done

(which works fine in stdout)

calling it with:

${exec ~/mytexts.sh}

but this seems to send the conky into a loop, loads of conkys created, and no display of conky at all, requiring a killall to clear up.

I want to "hand this over" to a non techie, who will only have to edit the text files once all is up and running, so a script seems the way to go.

Can anyone point me in the right direction with this one?

Last edited by Joe90 (2014-03-18 22:24:42)

Offline

Be excellent to each other!

#2 2014-03-18 21:55:07

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: [SOLVED!] Conky: display one text file after another and repeat

you could do it just in conky i would think

set your conky to an update interval of 30, or however long between switching files then use ${if_updatenr }
something like this

${if_updatenr 1}${exec cat file 1}${endif}${if_updatenr 2}${exec cat file 2}${endif}${if_updatenr 2}${exec cat file 3}${endif}

or you could make a single statement using ${else}

edit, oops i had my { in the wrong place

here it is with elses and numbers (i was testing), just change the numbers to exec commands smile

${if_updatenr 01}1${else}${if_updatenr 02}2${else}${if_updatenr 03}3${endif}${endif}${endif}

Last edited by mrpeachy (2014-03-18 22:12:17)

Offline

#3 2014-03-18 22:24:08

Joe90
#! Junkie
Registered: 2013-10-10
Posts: 337

Re: [SOLVED!] Conky: display one text file after another and repeat

Fantastic! Works perfectly. Many thanks MrPeachy. Peachy indeed!

Just for completeness, the edits made to my conky as follows:

# interval

update_interval 30.0

# under "TEXT"

${if_updatenr 01}${exec cat file01.txt}${else}\
${if_updatenr 02}${exec cat file02.txt}${else}\
${if_updatenr 03}${exec cat file03.txt}${endif}${endif}${endif}

Not needed for this particular project, but is it possible to add an interval in the long line under TEXT, perhaps with execi?

Last edited by Joe90 (2014-03-18 22:25:10)

Offline

#4 2014-03-18 22:28:54

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: [SOLVED!] Conky: display one text file after another and repeat

yes, you can still use execi, but the interval will be multiplied by the conky interval
so execi 2 would be every 2 conky cycles, or in the above case 60 seconds

depends on what the interval would be for
if you mean a gap between the repeats you could add a fourth if_updatenr that outputs nothing

Offline

#5 2014-03-18 22:43:19

Joe90
#! Junkie
Registered: 2013-10-10
Posts: 337

Re: [SOLVED!] Conky: display one text file after another and repeat

Hmmm, tried changing update interval back to 1.0, then editing "exec" to "execi 30" in the long line. This didn't work and each file showed up for one second, in line with the update interval. Obviously I misunderstood  neutral

Offline

#6 2014-03-18 22:48:12

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: [SOLVED!] Conky: display one text file after another and repeat

if you are wanting an update interval of 1 second, for example to display cpu usage
and in the same conky want your files displayed with the delay... that is going to take a bit more doing
but should still be possible

Offline

#7 2014-03-18 22:52:05

Joe90
#! Junkie
Registered: 2013-10-10
Posts: 337

Re: [SOLVED!] Conky: display one text file after another and repeat

Thought so  smile  No worries. I'll start reading all 287 pages (and counting) of the conky thread  wink
Thanks for your help.

Last edited by Joe90 (2014-03-18 22:52:51)

Offline

#8 2014-03-18 23:35:37

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: [SOLVED!] Conky: display one text file after another and repeat

if you dont mind burning some cpu cyces you could still use if_updatenr with a 1 second interval

${if_updatenr 01}${exec cat file01.txt}${else}\
${if_updatenr 02}${exec cat file01.txt}${else}\
...
${if_updatenr 29}${exec cat file01.txt}${else}\
${if_updatenr 30}${exec cat file02.txt}${else}\
...
${if_updatenr 59}${exec cat file02.txt}${else}\
${if_updatenr 60}${exec cat file03.txt}${else}\
etc
${endif}${endif}${endif}...lots of endifs!

ie have an if_updatener for ever second (every conky cycle)
this does mean running the cat command every second, bit it isnt that expensive

other than that it would need to be a script
bash perhaps, but my bash is no good smile

Last edited by mrpeachy (2014-03-18 23:36:33)

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo