|
From: Simon C. <co...@si...> - 2015-08-21 05:02:23
|
Hello, I have set up conky to display important tasks from my todo.txt text file. This text file has one task for each line (cf. todotxt.com). I have created a python script to filter items with due dates. If tasks exist, the script sends the task to stdout. The script works well. I can get customized lists of overdue tasks, tasks due today and future tasks. These subsets of the task file are positioned under appropriate titles. The problem I have is that I can prevent the script from printing to stdout but can't get conky not to print the title if nothing is returned. I have looked around but can't find an example of how to do this based on the output of a script. I have created exit codes (0, a list produced; 1 no list available) but I can't seem to capture these events. Does anyone have an idea or can point me to a working example? At the crux of it, I want my titles to disappear when no information is returned to stdout by a script or alternatively, when a unsuccessful exit code is detected. -- Cheers Simon |
|
From: Phil <n0...@us...> - 2015-08-21 10:21:52
|
On Fri, Aug 21, 2015 at 02:08:08PM +1000, Simon Cropper wrote: > Hello, > > I have set up conky to display important tasks from my todo.txt text > file. This text file has one task for each line (cf. todotxt.com). > > I have created a python script to filter items with due dates. If tasks > exist, the script sends the task to stdout. > > The script works well. I can get customized lists of overdue tasks, > tasks due today and future tasks. > > These subsets of the task file are positioned under appropriate titles. > The problem I have is that I can prevent the script from printing to > stdout but can't get conky not to print the title if nothing is > returned. I have looked around but can't find an example of how to do > this based on the output of a script. > > I have created exit codes (0, a list produced; 1 no list available) but > I can't seem to capture these events. > > Does anyone have an idea or can point me to a working example? You could use $if_match to check for empty output at least. IIRC, something like ${if_match ${exec script.sh} != ""} could work. > At the crux of it, I want my titles to disappear when no information is > returned to stdout by a script or alternatively, when a unsuccessful > exit code is detected. AFAIK, there is no way to react upon return values. As a clean solution (which does not lead to complete mess in conkyrc, I would put this all into a wrapper script, and pass it the title to display as a parameter: | #!/bin/bash | title="$1" | shift | items="$(script.sh "$@")" | [[ -n $items ]] || exit 0 | cat <<EOF | $title | \$hr | $items | EOF call with ${execp wrapper.sh "The Title" <script args>}. Does that make sense? Cheers, Phil |
|
From: Simon C. <co...@si...> - 2015-08-21 16:00:02
|
see in-line comments On 21/08/15 20:03, Phil wrote: > On Fri, Aug 21, 2015 at 02:08:08PM +1000, Simon Cropper wrote: >> Hello, >> >> I have set up conky to display important tasks from my todo.txt text >> file. This text file has one task for each line (cf. todotxt.com). >> >> I have created a python script to filter items with due dates. If tasks >> exist, the script sends the task to stdout. >> >> The script works well. I can get customized lists of overdue tasks, >> tasks due today and future tasks. >> >> These subsets of the task file are positioned under appropriate titles. >> The problem I have is that I can prevent the script from printing to >> stdout but can't get conky not to print the title if nothing is >> returned. I have looked around but can't find an example of how to do >> this based on the output of a script. >> >> I have created exit codes (0, a list produced; 1 no list available) but >> I can't seem to capture these events. >> >> Does anyone have an idea or can point me to a working example? > You could use $if_match to check for empty output at least. IIRC, > something like ${if_match ${exec script.sh} != ""} could work. Yeah, you would think this would work but it doesn't. I tried returning a single character ("#", "1", "-") instead of the error code but conky does not work with the != operand. Following your comment above I tried again and managed to muddle something together. The python routine prints the integer 1 to stdout if no list is available and conky uses ${if_match ${exec script.sh} != 1}. Wierdly if the script prints the character "1" to stdout conky still only works if you use ${if_match ${exec script.sh} != 1}. Obviously conky automatically converts the numbers characters (string or not) in stdout to integers. > >> At the crux of it, I want my titles to disappear when no information is >> returned to stdout by a script or alternatively, when a unsuccessful >> exit code is detected. > AFAIK, there is no way to react upon return values. As a clean solution > (which does not lead to complete mess in conkyrc, I would put this all > into a wrapper script, and pass it the title to display as a parameter: > > | #!/bin/bash > | title="$1" > | shift > | items="$(script.sh "$@")" > | [[ -n $items ]] || exit 0 > | cat <<EOF > | $title > | \$hr > | $items > | EOF > > call with ${execp wrapper.sh "The Title" <script args>}. Does that make > sense? Makes perfect sense. Had tried to do this already but found I could not pass the ${color} and ${hr} commands for the title. I tried all sorts of things but all 'commands' were just printed to stdout as written. > Cheers, Phil > > ------------------------------------------------------------------------------ > _______________________________________________ > Conky-users mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/conky-users -- Cheers Simon |
|
From: Phil <n0...@us...> - 2015-08-22 00:35:35
|
On Sat, Aug 22, 2015 at 01:59:46AM +1000, Simon Cropper wrote: > see in-line comments > > On 21/08/15 20:03, Phil wrote: > > On Fri, Aug 21, 2015 at 02:08:08PM +1000, Simon Cropper wrote: > >> Hello, > >> > >> I have set up conky to display important tasks from my todo.txt text > >> file. This text file has one task for each line (cf. todotxt.com). > >> > >> I have created a python script to filter items with due dates. If tasks > >> exist, the script sends the task to stdout. > >> > >> The script works well. I can get customized lists of overdue tasks, > >> tasks due today and future tasks. > >> > >> These subsets of the task file are positioned under appropriate titles. > >> The problem I have is that I can prevent the script from printing to > >> stdout but can't get conky not to print the title if nothing is > >> returned. I have looked around but can't find an example of how to do > >> this based on the output of a script. > >> > >> I have created exit codes (0, a list produced; 1 no list available) but > >> I can't seem to capture these events. > >> > >> Does anyone have an idea or can point me to a working example? > > You could use $if_match to check for empty output at least. IIRC, > > something like ${if_match ${exec script.sh} != ""} could work. > > Yeah, you would think this would work but it doesn't. > > I tried returning a single character ("#", "1", "-") instead of the > error code but conky does not work with the != operand. > > Following your comment above I tried again and managed to muddle > something together. The python routine prints the integer 1 to stdout if > no list is available and conky uses ${if_match ${exec script.sh} != 1}. > Wierdly if the script prints the character "1" to stdout conky still > only works if you use ${if_match ${exec script.sh} != 1}. Obviously > conky automatically converts the numbers characters (string or not) in > stdout to integers. > > > > >> At the crux of it, I want my titles to disappear when no information is > >> returned to stdout by a script or alternatively, when a unsuccessful > >> exit code is detected. > > AFAIK, there is no way to react upon return values. As a clean solution > > (which does not lead to complete mess in conkyrc, I would put this all > > into a wrapper script, and pass it the title to display as a parameter: > > > > | #!/bin/bash > > | title="$1" > > | shift > > | items="$(script.sh "$@")" > > | [[ -n $items ]] || exit 0 > > | cat <<EOF > > | $title > > | \$hr > > | $items > > | EOF > > > > call with ${execp wrapper.sh "The Title" <script args>}. Does that make > > sense? > > Makes perfect sense. Had tried to do this already but found I could not > pass the ${color} and ${hr} commands for the title. I tried all sorts of > things but all 'commands' were just printed to stdout as written. But you did notice how I carefully put ${execp} in my example above, didn't you? If so, maybe you forgot to escape the dollar sign from being expanded by the script interpreter. |
|
From: Simon C. <co...@si...> - 2015-08-22 00:49:23
|
On 22/08/15 10:36, Phil wrote: > On Sat, Aug 22, 2015 at 01:59:46AM +1000, Simon Cropper wrote: >> see in-line comments >> >> On 21/08/15 20:03, Phil wrote: >>> On Fri, Aug 21, 2015 at 02:08:08PM +1000, Simon Cropper wrote: >>>> Hello, >>>> >>>> I have set up conky to display important tasks from my todo.txt text >>>> file. This text file has one task for each line (cf. todotxt.com). >>>> >>>> I have created a python script to filter items with due dates. If tasks >>>> exist, the script sends the task to stdout. >>>> >>>> The script works well. I can get customized lists of overdue tasks, >>>> tasks due today and future tasks. >>>> >>>> These subsets of the task file are positioned under appropriate titles. >>>> The problem I have is that I can prevent the script from printing to >>>> stdout but can't get conky not to print the title if nothing is >>>> returned. I have looked around but can't find an example of how to do >>>> this based on the output of a script. >>>> >>>> I have created exit codes (0, a list produced; 1 no list available) but >>>> I can't seem to capture these events. >>>> >>>> Does anyone have an idea or can point me to a working example? >>> You could use $if_match to check for empty output at least. IIRC, >>> something like ${if_match ${exec script.sh} != ""} could work. >> Yeah, you would think this would work but it doesn't. >> >> I tried returning a single character ("#", "1", "-") instead of the >> error code but conky does not work with the != operand. >> >> Following your comment above I tried again and managed to muddle >> something together. The python routine prints the integer 1 to stdout if >> no list is available and conky uses ${if_match ${exec script.sh} != 1}. >> Wierdly if the script prints the character "1" to stdout conky still >> only works if you use ${if_match ${exec script.sh} != 1}. Obviously >> conky automatically converts the numbers characters (string or not) in >> stdout to integers. >> >>>> At the crux of it, I want my titles to disappear when no information is >>>> returned to stdout by a script or alternatively, when a unsuccessful >>>> exit code is detected. >>> AFAIK, there is no way to react upon return values. As a clean solution >>> (which does not lead to complete mess in conkyrc, I would put this all >>> into a wrapper script, and pass it the title to display as a parameter: >>> >>> | #!/bin/bash >>> | title="$1" >>> | shift >>> | items="$(script.sh "$@")" >>> | [[ -n $items ]] || exit 0 >>> | cat <<EOF >>> | $title >>> | \$hr >>> | $items >>> | EOF >>> >>> call with ${execp wrapper.sh "The Title" <script args>}. Does that make >>> sense? >> Makes perfect sense. Had tried to do this already but found I could not >> pass the ${color} and ${hr} commands for the title. I tried all sorts of >> things but all 'commands' were just printed to stdout as written. > But you did notice how I carefully put ${execp} in my example above, > didn't you? If so, maybe you forgot to escape the dollar sign from being > expanded by the script interpreter. "But you did notice how I carefully put ${execp} in my example above, didn't you?" Actually no. Missed that! Makes all the difference. You second option works as well :). Thanks Phil. > > ------------------------------------------------------------------------------ > _______________________________________________ > Conky-users mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/conky-users -- Cheers Simon Simon Christopher Cropper Mobile: 0431 821 566 Email: co...@si... <mailto:co...@si...> Online CV: http://www.simonchristophercropper.com/ LinkedIn: http://au.linkedin.com/in/simonchristophercropper/ ResearchGate: https://www.researchgate.net/profile/Simon_Cropper3 |