Subject: FVWM: Script output into menu

From: Mikko Heiskanen <[email-masked]>
Date: Mon, 14 Feb 2005 01:25:00 +0200

Hi list,
I have a simple shellscript, which output I would like to have made into
a menu. Reading from the manpage, I understand this should be possible
to do.
the shellscript is as follows:

#!/bin/sh
# fbsd-fvwm
echo "AddToMenu $1 $1 title"
for i in /usr/ports/$1/*; do
case $1 in
editors)
echo "+ %mini.edit.xpm%\"$(basename $i)\" Exec exec $(basename $i)
;;
audio)
echo "+ %mini.sound.xpm%\"$(basename $i)\" Exec exec $(basename $i)
;;
(and so on)
esac
done

Now, I try to add it to fvwmrc like this:
addtofunc makemenu
+ I Exec fbsd-fvwm $0
^^ taken from manpage for make-directory-menu or something similiar.

And to menu:
addtomenu somemenu
+ MissingSubmenuFunction makemenu
+ "editors" Popup editors

And I don't get any output, whilst running it on shell provides right
output. What am I missing?

Thanks,
Mikko
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Frank Gruellich <[email-masked]>
Date: Mon, 14 Feb 2005 09:26:28 +0100

> Hi list,

Hello,

> a menu.
> [script]

You miss PipeRead.  You start the script and its output is send to
stdout of fvwm (check the console you ran fvwm from or tail -f your
~/.xsession-errors).  If you want fvwm to read your output you should
use PipeRead.

HTH,
 regards, Frank.
-- 
,------------------------.------------------------.--------------------.
| Chemnitzer Linux-Tage  | "Linux loves desktops" ' [email-masked] |
| March, 5th + 6th, 2005 |       http://chemnitzer.linux-tage.de/      |
'------------------------'---------------------------------------------'
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Mikko Heiskanen <[email-masked]>
Date: Tue, 15 Feb 2005 22:00:44 +0200

> ~/.xsession-errors).  If you want fvwm to read your output you should
Thanks! Now it is working.
I decided to share this with the list as at least FreeBSD users could
benefit from it nicely (Maybe gentoo users, too?).

AddToFunc makedeinstallmenu
+ I DestroyMenu Recreate deinstallmenu
+ I AddToMenu deinstallmenu
+ I PipeRead 'for i in $(pkg_info -a -o -q|sort); \
do echo "+ %mini.file.xpm%\"$i\" Exec cd /usr/ports/$i; \
    $[TER] -T \'Deinstalling $i\' -e make deinstall"; done'

DestroyMenu deinstallmenu
AddToMenu deinstallmenu
+ DynamicPopupAction makedeinstallmenu

addtomenu management
+ "deinstall" Popup deinstallmenu

A couple of thoughts: ports-tree could be located somewhere else than
/usr/ports; but /usr/ports is the default on free- & openbsd.
If one has lot of programs installed, the menu could be quite long. I'm
open to ideas how to make ports-tree categories as submenus of installed
programs.
Why I used cd /port; make deinstall, and not pkg_delete or something
else? Because of the nifty "changing to root credentials" which is only
available in this method.

About the subtree-idea: a friend of mine gathered the following external
script:
#!/bin/sh

category=""

for line in $(pkg_info -a -o -q|sort); do
  curcat=$(echo $line | awk -F '/' '{ print $1 }')
  app=$(echo $line | awk -F '/' '{ print $2 }')
  
  if [ "$curcat" != "$category" ]; then
    echo "AddToMenu deinstallmenu"
    echo "+ %some.icon%\"$curcat\" Popup $curcat"
    echo "AddToMenu $curcat"
    category=$curcat
  fi
  if [ -n "$app" ]; then
    echo "+ %some.icon%\"$app\" Exec $app"
  fi
done

However, it gets generated multiple times for some odd reason.
If one moves mouse all the time during the execution, then it is created
only once like it should. But if one just waits for menu popup, it gets
generated multiple times. Also, naturally, the execution time is
somewhat longer.

More info about the ports-tree: http://www.freebsd.org/ports
Example output of pkg_info -q -o -a|sort:
archivers/zip
archivers/zoo
www/mozilla
www/netscape

Mikko

---

From: Mikko Heiskanen <[email-masked]>
Date: Tue, 15 Feb 2005 23:11:43 +0200

>     echo "+ %some.icon%\"$app\" Exec $app"
Nevermind, the above script is working as it should; I was missing an
'I' from my config, hence menus multiplying every run. One glitch still
remains with the above; after generation, the menu isn't popped up
automatically; one needs to move the cursor for menu to popup.

Mikko