[Wine] Useful bash scripts for wine / need help

landeel wineforum-user at winehq.org
Thu May 6 16:39:50 CDT 2010

They can be copied to /usr/bin

The first script will extract icons from the .EXE file, choose the best icon, convert it to PNG, and copy it to the same folder of the application.

The second one depends on the first. It and can be very useful. If you simply call "wine-createshortcut MYAPP.EXE" it will produce a shortcut for the application, in desktop and applications menu, with the proper icon. :)



# wine-extracticon

echo "Extracting icon(s)..."
wrestool -x -t 14 "$( readlink -f "$@")" > "/tmp/$( basename "$( readlink -f "$@")").ico"

echo Converting icon to PNG...
convert -alpha on "/tmp/$( basename "$( readlink -f "$@")").ico" "/tmp/$( basename "$( readlink -f "$@")").png"

#  the script will assume the best icon is the bigger one
echo Copy $(ls -S -1 "/tmp/$( basename $( readlink -f "$@"))"*".png" | tac | tail -n 1) to "$( readlink -f "$@").icon.png" ...
cp $(ls -S -1 "/tmp/$( basename $( readlink -f "$@"))"*".png" | tac | tail -n 1) "$( readlink -f "$@").icon.png"

echo "Done."



# wine-createshortcut

echo Extract icon...
wine-extracticon "$@"

echo Create shortcut contents...
myshortcut="[Desktop Entry]"\\n"Exec=wine start /Unix \""$( readlink -f "$@")"\""\\n"Type=Application"\\n"Categories=Application"\\n"Icon="$( readlink -f "$@")".icon.png"

echo Create .desktop file...
echo -e $myshortcut >"$( readlink -f "$@")".desktop

echo Create links on desktop and applications menu...
ln -s "$( readlink -f "$@").desktop" "$HOME/Desktop/$( basename "$( readlink -f "$@")").desktop"
ln -s "$( readlink -f "$@").desktop" "$HOME/.local/share/applications/$( basename "$( readlink -f "$@")").desktop"

echo Done.

The problem is both scripts will fail if there are any spaces in the filename or in the path name. Spaces in filenames are evil!

Any bash script experts? I need help!

More information about the wine-users mailing list