Hey, I thought I'd add my two-cents.
Code:
#!/bin/bash
#Shortcut-Maker by Jorl
#Helper colors
NO_COLOUR="\e[0m"
LIGHT_BLUE="\e[1;34m"
RED="\e[1;31m"
#Test that there are three arguments (Path, Command and Name)
if [ -z $3 ]
then
echo -e "${RED}Not enough arguments!${NO_COLOUR}";
exit ;
fi ;
#The path must be resolved in case it is a symbolic link or relative
CDPATH=`readlink -f $1`
#Notify the user of what we are doing
echo -e "${LIGHT_BLUE}Creating shortcut...${NO_COLOUR}";
echo -e "${LIGHT_BLUE}Path: $CDPATH${NO_COLOUR}";
echo -e "${LIGHT_BLUE}Command: $2${NO_COLOUR}";
echo -e "${LIGHT_BLUE}Name: $3${NO_COLOUR}";
#This is the path to the new shortcut
FILEPATH=/usr/local/bin/$3
#Echo the messages
echo "#!/bin/bash" > $FILEPATH
echo "###################################" >> $FILEPATH
echo "# Autogenerated by shortcut-maker #" >> $FILEPATH
echo "###################################" >> $FILEPATH
echo "" >> $FILEPATH
#CD to the directory
echo "cd \"$CDPATH\"" >> $FILEPATH
# $2 is the command to run. Parse any arguments to it.
echo "$2 \$@" >> $FILEPATH
#Make it executable
chmod +x $FILEPATH
#Notify the user
echo -e "${LIGHT_BLUE}Shortcut created!${NO_COLOUR}";
That's the script I use to make wine shortcuts. It can be used for other
things as well. It follows the syntax:
shortcut-maker <directory (can be relative path, as readlink converts it)>
<command to execute> <target name>
It creates a shortcut with the "target name" in the /usr/local/bin
folder. It makes it executable (do not that I have r+w permissions to this
folder).
Basically, since, in Ubuntu, /usr/local/bin is in the path, I'm safe with
this. For wine apps, I can do (imagine I want to launch myApp.exe in the current
directory):
Code:
shortcut-maker . "wine MyApp.exe" "myapp-launcher"
Or, to set WINEDEBUG=-all:
Code:
shortcut-maker . "WINEDEBUG=-all wine MyApp.exe"
"myapp-launcher"
It can be used for many other things. Probably it has errors and it isn't
well-written or that efficient, but it does the job for me. Oh, I almost forgot!
It creates a shortcut that accepts parameters to pass to the app. So running
"myapp-launcher --some-options" would be the same as
"WINEDEBUG=-all wine MyApp.exe --some-options" (after CD'ing).
Hope that helped!
Cheers,
Jorl17