Quick PipeRead Question

I’m trying to write a weather checking script to put into my fvwmRootMenu. I know I have to use piperead to do it, but I can’t figure it out for the life of me.

The script right now downloads weather info and greps out the temperature and pipes that into its into a weather.txt file. I just need to the Menu to dynamically read the weather.txt file, but I can’t get it to work. Any help would be great. Thanks!

Something like this:

DestroyMenu foo
AddToMenu foo
+ MissingSubMenuFunctiono myfunction foo

Which will then run that “myfunction” which you can define as whatever you want:

DestroyFunc myfunction
AddToFunc myfunction
+ I DestroyMenu "$0"
+ I AddToMenu "$0"
+ I + DynamicPopDownAction DestroyMenu "$0"
+ I PipeRead ....   #from your weather.txt file

Note that for the menu definition, I pass the name of the menu (“foo”) as a formal parameter.

– Thomas Adam

Still Can’t get it to work. This is basically what’s going on:

I have the Weather2.sh script:#!/bin/bash cat /home/brad/.weather.txt | grep Temperature

And So I’m trying to get the menu to read this code, so, using fvwm-console I’ve been typing:

[code]DestroyMenu WeatherCheck
AddToMenu WeatherCheck

  • MissingSubMenuFunction FvwmWeather WeatherCheck
    DestroyFunc FvwmWeather
    AddToFunc FvwmWeather
  • I DestroyMenu “$0”
  • I AddToMenu “$0”
  • I + DynamicPopDownAction DestroyMenu “$0”
  • I PipeRead /home/brad/weather2.sh[/code]
    Then I want it to be piped to the root menu so, :[code]
    AddToMenu FvwmRootMenu
  • WeatherCheck[/code]


AddToMenu FvwmRootMenu
+ "WeatherCheck" Popup WeatherCheck
AddToMenu FvwmRootMenu
+ Function FvwmWeather WeatherCheck

But none of them work…

Then you must make sure this script echo’s back FVWM syntax to add these entries to your menu. If the file just contains the elements for the menu entry, then you will need to use PipeRead to do it.

– Thomas Adam

I’m not sure I follow. I guess I don’t understand where else I would need to add the piperead to get the fvwm syntax correct. Could you provide and example maybe? Thanks for the help, by the way.

Here is an example that display date on a menu.

[code]AddToMenu Test

  • DynamicPopupAction Function weather

DestroyFunc weather
AddToFunc weather

  • I DestroyMenu recreate Test
  • I Piperead ‘echo AddToMenu Test \"date\"’

I gues if you replace date by your script Weather2.sh, it should work (provinding it is in the path, I had strange issue with that, and you may have to put full path to it)[/code]

Pem has done it in his config. Try to have a look at the code, it will give you some new idea.


Zonk. You’re suggestion worked perfectly. Would you mind explaining to me what the \\ are for? I can’t seem to figure out why they make the script work. Thanks.

They’re escaping the command substitution, so that the interpolation doesn’t happen too early; else you’ll get odd results. That way, when the line has ran, it’s the date that’s “echoed” back. Anything else passed to “AddToMenu” before hand is just nonsense until the other operands working on it have done their job.

– Thomas Adam