Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (3) </ 1 [2] 3 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: "Add Icon" script, bit of user-friendliness< Next Oldest | Next Newest >
TyphoonMentat (not logged in)
Unregistered






Posted: Feb. 13 2005,10:11 QUOTE

Well, I guess there're two options:
- Don't use a file selector, and let the user type in the appropriate file within the /home/dsl/.xtdesktop directory
- Include the XDialog binary, which is 78Kb (the Debian package is 880Kb uncompressed, but this is mostly locales and docs)
Back to top
clacker Offline





Group: Members
Posts: 570
Joined: June 2004
Posted: Feb. 13 2005,15:33 QUOTE

Quote
But I think that the file selector is not supported in whiptail, but I could be wrong.


it isn't, but I believe --menu is.  you could make a menu that contained the names of all of the jpg, png, gif files in the .xtdesktop directory.
Back to top
Profile PM 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Feb. 13 2005,17:02 QUOTE

Good point.  "ls *.{gif,png,jpg,xpm}" or something similar could dynamically create a list for your menu.

Code Sample
ICON_DIR=$HOME/.xtdesktop
ICON_CNT=0
ICON_TMP=/tmp/xtdesk-icon.tmp
ICON_LIST="whiptail --menu Choose_an_Icon 24 70 16"

for file in `ls ${ICON_DIR}/*.{png,xpm,jpg,gif} 2>/dev/null`; do
       ICON_CNT=$((ICON_CNT+1))
       ICON_LIST="${ICON_LIST} ${file} ${ICON_CNT}"
done

${ICON_LIST} 2>${ICON_TMP}

The content of the ICON_TMP file would then be read back in as the icon filename.
This doesn't work with filenames containing spaces.  I messed around with it for a while but didn't come up with a fix for it.  Honestly, with all the trouble I've had in the past trying to script for filename spaces I decided long ago just to never use spaces in filenames, ever.

Also, This wasn't tested with Busybox, so I can't say that it will work as is in DSL.

I'm thinking it might be fun to do this with Lua FLTK rather than Bash, as we might be able to display the icon choices as graphic buttons rather than choosing from a text list.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
Delboy Offline





Group: Members
Posts: 144
Joined: Nov. 2003
Posted: Feb. 15 2005,13:53 QUOTE

Has anyone tried the icon creation fluxbox plugin 'fbdesk' it can be installed from the Debian packages site using apt-get install ----?.  I suggested this a long while ago for icons but there seemed to be more resistance to 'eye candy' then.
Back to top
Profile PM 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Feb. 15 2005,21:01 QUOTE

I've tried it a little...doesn't seem to be much different than xtdesk.

I put together a Lua FLTK script for making icons.  The file browser in Lua FLTK seems to be pretty limited...it doesn't seem to have a lot of the options that are available in FLTK. There is apparently no image support, and I don't even think you can change the font.

Code Sample

#!/bin/flua

-- dsl-create_icon.flua
-- mikshaw Feb2005

-- DEFAULTS
xtdesk_dir = getenv("HOME").."/.xtdesktop/"
xtdesk_tmp = "/tmp/xtdeskPIDtmp"
w_main_width = 360
w_main_height = 380
b_w = 80        -- button width
b_h = 25        -- button height
b_vs = b_h+5    -- button vertical spacing
b_hs = b_w+30   -- button horizontal spacing
Fl_Widget.initializers = {textfont = 15, labelfont = 15, labelcolor = 15}
Fl_Input_.initializers = {when = When.changed, color = 0, textcolor = 2, cursor_color = 15, selection_color = 8}
Fl_Button.initializers = {box = Boxtype.thin_up, down_box = Boxtype.thin_down, color = 8, labelcolor = 2}
Fl_Round_Button.initializers = {box = Boxtype.none, color = 8, labelcolor = 15, selection_color = 2, type = Buttontype.radio, align = Align.right}
Fl_Window.initializers = {box = Boxtype.thin_down, color = 0}

function hide_mounts()
icon_mount_label:hide()
icon_mount:hide()
icon_mount_browse:hide()
icon_umount_label:hide()
icon_umount:hide()
icon_umount_browse:hide()
icon:show()
icon_label:show()
icon_browse:show()
end

function show_mounts()
icon_mount_label:show()
icon_mount:show()
icon_mount_browse:show()
icon_umount_label:show()
icon_umount:show()
icon_umount_browse:show()
icon:hide()
icon_label:hide()
icon_browse:hide()
end

-- BEGIN LAYOUT
-- HELP
w_help = Window{w_main_width,w_main_height, "help"}
help_text = Box{10-w_main_width,0,w_main_width,w_main_height,"link filename: The filename for your *.lnk file,\nlisted with no extension or leading path.\n\n"..
"\choose icon: The image file(s) used for your icon.\nFor a mount icon two images are requested, one for \nthe unmounted state and one for the mounted state.\n\n"..
"command: The full command which will be run when \nthe icon is clicked.\n\n"..
"caption: The text which will be displayed on the \ndesktop next to the icon.\n\n"..
"x pos & y pos: The horizontal(X) and vertical(Y) \nlocation of your icon, in pixels.\n\n"..
"more: Additional features for the icons. Some features \nmay not work for some versions of xtdesk.\n\n\n\n"..
"lua fltk script by mikshaw, 2005";align=Align.right}
w_help:end_layout()

w_main = Window{w_main_width,w_main_height, "dsl-create_icon"}

-- NAME OF LNK FILE
file_name_label = Box{24,10,100,20,"link filename:"}
file_name = Input{30,30,120,20,".lnk";align=Align.right}

-- SPECIFY TYPE OF ICON
icon_type1 = Round_Button{200,30,20,20,"program"}
function icon_type1.callback()
if old_command_value then command.value = old_command_value end
if old_extras_value then extras.value = old_extras_value end
if old_caption_value then caption.value = old_caption_value end
if old_filename_value then file_name.value = old_filename_value end
hide_mounts()
end
icon_type2 = Round_Button{275,30,20,20,"mount"}
function icon_type2.callback()
if command.value then old_command_value = command.value end
command.value = "mount"
if extras.value then old_extras_value = extras.value end
extras.value = "MenuCommand1: Mount CDROM : mount /dev/cdrom \nMenuCommand2: Umount CDROM : umount /dev/cdrom \nMenuCommand3: Eject CDROM : eject /dev/cdrom \n"
if caption.value then old_caption_value = caption.value end
caption.value = "/dev/cdrom"
if file_name.value then old_filename_value = file_name.value end
file_name.value = "cdrom"
show_mounts()
end
icon_type1.value = 1 -- default is 'Program'

-- SPECIFY ICON FILE
icon_label = Box{18,50,100,20,"choose icon:"}
icon = Input{30,70,280,20}
icon_browse = Button{310,70,20,20,"@>";labeltype=Labeltype.symbol}
function icon_browse.callback()
icon.value = fl_file_chooser("Choose An Icon","*.{jpg,gif,png,xpm}",xtdesk_dir)
end

icon_umount_label = Box{39,50,100,20,"choose umount icon:"}
icon_umount = Input{30,70,280,20}
icon_umount_browse = Button{310,70,20,20,"@>";labeltype=Labeltype.symbol}
function icon_umount_browse.callback()
icon_umount.value = fl_file_chooser("Choose An Icon For Umounted Drive","*.{jpg,gif,png,xpm}",xtdesk_dir)
end

icon_mount_label = Box{36,90,100,20,"choose mount icon:"}
icon_mount = Input{30,110,280,20}
icon_mount_browse = Button{310,110,20,20,"@>";labeltype=Labeltype.symbol}
function icon_mount_browse.callback()
icon_mount.value = fl_file_chooser("Choose An Icon For Mounted Drive","*.{jpg,gif,png,xpm}",xtdesk_dir)
end

command_label = Box{90,130,100,20,"command (including options, if any):"}
command = Input{30,150,280,20}
command_browse = Button{310,150,20,20,"@>";labeltype=Labeltype.symbol}
function command_browse.callback()
command.value = fl_file_chooser("Browse For Application","*","/usr/bin/")
end

caption_label = Box{6,170,100,20,"caption:"}
caption = Input{30,190,200,20}
x_pos_label = Box{220,170,80,20,"x pos:"}
x_pos = Int_Input{240,190,40,20;maximum_size=4}
y_pos_label = Box{270,170,80,20,"y pos:"}
y_pos = Int_Input{290,190,40,20;maximum_size=4}

extras_label = Box{111,220,100,20,"more ( MenuCommand<num>: label : command ):"}
extras = Multiline_Input{30,240,300,56}

b_help = Button{30,320,b_w,b_h,"help"}
function b_help.callback()
       w_help:show()
end

b_create = Button{w_main_width-b_hs*2,320,b_w,b_h,"CREATE ICON"}
function b_create.callback()
filename = xtdesk_dir..file_name.value..".lnk"
if icon_type2.value == 1 then
icontype = "Mount"
command.value = "mount"
else
icontype = "Program"
end
writeto(filename)
write("table Icon\n"..
"Type: "..icontype.."\n"..
"Caption: "..caption.value.."\n"..
"Command: "..command.value.."\n")
if icontype == "Program" then
write("Icon: "..icon.value.."\n")
else
write("IconMount: "..icon_mount.value.."\n"..
"IconUmount: "..icon_umount.value.."\n")
end
write("X: "..x_pos.value.."\n"..
"Y: "..y_pos.value.."\n"..
extras.value.."\nend")
execute("pidof xtdesk && echo \"xtdesk_pid = `pidof xtdesk`\" >"..xtdesk_tmp.." || echo \"xtdesk_pid = 0\" >"..xtdesk_tmp)
dofile(xtdesk_tmp)
remove(xtdesk_tmp)
if xtdesk_pid > 0 then
execute("killall xtdesk")
end
fl_message("Some things and stuff has been written to "..filename)
if xtdesk_pid > 0 then
execute("xtdesk >/dev/null &")
end
exit(0)
end

b_exit = Button{w_main_width-b_hs,320,b_w,b_h,"exit"}
function b_exit.callback()
       exit(0)
end

w_main:end_layout()
hide_mounts()
w_main:show()



Be careful about copy and paste here...lines that wrap may paste as multiple lines.  You may want to stretch your browser window out a bit until lines no longer wrap


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
11 replies since Feb. 12 2005,13:15 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (3) </ 1 [2] 3 >/
reply to topic new topic new poll
Quick Reply: "Add Icon" script

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code