Generating Fluxbox menus for VNC (Vinagre) connections

One of the lovely things about Fluxbox is the text-driven menu. One of the nice things about Vinagre (Gnome's VNC client) is the xml-based bookmarks file. Here's a handy script to create a Fluxbox submenu out of your Vinagre bookmarks:

  1.  
  2. #! /usr/bin/perl
  3.  
  4. use strict;
  5. use warnings;
  6. use XML::Simple;
  7. my <span class="katex math inline">HOME =</span>ENV{ HOME };
  8.  
  9. my <span class="katex math inline">bookmarks_file = "</span>HOME/.local/share/vinagre/vinagre-bookmarks.xml";
  10. my <span class="katex math inline">menu_file = "</span>HOME/.fluxbox/vnc_menu";
  11.  
  12. my <span class="katex math inline">xml = new XML::Simple (KeyAttr=>[]);
  13. my</span>data = <span class="katex math inline">xml->XMLin("</span>bookmarks_file");
  14.  
  15. open(MENU, "><span class="katex math inline">menu_file") || die "Error opening \$menu_file:</span>menu_file <span class="katex math inline">0";
  16.  
  17. print MENU "[begin]\n";
  18.  
  19. foreach my</span>b(@{<span class="katex math inline">data->{"item"}}){
  20. print MENU "[exec] (</span>b->{name}) {vinagre <span class="katex math inline">b->{host}:</span>b->{port}}\n";
  21. }
  22. print MENU "[end]\n";
  23. close MENU;
  24.