~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/tools/wineshelllink

Version: ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 #!/bin/sh
  2 #
  3 # Create menu/desktop entries for an application
  4 # This is used by the IShellLink interface
  5 #
  6 # Copyright 2000 Alexandre Julliard
  7 # Copyright 2006 Vitaliy Margolen
  8 #
  9 # This library is free software; you can redistribute it and/or
 10 # modify it under the terms of the GNU Lesser General Public
 11 # License as published by the Free Software Foundation; either
 12 # version 2.1 of the License, or (at your option) any later version.
 13 #
 14 # This library is distributed in the hope that it will be useful,
 15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 # Lesser General Public License for more details.
 18 #
 19 # You should have received a copy of the GNU Lesser General Public
 20 # License along with this library; if not, write to the Free Software
 21 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 22 #
 23 
 24 # Note that the link is a relative unix-style path name.  Since the / character
 25 # is not valid in Windows filenames it is an adequate separator to show the
 26 # menu structure.
 27 
 28 mode=""
 29 args=""
 30 menu=""
 31 icon=""
 32 descr=""
 33 link=""
 34 path=""
 35 workdir=""
 36 
 37 usage()
 38 {
 39     cat <<EOF
 40 usage: wineshelllink options
 41 
 42 options:
 43   --desktop     create a desktop link
 44   --menu        create a menu entry
 45   --path xx     path to the application
 46   --link xx     name of link to create, including path
 47   --args xx     command-line arguments for the application
 48   --icon xx     icon to display
 49   --workdir xx  working directory for the application
 50   --descr xx    application description
 51 
 52 EOF
 53     exit 2
 54 }
 55 
 56 if [ $# -eq 0 ] ; then
 57     usage
 58 fi
 59 
 60 while [ $# -gt 0 ]
 61 do
 62   case "$1" in
 63     --desktop) mode="desktop"; shift 1 ;;
 64     --menu)    mode="menu"; shift 1 ;;
 65     --path)    path="$2"; shift 2 ;;
 66     --link)    link="$2"; shift 2 ;;
 67     --args)    args="$2"; shift 2 ;;
 68     --icon)    icon="$2"; shift 2 ;;
 69     --descr)   descr="$2"; shift 2 ;;
 70     --workdir) workdir="$2"; shift 2 ;;
 71     *) usage ;;
 72   esac
 73 done
 74 
 75 if [ -z "$mode" ] ; then
 76     echo "Either --desktop or --menu required"
 77     usage
 78 fi
 79 
 80 if [ -z "$link" ] ; then
 81     echo "You must specify a link name with --link"
 82     usage
 83 fi
 84 
 85 desktop_entry()
 86 {
 87     cat <<EOF
 88 [Desktop Entry]
 89 Name=$linkname
 90 Exec=env WINEPREFIX="${WINEPREFIX:-$HOME/.wine}" wine "$path" $args
 91 Type=Application
 92 StartupWMClass=Wine
 93 EOF
 94     [ -z "$descr"   ] || echo "Comment=$descr"
 95     [ -z "$workdir" ] || echo "Path=$workdir"
 96     [ -z "$xpmicon" ] || echo "Icon=$xpmicon"
 97 }
 98 
 99 directory_entry()
100 {
101     cat <<EOF
102 [Desktop Entry]
103 Type=Directory
104 EOF
105     if [ "$1" = "wine" ] ; then
106         echo "Name=Wine"
107         echo "Icon=wine"
108     else
109         echo "Name=$1"
110         echo "Icon=folder"
111     fi
112 }
113 
114 # copy the icon file to a specified dir and set xpmicon to the resulting path
115 copy_icon()
116 {
117     if [ -f "$icon" ]
118     then
119         xpmicon=`basename "$icon"`
120         xpmicon=${xpmicon%.*}
121 
122         mkdir -p "$1"
123         cp "$icon" "$1"
124     else
125         xpmicon=""
126     fi
127 }
128 
129 # XDG
130 
131 xdg_config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/menus/applications-merged"
132 xdg_data_dir="${XDG_DATA_HOME:-$HOME/.local/share}"
133 
134 # Create common directories
135 mkdir -p "$xdg_config_dir"
136 mkdir -p "$xdg_data_dir/desktop-directories"
137 
138 get_menu_entries()
139 {
140     tmp="$xdg_config_dir/$1.menu"
141 
142     if [ -r "$tmp" ] ; then
143         awk '
144 BEGIN {  RS="<" }
145 /^Filename/ {
146   RSTART=index($0,">")
147   if (RSTART>0) {
148      print substr($0,RSTART+1)
149   }
150 }' $tmp
151     fi
152 }
153 
154 # Input
155 #   menu file name
156 #   new item
157 write_menu_file()
158 {
159     menu=`echo "$1" | sed 's!/!-!g'`
160     filename=`echo "$2" | sed 's!/!-!g'`
161 
162     tmpfile=`mktemp /tmp/wine.XXXXXX`
163     (
164         echo '<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"'
165         echo '"http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">'
166         echo '<Menu>'
167         echo '  <Name>Applications</Name>'
168 
169         IFS="/"
170 
171         fullname='wine'
172         for i in $1; do
173             echo "  <Menu>"
174             echo "    <Name>$fullname-$i</Name>"
175             echo "    <Directory>$fullname-$i.directory</Directory>"
176 
177             dir_file_name="$xdg_data_dir/desktop-directories/$fullname-$i.directory"
178             if [ ! -f "$dir_file_name" ] ; then
179                 directory_entry "$i" > "$dir_file_name"
180             fi
181             test "$i" = "wine" || fullname="$fullname-$i"
182         done
183 
184         echo "    <Include>"
185 
186         IFS="
187 "
188         for i in `get_menu_entries "$menu"`
189         do
190             test "$i" = "$filename" && continue
191             echo "      <Filename>$i</Filename>"
192         done
193 
194         # New record
195         echo "      <Filename>$filename</Filename>"
196         echo "    </Include>"
197 
198         IFS='/'
199         for i in $1; do
200             echo "  </Menu>"
201         done
202         echo '</Menu>'                        
203     ) > $tmpfile
204     chmod 0600 $tmpfile
205 
206     mv -f $tmpfile "$xdg_config_dir/$menu.menu"
207 }
208 
209 
210 copy_icon "$xdg_data_dir/icons"
211 
212 linkname=`basename "$link"`
213 
214 if [ $mode = "menu" ] ; then
215     mkdir -p "$xdg_data_dir/applications/wine/`dirname "$link"`"
216 
217     linkpath=`dirname "$link"`
218     if [ "$linkpath" = "." ] ; then
219         linkpath=""
220     else
221         linkpath="/$linkpath"
222     fi
223 
224     desktop_entry > "$xdg_data_dir/applications/wine/$link.desktop"
225     write_menu_file "wine$linkpath" "wine$linkpath/$linkname.desktop"
226 else
227     if [ -d "$HOME/Desktop" ]
228     then
229       desktop_target="$HOME/Desktop/$linkname.desktop"
230     else
231       desktop_target="$HOME/$linkname.desktop"
232     fi
233     desktop_entry > "$desktop_target"
234 fi
235 
236 exit 0

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.