#!/bin/sh # # Create menu/desktop entries for an application # This is used by the IShellLink interface # # Copyright 2000 Alexandre Julliard # Copyright 2006 Vitaliy Margolen # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # # Note that the link is a relative unix-style path name. Since the / character # is not valid in Windows filenames it is an adequate separator to show the # menu structure. mode="" args="" menu="" icon="" descr="" link="" path="" workdir="" usage() { cat <") if (RSTART>0) { print substr($0,RSTART+1) } }' $tmp fi } # Input # menu file name # new item write_menu_file() { menu=`echo "$1" | sed 's!/!-!g'` filename=`echo "$2" | sed 's!/!-!g'` tmpfile=`mktemp /tmp/wine.XXXXXX` ( echo '' echo '' echo ' Applications' IFS="/" fullname='wine' for i in $1; do echo " " echo " $fullname-$i" echo " $fullname-$i.directory" dir_file_name="$xdg_data_dir/desktop-directories/$fullname-$i.directory" if [ ! -f "$dir_file_name" ] ; then directory_entry "$i" > "$dir_file_name" fi test "$i" = "wine" || fullname="$fullname-$i" done echo " " IFS=" " for i in `get_menu_entries "$menu"` do test "$i" = "$filename" && continue echo " $i" done # New record echo " $filename" echo " " IFS='/' for i in $1; do echo " " done echo '' ) > $tmpfile chmod 0600 $tmpfile mv -f $tmpfile "$xdg_config_dir/$menu.menu" } copy_icon "$xdg_data_dir/icons" linkname=`basename "$link"` if [ $mode = "menu" ] ; then mkdir -p "$xdg_data_dir/applications/wine/`dirname "$link"`" linkpath=`dirname "$link"` if [ "$linkpath" = "." ] ; then linkpath="" else linkpath="/$linkpath" fi desktop_entry > "$xdg_data_dir/applications/wine/$link.desktop" write_menu_file "wine$linkpath" "wine$linkpath/$linkname.desktop" else if [ -d "$HOME/Desktop" ] then desktop_target="$HOME/Desktop/$linkname.desktop" else desktop_target="$HOME/$linkname.desktop" fi desktop_entry > "$desktop_target" fi exit 0