summarylogtreecommitdiffstats
path: root/embrilliance.bash
blob: d6b046c66649284b9272ce35ae1619d72caa883c (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
#!/usr/bin/env bash
set -eu

PKGNAME='embrilliance'
APPNAME_UPSTREAM='Embroidery'
EXE="C:/Program Files/BriTon Leap/${APPNAME_UPSTREAM}/Embroidery.exe"
PKG_USER_DATA_HOME="${XDG_DATA_HOME:-"${HOME}/.local/share"}/${PKGNAME}"

echo >&2 "Initializing"

export WINEARCH='win64'
export WINEPREFIX="${PKG_USER_DATA_HOME}/wine"

APPDIR_SOURCE="/opt/${PKGNAME}"
APPDIR_PARENT="${WINEPREFIX}/drive_c/Program Files/BriTon Leap"
TARGET_HOME="${WINEPREFIX}/drive_c/users/$(whoami)"

echo >&2 "Checking for Wine prefix"
if ! [ -d "${WINEPREFIX}" ]; then
  echo >&2 "==> Bootstrapping Wine prefix"
  mkdir -pv "${WINEPREFIX}"
  wineboot -i
  rm -fv "${WINEPREFIX}/dosdevices/z:"
  echo >&2 "==> Done"
fi

echo >&2 "Checking user data directory"
mkdir -pv "${PKG_USER_DATA_HOME}/Documents"
if ! [ -d "${PKG_USER_DATA_HOME}/Documents/Embrilliance" ]; then
  cp -R "/usr/share/${PKGNAME}" \
    "${PKG_USER_DATA_HOME}/Documents/Embrilliance"
fi

echo >&2 "==> Restoring symlink to user data directory"
mkdir -pv "${TARGET_HOME}"
cd "${TARGET_HOME}"
ln -fnsv "${PKG_USER_DATA_HOME}/Documents"
echo >&2 "==> Done"

echo >&2 "Checking app directory"
if ! [ -d "${APPDIR_PARENT}/${APPNAME_UPSTREAM}" ]; then
  echo >&2 "==> Creating symlink to app directory"
  mkdir -pv "${APPDIR_PARENT}"
  ln -fnsv "${APPDIR_SOURCE}" "${APPDIR_PARENT}/${APPNAME_UPSTREAM}"
  echo >&2 "==> Done"
fi

echo >&2 "Launching app with Wine"
wine "${EXE}"
echo >&2 "==> Finished"