summarylogtreecommitdiffstats
path: root/evesetup.shlib
blob: 7dc0e63ed60731a0602035b5fac7c1422d68859e (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/sh

CONFDIR="$HOME/.config/CCP"
EVECONF="$CONFDIR/EVE.conf"
SHAREDIR="$HOME/.eve"

check_elv() {
	/usr/bin/kill -s TERM evelauncher 2>/dev/null || true
	ELBIN=$(getdate $LAUNCHER/evelauncher)
	ELARC=$(getdate $SETUPDIR/lib/evelauncher-$ELVER.tar.?z)
	if [ "$ELBIN" -lt "$ELARC" ] ;then
		if [ -d "$LAUNCHER" ] ;then
			rm -rf $LAUNCHER
			desktop_msg "Update EVE Launcher binaries"
		fi
		tar xmf $SETUPDIR/lib/evelauncher-$ELVER.tar.?z -C $EVEDIR
		mv $EVEDIR/evelauncher $LAUNCHER
		if [ -f "$HOME/.config/devilspie2/evelauncher.lua" ] ;then
			sed -i 2\ s,[0-9].*\",$ELVER\", $HOME/.config/devilspie2/evelauncher.lua
		fi
		for ELCACHE in $HOME/.cache $HOME/.local/share ;do
			if [ -d "$ELCACHE/CCP/EVE/QtWebEngine" ] ;then
				rm -rf $ELCACHE/CCP/EVE/QtWebEngine
			fi
		done
	fi
}

check_env() {
	if [ -r "$EVECONF" ] ;then SHAREDIR=$(getval SharedCacheFolder) ;fi
	if [ ! -d "$SHAREDIR" ] ;then SHAREDIR="" ;fi
	if [ "x$SHAREDIR" != "x$EVEDIR/SharedCache/" ] ;then
		desktop_msg "Preparing environment in $EVEDIR"
		mkdir -p $CONFDIR
		cat >$EVECONF <<EOF
[General]
SharedCacheFolder=$EVEDIR/SharedCache/
UseCustomWine=true
CustomWinePath=$WINEPATH/wine
LauncherRunClientsWithDx9=false
LauncherShouldMinimizeToTray=false
EOF
		mkdir -p $EVEDIR/SharedCache
		if [ -d "$SHAREDIR/ResFiles/" ] ;then
			mv $SHAREDIR/ResFiles/ $EVEDIR/SharedCache/
			mv $SHAREDIR/*.txt $EVEDIR/SharedCache/
			rm -rf $SHAREDIR
		fi
	fi
}

check_steam() {
	if [ ! -r "$LAUNCHER/steam_appid.txt" -a -x "$(which steam 2>/dev/null)" ] ;then
		echo "8500" >$LAUNCHER/steam_appid.txt
	fi
}

check_wine() {
	CUSTOMWP=$(getval CustomWinePath)
	SHAREDIR=$(getval SharedCacheFolder)
	UCW=$(getval UseCustomWine)
	DXVKLIBDIR=$SETUPDIR/lib/dxvk
	DXVKFILELIST="d3d10core d3d11 d3d9 dxgi"
	WINEPREFIX=${SHAREDIR}wineenv
	WINSYSDIR=$WINEPREFIX/drive_c/windows/system32
	W32SYSDIR=${WINSYSDIR%/*}/syswow64
	if [ "$UCW" = "true" ] ;then
		WINEPATH=${CUSTOMWP%/*}
		if [ -d "${SHAREDIR}wine" ] ;then rm -rf ${SHAREDIR}wine ;fi
	else
		CUSTOMWP=${SHAREDIR}wine
		WINEPATH=${SHAREDIR}wine/bin
	fi
	if [ -x "$WINEPATH/wine64" ] ;then
		WINE=$WINEPATH/wine64
	else
		WINE=$WINEPATH/wine
	fi
	if [ -x "$WINE" ] ;then
		INSTWINE=$(tr -dc [:digit:] 2>/dev/null < $WINEPREFIX/.update-timestamp || printf 0)
		WINEINFP=$(readlink -f $CUSTOMWP)
		WINECONF=$(find ${WINEINFP%bin*}share/wine* -name 'wine.inf')
		WINEDATE=$(getdate $WINECONF)
		if [ "$WINEDATE" != "$INSTWINE" ] ;then
			desktop_msg "Preparing wine environment for EVE"
			for DXVKFILE in d3d10_1 d3d10core d3d10 d3d11 d3d9 dxgi ;do
				rm $WINSYSDIR/$DXVKFILE.dll* || true
				rm $W32SYSDIR/$DXVKFILE.dll* || true
				sed -i /\"$DXVKFILE\"=\"/d $WINEPREFIX/user.reg || true
			done
			env WINEPREFIX=$WINEPREFIX WINEDEBUG=-all WINEDLLOVERRIDES="mscoree,mshtml=d" $WINE wineboot
			env WINEPREFIX=$WINEPREFIX $WINE reg add 'HKCU\Software\Wine\FileOpenAssociations' /v Enable /d N /f >/dev/null
		fi
		if [ -d "$DXVKLIBDIR" ] ;then
			DXVKARC=$(getdate $DXVKLIBDIR/x64/d3d10core.dll)
			INSTDX=$(getdate $WINSYSDIR/d3d10core.dll)
			if [ "$INSTDX" != "$DXVKARC" ] ;then
				for DXVKFILE in $DXVKFILELIST ;do
					cp --preserve=timestamps $DXVKLIBDIR/x64/$DXVKFILE.dll $WINSYSDIR/$DXVKFILE.dll
					if [ -d "$W32SYSDIR" ] ;then
						cp --preserve=timestamps $DXVKLIBDIR/x32/$DXVKFILE.dll $W32SYSDIR/$DXVKFILE.dll
					fi
					env WINEPREFIX=$WINEPREFIX $WINE reg add 'HKCU\Software\Wine\DllOverrides' /v $DXVKFILE /d native /f >/dev/null
				done
			fi
		fi
		if [ "$(grep -csw winemenubuilder $WINEPREFIX/system.reg)" != "0" ] ;then
			env WINEPREFIX=$WINEPREFIX $WINE reg delete 'HKLM\Software\Microsoft\Windows\CurrentVersion\RunServices' /v winemenubuilder /f >/dev/null
		fi
	fi
}

desktop_msg() {
	if [ -x "$(which notify-send)" ] ;then notify-send -i eve $(basename $0) "$@" ;fi
	printf "$(basename $0): $@\n"
}

getdate() {
	printf $(ls -l --time-style=+%s $1 | cut -d' ' -f6) || printf 0
}

getval() {
	if [ ! -r "$EVECONF" ] ;then
		desktop_msg "ERROR: EVE Configuration not found!"
		exit 1
	fi
	printf $(grep "$1" $EVECONF | cut -d= -f2)
}