summarylogtreecommitdiffstats
path: root/evelauncher.shlib
blob: 417e5e3b1da83c0112a7f6da53cafcbb1cd54790 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh

# Evelauncher shared functions

desktop_msg() {
    if [ -x "$(which notify-send 2>/dev/null)" ] ;then
	notify-send -i eve 'EVE Online Launcher' "$@"
    fi
    printf "$(basename $0): $@\n"
}

check_wine() {
    EVECONF=$HOME/.config/CCP/EVE.conf
    if [ ! -r "$EVECONF" ] ;then
	desktop_msg "ERROR: EVE Configuration not found!"
	exit 1
    fi
    CUSTOMWP=$(grep CustomWinePath $EVECONF | cut -d= -f2)
    SHAREDIR=$(grep SharedCacheFolder $EVECONF | cut -d= -f2)
    UCW=$(grep UseCustomWine $EVECONF | cut -d= -f2)
    WINEPREFIX=${SHAREDIR}wineenv
    if [ "x$UCW" = "xtrue" ] ;then
	WINEPATH=${CUSTOMWP%/*}
	[ -d "${SHAREDIR}wine" ] && rm -rf ${SHAREDIR}wine
    else
	CUSTOMWP=${SHAREDIR}wine
	WINEPATH=${SHAREDIR}wine/bin
    fi
    if [ ! -x "$WINEPATH/wine" ] ;then
	desktop_msg "ERROR: \"$CUSTOMWP\" not found!"
	exit 1
    fi
    INSTWINE=$(cat $WINEPREFIX/.update-timestamp 2>/dev/null | tr -dc [:digit:]) || true
    WINEINFP=$(readlink -f $CUSTOMWP)
    WINECONF=${WINEINFP%/bin*}/share/wine/wine.inf
    WINEDATE=$(ls -l --time-style=+%s $WINECONF 2>/dev/null | cut -d' ' -f6)
    if [ "x$WINEDATE" != "x$INSTWINE" ] ;then
	desktop_msg "Preparing wine in $WINEPREFIX"
	env WINEPREFIX=$WINEPREFIX \
	    WINEDEBUG=-all \
	    WINEDLLOVERRIDES="mscoree,mshtml=d" \
	    $WINEPATH/wineboot
	env WINEPREFIX=$WINEPREFIX \
	    $WINEPATH/wine reg add \
	    'HKCU\Software\Wine\FileOpenAssociations' \
	    /v Enable /d N /f >/dev/null
	WINETRP=$(cat $WINEPREFIX/winetricks.log 2>/dev/null | uniq)
	if [ "x$WINETRP" != "x" ] ;then
	    desktop_msg "Apply winetricks settings. This will take some time."
	    rm $WINEPREFIX/winetricks.log >/dev/null
	    env WINEPREFIX=$WINEPREFIX \
		WINE=$WINEPATH/wine \
		$(which winetricks) -q --force $WINETRP >/dev/null
	fi
    fi
    if [ -x "$WINEPATH/wine64" ] ;then
	WINE=$WINEPATH/wine64
    else
	WINE=$WINEPATH/wine
    fi
    env WINEPREFIX=$WINEPREFIX \
	$WINE reg delete \
	'HKLM\Software\Microsoft\Windows\CurrentVersion\RunServices' \
	/v winemenubuilder /f >/dev/null || true
}