Programming and Scripting :: add wallpaper tool



hi,

im making a addWallpaper.lua tool, wich ads a wallpaper to /opt/.backgrounds. Now i got the problem that the fltk filechooser returns a full path of the selected wallpaper, like /home/dsl/image.png. I just need the image.png piece of that... It should be possible with regexes, but i have no clue how i would do it. Can anybody help me? (mikshaw :P)

Thanks for your help,
Jaapz

Are you using Robert's wallpaper.lua as a base (not sure if it's still in DSL 4, but probably still in DSL 3)?
We already have a wallpaper.lua.

There are many examples for the  question you are asking. Do you know how to use grep?

Just grep for the lua construct over /usr/local/bin/*.lua

If you just wanted some kind of simple matching pattern, you could use something like [^\/]*$ with string:match (not sure if you'll need to escape the / )

I think these need to be asked:
- is this for personal learning?
- if not, are you adding anything that the current wallpaper tool doesn't do?

Quote
the fltk filechooser returns a full path of the selected wallpaper, like /home/dsl/image.png. I just need the image.png piece of that

use fl_filename_name()
Code Sample
image_path=fltk.fl_file_chooser("Choose an image","Image Files (*.{jp{,e}g,png,bmp,xbm,xpm,gif})",nil, nil)
if image_path then
   my_image=fltk.fl_filename_name(image_path)
   print(my_image)
end

Next Page...
original here.