#!/bin/bash

DIRECTORY="$(dirname "$(dirname "$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )")")"

function error {
  echo -e "\\e[91m$1\\e[39m"
  exit 1
}

env WINEPREFIX="$HOME/.wine" wine C:\\windows\\command\\start.exe /Unix ~/.wine/dosdevices/c:/ProgramData/Microsoft/Windows/Start\ Menu/Programs/LEGO\ Company/Uninstall\ LEGO\ Digital\ Designer.lnk || error "Wine uninstallation command failed!"

#wait until finished
while ps aux | grep -v grep | grep wine | grep -q 'LEGO Digital Designer' ;do
  sleep 1
done

rm -rf ~/'.local/share/applications/wine/Programs/LEGO Company'
