-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Shay,

I don't think fvwm supports this directly; but you can script it...

If you could wrap all of your apps from a script which keeps a tally of
number of times its been run, then you would be able to create such a 
menu.  Unfortunately, you would still need to restart fvwm before this 
menu is updated.  

So, I wrote an example script (attached as tally.rb, written in ruby, < 60
lines).  One must modify his .fvwm2rc file to use it:

<snip>
        AddToMenu SomeMenu "Apps"
        + "Browser" Exec exec tally.rb Browser
        + "Editor" Exec exec tally.rb Editor --some-flag
</snip>

Compared to the original:

<snip>
        AddToMenu SomeMenu "Apps"
        + "Browser" Exec exec Browser
        + "Editor" Exec exec Editor --some-flag
</snip>

This script will then generate an fvwm-style menu in some file (the
attached example uses ~/.fvwm_dynamic_menu), which you can include into a
.fvwm2rc (note that you need to restart before changes take effect):

<snip>
        Read .fvwm_dynamic_menu
</snip>

This program could also be used from the command line, i.e.

        [EMAIL PROTECTED] tally.rb echo Hello World
        Hello World

But this seems less useful; you cannot supply command line parameters in 
as useful a fashion in programs are launched from a menu.

Hope this helps.
- -- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  Nicholas Paul Johnson
  o nickjohnson \at\ virginia \dot\ edu
  o 3ebf10a7 subkeys.pgp.net
  o http://manjac.ath.cx/nick
  o "When all you've got is a hammer,
    everything looks like a nail.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

On Wed, 5 May 2004, Xavier Maillard wrote:

> On  4 May 2004, Shay wrote:
> 
> > Is  there a  way for  FVWM  to find  the most  used applications?  I'm
> > dreaming of a command line interface which automatically builds a root
> > menu for quick access to the most often used items.
> 
> Hummmm, dunno if it exists but I just love the idea yet :)
> 
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Made with pgp4pine 1.75-6

iD8DBQFAmG5DfnGNDj6/EKcRAtt0AJ9BNERSvc8h1NMQtmmJFx19Nmrx2gCeL1VE
5GbuxR0wJrVsH0/UtjSibIU=
=i6F+
-----END PGP SIGNATURE-----

#!/usr/local/bin/ruby -w

# files... don't need to change
dbFile = "#{ENV['HOME']}/.tally_db"
fvwmFile = "#{ENV['HOME']}/.fvwm_dynamic_menu"

# fvwm-name for the menu
menuName = 'FrequentMenu'

# determine name of command being executed
commandName = ARGV[0]

# update the program usage database

# load db and increment/insert the program we are running
db = { commandName => 1 }
begin
        IO.readlines(dbFile).each do |line|

                prog, count = line.split
                count = count.to_i
                count += 1 if prog == commandName       
                db[prog] = count
        end
rescue
end


begin
        # save the database
        File.open(dbFile, 'w') do |fout|

                db.each_pair do |key,val|
                        fout.syswrite "#{key} #{val}\n"
                end
        end

        # save an FVWM menu
        File.open(fvwmFile, 'w') do |fout|

                fout.syswrite "AddToMenu #{menuName} \"Common Applications\" Title\n" 

                # sort entries in decending order by occurance  
                sorted = db.sort { |a,b| b[1] <=> a[1] }

                # write each program as a menu entry    
                sorted.each do |entry|
                
                        fout.syswrite "+ \"#{entry[0]}\" Exec exec tally.rb 
#{entry[0]}\n"
                end             
        end
rescue
        puts "Cannot open for writing"
end


# execute the program as normal
exec ARGV.join(' ')

Reply via email to