#!/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
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Install Wine
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if ! command -v wine || [ "$(cat "${DIRECTORY}/data/status/Wine (x86)" 2>/dev/null)" != 'installed' ];then
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  echo 'Installing Wine...'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  "${DIRECTORY}/manage" install 'Wine (x86)' || error "Wine failed to install somehow!"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								fi
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								ulimit -c unlimited
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo "Note that during this installation, a error may pop up saying \"Gecko\" or \"Mono\" isn't installed. Don't worry, that error is normal. Just click the \"Install\" button!"
							 
						 
					
						
							
								
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								read -p "Press [Enter] to continue installaton."
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								rm -rf ~/.config/wechat-prefix
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								mkdir -p ~/.config/wechat-prefix
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Install font stuff so chinese renders
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo "Installing several Wine extensions to allow font rendering..."
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								BOX86_NOBANNER=1 WINEPREFIX=~/.config/wechat-prefix winetricks corefonts gdiplus riched20 riched30 wenquanyi cjkfonts || error "Winetricks failed to install corefonts gdiplus riched20 riched30 wenquanyi cjkfonts"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Download reg file to apply fonts
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo "Downloading custom registry file to allow font rendering..."
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								wget -O ~/chn_fonts.reg https://gist.githubusercontent.com/swordfeng/c3fd6b6fcf6dc7d7fa8a/raw/0ad845f98f5a97e7173ff40b5e57b3a163e92465/chn_fonts.reg
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo "Now installing the custom registry file to allow font rendering..."
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								WINEPREFIX=~/.config/wechat-prefix wine regedit ~/chn_fonts.reg
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								rm ~/chn_fonts.reg
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Install wechat
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo "Finally! Downloading WechatSetup.exe"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								wget -O ~/WeChatSetup.exe https://dldir1.qq.com/weixin/Windows/WeChatSetup.exe
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								WINEPREFIX=~/.config/wechat-prefix wine ~/WeChatSetup.exe
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								rm ~/WeChatSetup.exe
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								rm ~/.local/share/applications/wine/Programs/WeChat/UninstallWeChat.desktop
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								rm ~/.local/share/desktop-directories/wine-Programs-WeChat.directory
							 
						 
					
						
							
								
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								rm -rf ~/.local/share/applications/wine/Programs/WeChat/
							 
						 
					
						
							
								
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								rm ~/Desktop/WeChat.desktop
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								rm ~/.local/share/applications/wine/Programs/WeChat/WeChat.desktop
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo "[Desktop Entry]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Name=WeChat
							 
						 
					
						
							
								
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Exec=env BOX86_NOBANNER=1 env WINEPREFIX=$HOME/.config/wechat-prefix wine $HOME/.config/wechat-prefix/drive_c/Program\ Files/Tencent/WeChat/WeChat.exe
							 
						 
					
						
							
								
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Type=Application
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								StartupNotify=true
							 
						 
					
						
							
								
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Path=$HOME/.config/wechat-prefix/drive_c/Program\ Files/Tencent/WeChat/
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Icon=$HOME/pi-apps/apps/Wechat/icon-64.png" > ~/Desktop/WeChat.desktop
							 
						 
					
						
							
								
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								cp ~/Desktop/WeChat.desktop ~/.local/share/applications/WeChat.desktop
							 
						 
					
						
							
								
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo 'Install complete! Open WeChat now by using the desktop shortcut in your desktop or in the start menu.'