Create a panel with .desktop files

I wrote a little perl script, you need the DesktopEntry lib

you just have to create a directory in .fvwm: panel.desktop
and put inside some *.desktop files don’t forget to change the icon to a png file because fvwm don’t know svg :slight_smile:. .desktop files are well know by Nautilus (he didn’t show up the .desktop extension by default) you can then easly change the icon and the commands by right clicking on the file.

{ ButtonName file.desktop}
put this in ~/.fvwm/scripts/

# $FvwmButton's name $URI to the a .desktop file

use File::DesktopEntry;

my $entry = File::DesktopEntry->new_from_file("$ARGV[1]" );

die $entry->get_value('Name')." isn't an application\n"

unless $entry->get_value('Type') eq 'Application';
print "*$ARGV[0]: (1x1 , Icon ".$entry->get_value('Icon').", Action(Mouse 1) `Exec ".$entry->get_value('Exec')."`)"

Somewhere in your fvwms config files, BuildPanel take 2 arguments $0:FvwmButton’s name $1:location of the .desktop files

DestroyFunc BuildPanel
AddToFunc   BuildPanel
+ I Test (f $1/$0.fvwm) Exec exec rm $1/$0.fvwm
+ I PipeRead 'for i in $1/*.desktop; do $[FVWM_USERDIR]/scripts/ $0 $i >> $1/$0.fvwm; done;'
+ I Read $1/$0.fvwm

AddToFunc StartFunction 
+ I BuildPanel MesBoutons $[FVWM_USERDIR]/panel.desktop #add to FvwmButtons MesBoutons the links present in the directory $[FVWM_USERDIR]
+ I Module FvwmButtons -g 50x768-0+0 MesBoutons

You can adapt the perl script so that it generates Menu entry instead of Button entry.

Next milestone: implement the desktop directory/menu/etc… you will be able to change the panel/menu really easly with alacarte (gnome appliction).

hope it helps.

[color=blue]Removed an ‘‘echo’’ builtin which serves no purpose. – TA[/color]

I am sure this has some really useful application somewhere, although I can’t see it myself. Nevertheless, well done for doing this.

Portability point one: I can only shudder to imagine what $[fvwm_home] expands to. No, wait, I can guess: $HOME/.fvwm, right? Well, FVWM will typically define this location for you as $[FVWM_USERDIR] – so you ought to use this here. Imagine how many people don’t have the command:

SetEnv fvwm_home $[HOME]/.fvwm

… in their config. Indeed, given that it’s a redundant and pointless use of environment variables, you win my UUOS award (Useless Use of SetEnv) and thus can read this:

Secondly, it would probably be easier to try and remove the file only if it exists. With FVWM 2.5.X, you can use:

+ I Test (f $[FVWM_USERDIR]/MesBoutons.fvwm) Exec exec rm $[FVWM_USERDIR]/MesBoutons.fvwm

If you were in FVWM 2.4.X, you would have to use PipeRead:

+ I PipeRead '[ -e $[FVWM_USERDIR]/MesBoutons.fvwm ] &&  rm $[FVWM_USERDIR]/MesBoutons.fvwm'

I’m not quite sure why you’re sending an “exec” request back to FVWM here. You’re already at the shell level. You don’t need to echo the request or exec it, just call the script directly with its arguments. You also don’t need the “Nop” command. I don’t quite know what you think it’s achieving in this context, other than nothing.

Again, see the $[FVWM_USERDIR] stuff from above.

– Thomas Adam

Thanks for your tips and corrections I updated the script and added parameters to the BuildPanel function in order to make it more portable.

Well, for a power user like you :wink: it seems… useless but it is more easy to tweak the panel with this for nb. And if I (or someone else) can get full support of the freedesktop spec, menu and panel will be really more easy to build.

The perl script is really minimal, for example it would be interresting to be able to sort the icon in a certain order… here I dunno how he manage this maybe alphabetically.