DSL Ideas and Suggestions :: "Add Icon" script



Another "just had a thought" from my delusional brain.
How about a small script, run from the "Desktop" part of the menu, to add a bit of user-friendliness to the creation of an icon, by using the inputed variables to create a .lnk file?  Say, on click of "menu / Desktop / Create icon" =>
1.  "Icon Caption" - gives the caption, and the file name for the created .lnk
2.  "Executable Command, eg. /usr/bin/gimp" - gives the command line, obviously may be a little too much for complete newbies, but...
3.  "Icon Image" - gives the name of the gif or png, maybe tells them to place it in /home/dsl/.xtdesktop?

Coordinates don't need to be specified, 'cause once it's made, the user can just drag the new icon to where they want it.

Of course it would be good if the "Command" and "Icon Image" had a "browse" function, but I'm guessing this would complicate it a bit.

The basic version should be a fairly small and simple script?  I'm not too knowledgeale about scripting, but I think I could probably figure out how to do this to some degree if need be?
Would just add a little bit more user-friendliness for those coming from windoze who are used to being able to create icons etc by right-clicking the desktop.

Hmm, actually, a similar principal could possibly apply to the menu, or at least the mydsl part of it, correct?  As each mydsl item creates it's own seperate link file under /var/temp/mydsl.menu
?

How about something like this:

Code Sample

#!/bin/sh
DIA="Xdialog --wmclass"

$DIA --2inputsbox "Please enter a name and a command for your icon." 0 0 "Name:" "" "Command:" "" 2>/tmp/tic
ICON_NAME=`cat /tmp/tic | perl -e '$x=<>;if($x=~/^(.*?)\/.+/{print $1}'`
ICON_CMD=`cat /tmp/tic | perl -e '$x=<>;if($x=~/^(.*?)\/(.*)/{print $2}'`

$DIA --msgbox "Now choose a picture for your icon." 0 0
$DIA --fselect /home/knoppix/.xtdesktop 0 0 2> /tmp/tic
ICON_PIC=`cat /tmp/tic`
rm -f /tmp/tic

cat <<EOF>/home/knoppix/.xtdesktop/$ICON_NAME.lnk
table Icon
Type: Program
Caption: $ICON_NAME
Command: $ICON_CMD
Icon: $ICON_PIC
X: 25
Y: 270
end
EOF


(apologies for any formatting errors)

Corrected version:

Code Sample
#!/bin/sh
DIA="Xdialog --wmclass --title Icon"

$DIA --2inputsbox "Please enter a name and a command for your icon." 0 0 "Name:" "" "Command:" "" 2>/tmp/tic
ICON_NAME=`cat /tmp/tic | perl -e '$x=<>;if($x=~/^(.*?)\/.+/{print $1}'`
ICON_CMD=`cat /tmp/tic | perl -e '$x=<>;if($x=~/^(.*?)\/(.*)/{print $2}'`

$DIA --msgbox "Now choose a picture for your icon." 0 0
$DIA --fselect /home/dsl/.xtdesktop 0 0 2> /tmp/tic
ICON_PIC=`cat /tmp/tic`
rm -f /tmp/tic

cat <<EOF>/home/dsl/.xtdesktop/$ICON_NAME.lnk
table Icon
Type: Program
Caption: $ICON_NAME
Command: $ICON_CMD
Icon: $ICON_PIC
X: 25
Y: 270
end
EOF

Thanks TyphoonMentat, but couldn't get it to work - looking at the script, I assume it needs perl to work, and perl isn't on in the standard iso, correct?
perl is on the standard iso

But xdialog ISN'T

A slight rewrite with whiptail instead of xdialog is in order.

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

Next Page...
original here.