You are not logged in.

#1 2019-07-25 00:45:40

MrEd
Member
Registered: 2018-06-26
Posts: 27

[SOLVED] Conky Question ${if_existing text in file}

Is it possible to find text in a file with grep maybe
to do this?

#${if_up enp3s0}      ############################
${if_existing grep "keyword" /home/myfile.txt}


${else}
do this

${endif}

Last edited by MrEd (2019-08-06 16:49:15)


MSI B85M-G43 * Dualcore 3.3GHz *-12GB ram * GT740 4GB video * Logitech USB-Marble Mouse=Trackball * System - ArchLinux-Antergos, KDE Plasma Desktop - Conky 1.10

Offline

#2 2019-07-25 02:45:13

MrEd
Member
Registered: 2018-06-26
Posts: 27

Re: [SOLVED] Conky Question ${if_existing text in file}

This works to a point.
If you have an existing image, try this.

${if_existing /home/major/.conky/My_conky/edweather/pcloudy.gif}
Now: ${color 00FF00}${exec cat /home/major/.conky/My_conky/edweather/rssweather.txt | awk -F "[><]" '/<description>/{print $3}' | awk 'NR==3{print $description}' | fold -w50 -s}${color}

${else}
Tonight:${color 00FF00}${exec cat /home/major/.conky/My_conky/edweather/rssweather.txt | awk -F "[><]" '/<Tonight>/{print $3}' | awk 'NR==3{print $description}' | fold -w50 -s}${color}

${endif}

The problem here is under $else
All that happens is it prints "Tonight:" in the conky window and does not complete the rest of the code as it does under ${if_existing blah blah}



To test, just change the image name.

Last edited by MrEd (2019-07-25 03:03:19)


MSI B85M-G43 * Dualcore 3.3GHz *-12GB ram * GT740 4GB video * Logitech USB-Marble Mouse=Trackball * System - ArchLinux-Antergos, KDE Plasma Desktop - Conky 1.10

Offline

#3 2019-07-25 03:05:36

MrEd
Member
Registered: 2018-06-26
Posts: 27

Re: [SOLVED] Conky Question ${if_existing text in file}

DISREGARD last post, I had something named wrong...duh me

I was trying a working example thing.
First post still stands at this point.
Thanks

Last edited by MrEd (2019-07-25 03:07:17)


MSI B85M-G43 * Dualcore 3.3GHz *-12GB ram * GT740 4GB video * Logitech USB-Marble Mouse=Trackball * System - ArchLinux-Antergos, KDE Plasma Desktop - Conky 1.10

Offline

#4 2019-08-04 17:10:03

ohnonot
...again
Registered: 2015-09-29
Posts: 3,988
Website

Re: [SOLVED] Conky Question ${if_existing text in file}

MrEd wrote:

First post still stands at this point.

MrEd wrote:

Is it possible to find text in a file with grep maybe
to do this?

#${if_up enp3s0}      ############################
${if_existing grep "keyword" /home/myfile.txt}

The answer is in conky's documentation; under "Conky Objects" it says:

if_existing file (string)
if FILE exists, display everything between if_existing and the matching $endif. The optional second parameter checks for FILE containing the specified string and prints everything between $if_existing and the matching $endif.

- in other words, this should work (not tested):

${if_existing /home/myfile.txt "keyword"}

Offline

#5 2019-08-06 16:48:47

MrEd
Member
Registered: 2018-06-26
Posts: 27

Re: [SOLVED] Conky Question ${if_existing text in file}

AH, Thankyou!

I was having a hard time deciphering what I needed to do.


MSI B85M-G43 * Dualcore 3.3GHz *-12GB ram * GT740 4GB video * Logitech USB-Marble Mouse=Trackball * System - ArchLinux-Antergos, KDE Plasma Desktop - Conky 1.10

Offline

Board footer

Powered by FluxBB