water cooler :: recommend a menu



I haven't still tested, but I won't be using fluxbox, I'll be using failsafewm.

Sorry to repeat, but is it possible to have spaces in the buttons' text?
Like "Web browser"="/usr/bin/dillo"

Replace this:
Code Sample
butt[cnt]:label(k)

with this:
Code Sample
a,b=string.gsub(k,"_"," ")
butt[cnt]:label(a)

Now use underscores for spaces in the table and they will be converted to spaces.

I couldn't find a way to use the spaces directly in the table keys.

Try
Code Sample
["A t e r m"]="aterm"

Quote
As far as I know, DSL 4.0 uses Fluxbox 0.1.14, which I already mentioned doesn't properly position the app. Are you saying position() works now? It didn't work for me when I tried it last night (DSL 4.0RC5/Fluxbox), any better than putting the coordinates in Fl_Window did.
Yea, I was just confirming the position problems but that I didn't run into any window decoration problems.  Using position() works for any other values than 0,0 and it does seem that the settings in Fl_Window are ignored.  Of course, I haven't thoroughly tested all cases...

Quote (^thehatsrule^ @ Oct. 26 2007,10:59)
Try
Code Sample
["A t e r m"]="aterm"

Hey, that works. I dunno what it means, but it works =o)
But I think I prefer my method, though. It's easier to use a single underscore for each space, in my opinion, than to use square brackets and quotes *and* spaces.

I also think I'll add a little code to automatically get the proper number of table entries instead of having the user change both, contrary to what I said before. It's only a few extra lines, and it won't make any noticeable difference in performance even on a very slow machine unless you have hundreds of keys (which wouldn't fit on the screen anyway).

With either of the above issues, I would consider keeping the code smaller if it weren't for the fact that the script is so small that the ease of use and configuration greatly outweighs the added code.

Added font and color config
Automated the table item count
Added suport for spaces in labels
Removed the Fl_Pack (not needed in a linear array of same-size buttons)
Changed the way the window is positioned (w:resize())
Code Sample

---- CONFIGURATION
-- menu: label="command" (use underscores for label spaces)
my_menu={
Aterm="aterm -fn proggy",
Dillo="dillo",
DSL_panel="cpanel.lua",
Top="aterm -e top"
}

size=11 -- text size
bh=16 -- button height
bw=100 -- button width
Fl:set_font(0,"snap")
Fl:background(0,0,0) -- r,g,b (0-255)
Fl:foreground(255,255,255)
---- END CONFIGURATION

w=fltk:Fl_Window(0,0,Fl:w(),bh,"MLmenu")
w:callback(function() end)
butt={}
cnt=0
for k,v in pairs(my_menu) do
butt[cnt]=fltk:Fl_Button(cnt*bw,0,bw,bh)
a,b=string.gsub(k,"_"," ")
butt[cnt]:label(a)
butt[cnt]:labelsize(size)
butt[cnt]:callback(function() os.execute(v.." &") end)
butt[cnt]:box(fltk.FL_BORDER_BOX)
cnt=cnt+1
end

barw=cnt*bw
w:resize(Fl:w()/2-barw/2,0,barw,bh)
w:border(0)
w:show()
Fl:run()

Next Page...
original here.