Subject: FVWM: Conditionally adding menu items

From: Scott Smedley <[email-masked]>
Date: Fri, 26 Mar 2004 18:34:53 +1100

Is there a better way (less code?) of conditionally adding menu items
to a menu than this?

AddToMenu "[email-masked]@" "MuLTiMeDia" Title
m4_syscmd(type xine >& /dev/null)
m4_ifelse(m4_sysval, 0,
+	"&XiNe (DVD Player)%xine.xpm%"		Exec exec xine
)
m4_syscmd(type gmplayer >& /dev/null)
m4_ifelse(m4_sysval, 0,
+	"&MPLaYeR (DVD Player)%xine.xpm%"	Exec exec gmplayer
)
m4_syscmd(type xmms >& /dev/null)
m4_ifelse(m4_sysval, 0,
+	"XMMS (MP&3 PLaYeR)%xmmsMini.xpm%"	Exec exec xmms
)
m4_syscmd(type dvdrip >& /dev/null)
m4_ifelse(m4_sysval, 0,
+	"&dvd::rip"				Exec exec dvdrip
)

SCoTT. :)
--
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: "F. Kater" <[email-masked]>
Date: Fri, 26 Mar 2004 09:27:59 +0100

> Is there a better way (less code?) of conditionally adding menu items

Sorry, no answer, I am looking for the same thing. :-)

As I have to administrate fvwm on several boxes, I'd very much like to
have something like pointing a menu to a directory in which all
programs/items to be shown or hidden are stored as links or something
similar.
--
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: Uwe Pross <[email-masked]>
Date: Fri, 26 Mar 2004 09:41:53 +0100

Hi there,

On 26 Mar 2004 at 18:34:53 +1100, Scott Smedley wrote:

> Is there a better way (less code?) of conditionally adding
> menu items to a menu than this?

Currently I use:

...
PipeRead "test -x /opt/mozilla-sc-1.5/mozilla/mozilla && echo  '+ \"Mozilla %mini.mozilla.xpm%\" Function FuncStartProgram /opt/mozilla-sc-1.5/mozilla/mozilla'"
...

which is quite ugly but does not need a preprocessor. 

Since this is a very common problem it would be nice if this
would be part of the fvwm configuration language.

Cheers, Uwe
-- 
  ,_,   For personal reply/mail put "fvwm"
 (O,O)  in the subject.
 (   )  Otherwise your mail is discarded by a filter.
=-"-"-= http://www.tu-chemnitz.de/~uwp
--
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: Tavis Ormandy <[email-masked]>
Date: Fri, 26 Mar 2004 09:33:36 +0000

--On Friday, March 26, 2004 09:41:53 +0100 Uwe Pross
<[email-masked]> wrote:

> PipeRead "test -x /opt/mozilla-sc-1.5/mozilla/mozilla && echo  '+
> \"Mozilla %mini.mozilla.xpm%\" Function FuncStartProgram
> /opt/mozilla-sc-1.5/mozilla/mozilla'" ...
> 

You could make it more generic,

AddToFunc CondAdd I Test (f $0) AddToMenu $1 %$2%$3 Exec $0

Then you just need to 

CondAdd /usr/bin/mozilla Programs mozilla.xpm Mozilla
CondAdd /usr/bin/netscape Programs netscape.xpm Netscape
CondAdd /usr/X11R6/bin/xterm Programs xterm.xpm Terminal
...

to add applications to Programs menu if they exist...

doesnt look so untidy :)

-- 
-------------------------------------
[email-masked] | finger me for my gpg key.
-------------------------------------------------------

---

From: Uwe Pross <[email-masked]>
Date: Fri, 26 Mar 2004 10:54:34 +0100

Hi there,

> CondAdd /usr/bin/mozilla Programs mozilla.xpm Mozilla

Have you tested this code? The man page (2.5.8.)  does not
say anything about "Test (f ...)".

Cheers, Uwe

---

From: Tavis Ormandy <[email-masked]>
Date: Fri, 26 Mar 2004 10:05:31 +0000

> say anything about "Test (f ...)".

Interesting! It seems to be undocumented, works just fine though (just
double checked).

I'm not sure how I found out about this feature, it should be documented
though, i've found it useful a few times :)

---

From: Remko Troncon <[email-masked]>
Date: Fri, 26 Mar 2004 11:08:53 +0100

> programs/items to be shown or hidden are stored as links or something

If you have the luck to be running Debian, you can add a menuitem:
..
+ "Debian"           Popup "/Debian"
..

This menu will contain all installed applications, grouped in several
categories.

cheers,
Remko

---

From: Scott Smedley <[email-masked]>
Date: Fri, 26 Mar 2004 22:49:39 +1100

Hi Tavis,

> CondAdd /usr/X11R6/bin/xterm Programs xterm.xpm Terminal

This works great!

AddToMenu "[email-masked]@" "MuLTiMeDia" Title
Test (x xine) AddToMenu Multimedia "&XiNe (DVD Player)%xine.xpm%" Exec exec xine
Test (x xcdroast) AddToMenu Multimedia "XCD&RoaST" Exec xhost + && exec xcdroast
Test (x gtcd) AddToMenu Multimedia "&CD PLaYeR%cdPlayer.xpm%" Exec exec gtcd
Test (x dvdrip) AddToMenu Multimedia "&dvd::rip" Exec exec dvdrip

I like that $PATH is searched to find if a binary exists. (ie. I don't
have to specify the exact path to each binary.)

SCoTT. :)

---

From: "F. Kater" <[email-masked]>
Date: Fri, 26 Mar 2004 13:59:29 +0100

> + "Debian"           Popup "/Debian"

That's great but I am running gentoo. I wonder however why this would
work only on Debian? Could you explain what Debian does to provide its
menus so easily and how this tecnique is integrated into fvwm?
--
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: Thomas Adam <[email-masked]>
Date: Fri, 26 Mar 2004 13:00:30 +0000 (GMT)

> menus so easily and how this tecnique is integrated into fvwm?

Debian has a menu package called 'menu', whereby authors of packages, can
add a menu 'hook' file so that their application appears in this common
menu structure. I personally find it a real pain in the bum, and much
prefer writing my own dynamic menus (mine are implemented with ruby).

-- Thomas Adam

=====
"The Linux Weekend Mechanic" -- http://linuxgazette.net
"TAG Editor"                 -- http://linuxgazette.net

"<shrug> We'll just save up your sins, Thomas, and punish 
you for all of them at once when you get better. The 
experience will probably kill you. :)"

 -- Benjamin A. Okopnik (Linux Gazette Technical Editor)

___________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html
--
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: Remko Troncon <[email-masked]>
Date: Fri, 26 Mar 2004 14:06:45 +0100

> menus so easily and how this tecnique is integrated into fvwm?

Debian packages normally contain a file describing what type of
application it is (graphical, games, ...), an icon for the application,
.. Each time a debian package is installed, Debian transforms this 
information using scripts into files for window managers which have use
for this. 

I'm not sure if other distributions have this, nor why they don't. But
i'm sure other people will respond to this ;)

cheers,
Remko

---

From: Remko Troncon <[email-masked]>
Date: Fri, 26 Mar 2004 14:13:24 +0100

> prefer writing my own dynamic menus (mine are implemented with ruby).

It's not really a pain in the bum, as you don't have to do anything
about it to use it. Besides, they're not really dynamic, so it doesn't cost
extra time to generate menus at runtime, whereas real dynamic menus do.

I personally don't use the Debian menus (maybe just for browsing what
applications are installed on a machine). Normally, you only have a small 
amount of applications you use, so you can just define your own statical menu
and see that the apps exist on all machines you work on. I have a separate
extra rc file per machine for adding machine-spoecific applications.

cheers,
Remko

---

From: Thomas Adam <[email-masked]>
Date: Fri, 26 Mar 2004 13:17:23 +0000 (GMT)

> extra time to generate menus at runtime, whereas real dynamic menus do.

You misunderstood me. I meant it is a pain in the sense that you have no
real control over where the menu entries are added. Hence the reason why,
as you say, building your own where you have a small number of
applications is more desirable.

-- Thomas Adam

=====

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 26 Mar 2004 20:18:45 +0000

> Test (x dvdrip) AddToMenu Multimedia "&dvd::rip" Exec exec dvdrip

The same thing, just shorter and more readable:

  AddToMenu "[email-masked]@" "MuLTiMeDia" Title
  Test (x xine)     + "&XiNe (DVD Player)%xine.xpm%" Exec exec xine
  Test (x xcdroast) + "XCD&RoaST"                    Exec xhost +; xcdroast
  Test (x gtcd)     + "&CD PLaYeR%cdPlayer.xpm%"     Exec exec gtcd
  Test (x dvdrip)   + "&dvd::rip"                    Exec exec dvdrip

Regards,
Mikhael.

---

From: Michelle Konzack <[email-masked]>
Date: Fri, 26 Mar 2004 23:12:21 +0100

>menus so easily and how this tecnique is integrated into fvwm?

In the most Packages is a file which define it...

The files are stored in /usr/lib/menu

Then after each installation of a package which provides 
a menu file the installationsprogram run 'update-menus'.

Greetings
Michelle

-- 
Registered Linux-User #280138 with the Linux Counter, http://counter.li.org/