joewing / jwm

Joe's Window Manager
http://joewing.net/projects/jwm
MIT License
520 stars 84 forks source link

City temperature with wttr.in #307

Closed holmeslinux closed 8 years ago

holmeslinux commented 8 years ago

hi guys, i want to implement this $ curl wttr.in in the menu JWM and does not work! however, the terminal works, do you have any idea?

obs.: in https://github.com/chubin/wttr.in

vlw fwi, Holmes :)

technosaurus commented 8 years ago

Its actually much simpler than what you think.

Just use the dynamic tag with exec: and have your script format the curl output to the appropriate xml.

One thing I would recommend though, is to cache the data for a certain period of time so that you don't have to wait for the server every time you open the menu.

holmeslinux commented 8 years ago

hi @technosaurus i add exec sakura curl wttr.in in menu and not work!

vlw fwi, Holmes :)

ghost commented 8 years ago

exec:sakura -e "bash -c 'curl wttr.in'" Should give better results for you OR if in the menu

<Program label="Holmes Weather" icon="terminal">sakura -e "bash -c 'curl wttr.in'</Program>
holmeslinux commented 8 years ago

hi @Israel- i tested here, but the terminal closes! also I tested other combinations and it is the same...

vlw fwi, Holmes :)

ghost commented 8 years ago

ahhhh... maybe try sakura -e "bash -c 'curl wttr.in;exec bash'

holmeslinux commented 8 years ago

sakura -e "bash -c 'curl wttr.in;exec bash'"

hi @Israel- works! would you explain for me to understand: -e and bash -c thank you so much...

vlw fwi, Holmes :)

ghost commented 8 years ago

sure thing @holmeslinux sakura -e is like most terminal emulators xterm -e OR x-terminal-emulator -e do the same thing. the -e specifies a command to Execute

the " shows the command to execute. bash -c is similar to what JWM does to execute things from menus (Joe uses sh ) bash -c is bash -Command I enclose the bash command in ' to show the entire command being executed by the shell. the final part ;exec bash simply executes the bash shell (keeping the terminal open) the ';' will allow the exec bash to run even if the command fails (so you can find the error, or if you are doing something like echo "Hi" OR ls) I hope that is clear enough. And I think this issue can be closed now :smile:

holmeslinux commented 8 years ago

thank you @Israel- for the explanation. now I understand!

yes can be closed now...

vlw fwi, Holmes :)

technosaurus commented 8 years ago

How about starting a wiki page: "jwm helpers" for this kind of info.

joewing commented 8 years ago

A wiki would be nice for this type of thing, but it's not something I really want to maintain. If someone wants to start one, please feel free.