The forum

[Edited Script]

Edited Office 2007 script supports sp2 slipstream and make file associations automatically

Author Replies
Unkuiri Saturday 25 September 2010 at 1:03
Unkuiri

Hi, I've changed the Office 2007 script to support sp2 slipstream and to make file associations automatically so when we double-click a MSOffice file it opens in the respective office program.
The program icons:


The changed script:
#!/bin/bash
# Date : (2009-06-25 11-00)
# Last revision : (2010-09-21 08-00)
# Wine version used : 1.3.0
# Distribution used to test : Ubuntu 10.04
# Author : NSLW & Unkuiri
# Licence : Retail
# Depend : ImageMagick
 
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"
 
#procedure for patching Office2007
patch_Office2007()
{
POL_SetupWindow_browse "Select service pack file" "$TYTUL" ""
POL_SetupWindow_wait_next_signal "Installation in progress..." "$TYTUL"
wine "$APP_ANSWER"
POL_SetupWindow_detect_exit
POL_SetupWindow_message "Patch for $TYTUL has been installed successfully" "$TYTUL"
}
 
TYTUL="MS Office 2007"
PREFIX="Office2007"
WORKINGWINEVERSION="1.3.0"

ICOFOLDER="$HOME/.local/share/icons"
 
EXENAME[0]="WINWORD"
APPNAME[0]="Word"
ICOINDEX[0]=????_wordicon.0.png
 
EXENAME[1]="EXCEL"
APPNAME[1]="Excel"
ICOINDEX[1]=????_xlicons.0.png
 
EXENAME[2]="POWERPNT"
APPNAME[2]="PowerPoint"
ICOINDEX[2]=????_pptico.0.png
 
EXENAME[3]="ONENOTE"
APPNAME[3]="OneNote"
ICOINDEX[3]=????_joticon.0.png
 
EXENAME[4]="INFOPATH"
APPNAME[4]="InfoPath"
ICOINDEX[4]=????_inficon.0.png
 
EXENAME[5]="MSPUB"
APPNAME[5]="Publisher"
ICOINDEX[5]=????_pubs.0.png
 
EXENAME[6]="OUTLOOK" # do not work
APPNAME[6]="Outlook"
ICOINDEX[6]=????_outicon.0.png
 
EXENAME[7]="MSACCESS" # do not work
APPNAME[7]="Access"
ICOINDEX[7]=????_accicons.0.png
 
EXENAME[8]="GROOVE" # do not work
APPNAME[8]="Groove"
ICOINDEX[8]=????_grooveicon.png

#delete icons that may conflict

for i in `seq 0 8`;
do
rm $ICOFOLDER/${ICOINDEX[$i]}
done

#Extensions to associate and make work later:
#Word extensions
EXTNAME[1]="doc"
EXTNAME[2]="dochtml"
EXTNAME[3]="docm"
EXTNAME[4]="docx"
EXTNAME[5]="dot"
EXTNAME[6]="dothtml"
EXTNAME[7]="dotm"
EXTNAME[8]="dotx"
EXTNAME[9]="wbk"

#Access extensions
#EXTNAME[10]="accda"
#EXTNAME[11]="accdb"
#EXTNAME[12]="accdc"
#EXTNAME[13]="accde"
#EXTNAME[14]="accdr"
#EXTNAME[15]="accdt"
#EXTNAME[16]="accdu"
#EXTNAME[17]="ade"
#EXTNAME[18]="adn"
#EXTNAME[19]="adp"
#EXTNAME[20]="mad"
#EXTNAME[21]="maf"
#EXTNAME[22]="mag"
#EXTNAME[23]="mam"
#EXTNAME[24]="maq"
#EXTNAME[25]="mar"
#EXTNAME[26]="mas"
#EXTNAME[27]="mat"
#EXTNAME[28]="mau"
#EXTNAME[29]="mav"
#EXTNAME[30]="maw"
#EXTNAME[31]="mda"
#EXTNAME[32]="mdb"
#EXTNAME[33]="mdbhtml"
#EXTNAME[34]="mde"
#EXTNAME[35]="mdn"
#EXTNAME[36]="mdt"
#EXTNAME[37]="mdw"

#Excel extensions
EXTNAME[38]="csv"
EXTNAME[39]="slk"
EXTNAME[40]="xla"
EXTNAME[41]="xlam"
EXTNAME[42]="xlk"
EXTNAME[43]="xll"
EXTNAME[44]="xlm"
EXTNAME[45]="xls"
EXTNAME[46]="xlsb"
EXTNAME[47]="xlshtml"
EXTNAME[48]="xlsm"
EXTNAME[49]="xlsx"
EXTNAME[50]="xlt"
EXTNAME[51]="xlthtml"
EXTNAME[52]="xltm"
EXTNAME[53]="xltx"
EXTNAME[54]="xlw"


#Powerpoint extensions
EXTNAME[55]="pot"
EXTNAME[56]="pothtml"
EXTNAME[57]="potm"
EXTNAME[58]="potx"
EXTNAME[59]="ppa"
EXTNAME[60]="ppam"
EXTNAME[61]="pps"
EXTNAME[62]="ppsm"
EXTNAME[63]="ppsx"
EXTNAME[64]="ppt"
EXTNAME[65]="ppthtml"
EXTNAME[66]="pptm"
EXTNAME[67]="pptx"
EXTNAME[68]="pptxml"
EXTNAME[69]="pwz"
EXTNAME[70]="sldm"
EXTNAME[71]="sldx"

#Publisher extensions
EXTNAME[72]="ols"
EXTNAME[73]="pub"

#OneNote extensions
EXTNAME[74]="EMPTYBINARYREGISTRY"
EXTNAME[75]="one"
EXTNAME[76]="onepkg"
EXTNAME[77]="onetoc"
EXTNAME[78]="onetoc2"

#Infopath extensions
EXTNAME[79]="infopathxml"
EXTNAME[80]="xsf"
EXTNAME[81]="xsn"
 
wget http://upload.wikimedia.org/wikipedia/en/8/81/MS_Office_2007_Logo.svg --output-document="$REPERTOIRE/tmp/leftnotrotated.png"
convert "$REPERTOIRE/tmp/leftnotrotated.png" -rotate 270 "$REPERTOIRE/tmp/leftnotscaled.png"
convert "$REPERTOIRE/tmp/leftnotscaled.png" -scale 150x356\\! "$REPERTOIRE/tmp/left.jpeg"
POL_SetupWindow_Init "" "$REPERTOIRE/tmp/left.jpeg"
 
POL_SetupWindow_presentation "$TYTUL" "Microsoft" "www.microsoft.com" "NSLW (edited by Unkuiri)" "$PREFIX" 
 
select_prefix "$REPERTOIRE/wineprefix/$PREFIX"
 
#asking about service pack
#if [ -e "$REPERTOIRE/configurations/installed/Microsoft Office Word 2007" ]; then
#POL_SetupWindow_menu "What do you want to do?" "Actions" "Install service pack" "~"
 
#if [ "$APP_ANSWER" == "Install service pack" ]; then
#	patch_Office2007
#fi
 
#POL_SetupWindow_Close
#exit
#fi
 
#asking for CDROM and checking if it's correct one
POL_SetupWindow_message "Please insert $TYTUL media into your disk drive."
POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom "setup.exe"
 
#downloading specific Wine
POL_SetupWindow_install_wine "$WORKINGWINEVERSION"
Use_WineVersion "$WORKINGWINEVERSION"
 
#creating application's own prefix
POL_SetupWindow_prefixcreate
 
#fetching PROGRAMFILES environmental variable
PROGRAMFILES="Program Files" 
POL_LoadVar_PROGRAMFILES
 
#installing Visual C++ 2005 runtime libraries
 
POL_Call POL_Install_vcrun2005
 
POL_SetupWindow_wait_next_signal "Installation in progress..." "$TYTUL"
wine start /unix "$CDROM/setup.exe"
POL_SetupWindow_detect_exit

#installing dependencies
POL_Call POL_Install_msxml3
POL_Call POL_Install_wsh56
POL_Call POL_Install_riched20
POL_Call POL_Install_wininet

#installing ie6
POL_Call POL_Install_ie6
 
#overriding dlls required for displaying help
cd "$WINEPREFIX/drive_c/windows/temp"
echo "[HKEY_CURRENT_USER\\\\Software\\\\Wine\\\\DllOverrides]" > override.reg
echo "\\"usp10\\"=\\"native,builtin\\"" >> override.reg
echo "\\"riched20\\"=\\"native\\"" >> override.reg
regedit override.reg
 
#making shortcuts
for i in `seq 0 5`;
do
cd "$WINEPREFIX/drive_c/$PROGRAMFILES/Microsoft Office/Office12"
if [ -e "$WINEPREFIX/drive_c/$PROGRAMFILES/Microsoft Office/Office12/${EXENAME[$i]}.EXE" ];
then
POL_SetupWindow_auto_shortcut "$PREFIX" "${EXENAME[$i]}.EXE" "" "Microsoft Office ${APPNAME[$i]} 2007"

Set_WineVersion_Assign "$WORKINGWINEVERSION" "Microsoft Office ${APPNAME[$i]} 2007"

appdir=$(detect_appdir "Microsoft Office ${APPNAME[$i]} 2007")
cd "$REPERTOIRE/configurations/installed"
mv "Microsoft Office ${APPNAME[$i]} 2007" "Microsoft Office ${APPNAME[$i]} 2007.bak"
cat "Microsoft Office ${APPNAME[$i]} 2007.bak" | head -n5 > "Microsoft Office ${APPNAME[$i]} 2007"
echo "docname=\\${1##*/}" >> "Microsoft Office ${APPNAME[$i]} 2007"
echo "docpath=\\${1%/*}" >> "Microsoft Office ${APPNAME[$i]} 2007"
echo "cd \\"\\$docpath\\"" >> "Microsoft Office ${APPNAME[$i]} 2007"
echo "wine \\"$appdir/${EXENAME[$i]}.EXE\\" \\"\\$docname\\"" >> "Microsoft Office ${APPNAME[$i]} 2007"
rm "Microsoft Office ${APPNAME[$i]} 2007.bak"

fi
done

#Associating extensions to programs

for i in `seq 1 9`;
do
cd "/$HOME/.local/share/applications/"
mv "wine-extension-${EXTNAME[$i]}.desktop" "wine-extension-${EXTNAME[$i]}.desktop.bak"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n2 > "wine-extension-${EXTNAME[$i]}.desktop"
echo "Name=Microsoft Office Word 2007" >> "wine-extension-${EXTNAME[$i]}.desktop"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n4 | tail -n1 >> "wine-extension-${EXTNAME[$i]}.desktop"
echo "Exec=playonlinux --run 'Microsoft Office Word 2007'" >> "wine-extension-${EXTNAME[$i]}.desktop"
echo Icon= $ICOFOLDER/${ICOINDEX[0]} >> "wine-extension-${EXTNAME[$i]}.desktop"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | tail -n2 >> "wine-extension-${EXTNAME[$i]}.desktop"
rm "wine-extension-${EXTNAME[$i]}.desktop.bak"
done

#for i in `seq 10 37`;
#do
#cd "/$HOME/.local/share/applications/"
#mv "wine-extension-${EXTNAME[$i]}.desktop" "wine-extension-${EXTNAME[$i]}.desktop.bak"
#cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n2 > "wine-extension-${EXTNAME[$i]}.desktop"
#echo "Name=Microsoft Office Access 2007" >> "wine-extension-${EXTNAME[$i]}.desktop"
#cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n4 | tail -n1 >> "wine-extension-${EXTNAME[$i]}.desktop"
#echo "Exec=playonlinux --run 'Microsoft Office Access 2007'" >> "wine-extension-${EXTNAME[$i]}.desktop"
#echo Icon= $ICOFOLDER/${ICOINDEX[7]} >> "wine-extension-${EXTNAME[$i]}.desktop"
#cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | tail -n2 >> "wine-extension-${EXTNAME[$i]}.desktop"
#rm "wine-extension-${EXTNAME[$i]}.desktop.bak"
#done

for i in `seq 38 54`;
do
cd "/$HOME/.local/share/applications/"
mv "wine-extension-${EXTNAME[$i]}.desktop" "wine-extension-${EXTNAME[$i]}.desktop.bak"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n2 > "wine-extension-${EXTNAME[$i]}.desktop"
echo "Name=Microsoft Office Excel 2007" >> "wine-extension-${EXTNAME[$i]}.desktop"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n4 | tail -n1 >> "wine-extension-${EXTNAME[$i]}.desktop"
echo "Exec=playonlinux --run 'Microsoft Office Excel 2007'" >> "wine-extension-${EXTNAME[$i]}.desktop"
echo Icon= $ICOFOLDER/${ICOINDEX[1]} >> "wine-extension-${EXTNAME[$i]}.desktop"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | tail -n2 >> "wine-extension-${EXTNAME[$i]}.desktop"
rm "wine-extension-${EXTNAME[$i]}.desktop.bak"
done

for i in `seq 55 71`;
do
cd "/$HOME/.local/share/applications/"
mv "wine-extension-${EXTNAME[$i]}.desktop" "wine-extension-${EXTNAME[$i]}.desktop.bak"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n2 > "wine-extension-${EXTNAME[$i]}.desktop"
echo "Name=Microsoft Office PowerPoint 2007" >> "wine-extension-${EXTNAME[$i]}.desktop"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n4 | tail -n1 >> "wine-extension-${EXTNAME[$i]}.desktop"
echo "Exec=playonlinux --run 'Microsoft Office PowerPoint 2007'" >> "wine-extension-${EXTNAME[$i]}.desktop"
echo Icon= $ICOFOLDER/${ICOINDEX[2]} >> "wine-extension-${EXTNAME[$i]}.desktop"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | tail -n2 >> "wine-extension-${EXTNAME[$i]}.desktop"
rm "wine-extension-${EXTNAME[$i]}.desktop.bak"
done

for i in `seq 72 73`;
do
cd "/$HOME/.local/share/applications/"
mv "wine-extension-${EXTNAME[$i]}.desktop" "wine-extension-${EXTNAME[$i]}.desktop.bak"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n2 > "wine-extension-${EXTNAME[$i]}.desktop"
echo "Name=Microsoft Office Publisher 2007" >> "wine-extension-${EXTNAME[$i]}.desktop"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n4 | tail -n1 >> "wine-extension-${EXTNAME[$i]}.desktop"
echo "Exec=playonlinux --run 'Microsoft Office Publisher 2007'" >> "wine-extension-${EXTNAME[$i]}.desktop"
echo Icon= $ICOFOLDER/${ICOINDEX[5]} >> "wine-extension-${EXTNAME[$i]}.desktop"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | tail -n2 >> "wine-extension-${EXTNAME[$i]}.desktop"
rm "wine-extension-${EXTNAME[$i]}.desktop.bak"
done

for i in `seq 74 78`;
do
cd "/$HOME/.local/share/applications/"
mv "wine-extension-${EXTNAME[$i]}.desktop" "wine-extension-${EXTNAME[$i]}.desktop.bak"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n2 > "wine-extension-${EXTNAME[$i]}.desktop"
echo "Name=Microsoft Office OneNote 2007" >> "wine-extension-${EXTNAME[$i]}.desktop"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n4 | tail -n1 >> "wine-extension-${EXTNAME[$i]}.desktop"
echo "Exec=playonlinux --run 'Microsoft Office OneNote 2007'" >> "wine-extension-${EXTNAME[$i]}.desktop"
echo Icon= $ICOFOLDER/${ICOINDEX[3]} >> "wine-extension-${EXTNAME[$i]}.desktop"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | tail -n2 >> "wine-extension-${EXTNAME[$i]}.desktop"
rm "wine-extension-${EXTNAME[$i]}.desktop.bak"
done

for i in `seq 79 81`;
do
cd "/$HOME/.local/share/applications/"
mv "wine-extension-${EXTNAME[$i]}.desktop" "wine-extension-${EXTNAME[$i]}.desktop.bak"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n2 > "wine-extension-${EXTNAME[$i]}.desktop"
echo "Name=Microsoft Office InfoPath 2007" >> "wine-extension-${EXTNAME[$i]}.desktop"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | head -n4 | tail -n1 >> "wine-extension-${EXTNAME[$i]}.desktop"
echo "Exec=playonlinux --run 'Microsoft Office InfoPath 2007'" >> "wine-extension-${EXTNAME[$i]}.desktop"
echo Icon= $ICOFOLDER/${ICOINDEX[4]} >> "wine-extension-${EXTNAME[$i]}.desktop"
cat "wine-extension-${EXTNAME[$i]}.desktop.bak" | tail -n2 >> "wine-extension-${EXTNAME[$i]}.desktop"
rm "wine-extension-${EXTNAME[$i]}.desktop.bak"
done

#asking about patching
#POL_SetupWindow_question "Do you want to apply service pack?" "$TYTUL"
#if [ "$APP_ANSWER" == "TRUE" ] ;then
#patch_Office2007
#fi
 
#cleaning temp
cd "$WINEPREFIX/drive_c/windows/temp/"
rm -rf *
POL_SetupWindow_message "$TYTUL has been installed successfully" "$TYTUL"
 
POL_SetupWindow_reboot
POL_SetupWindow_Close
exit
Hope it works well, I've tested it myself on Ubuntu 10.04.The PlayOnLinux icons aren't showing the right image. Can someone test it in other linux distros too? thanks

Edited by Unkuiri

This site allows content generated by members, and we promptly remove any content that infringes copyright according to our Terms of Service. To report copyright infringement, please send a notice to dmca-notice@playonlinux.com