summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xkakaotalk161
1 files changed, 81 insertions, 80 deletions
diff --git a/kakaotalk b/kakaotalk
index dc37780..b81b632 100755
--- a/kakaotalk
+++ b/kakaotalk
@@ -11,9 +11,9 @@ set -e -o pipefail
###########################################################
function _check_wine() {
- WINE_EXE="$1"
+ WINE_EXE="$1"
- ls "${WINE_EXE}" >/dev/null 2>/dev/null
+ ls "${WINE_EXE}" >/dev/null 2>&1
}
###########################################################
@@ -21,58 +21,59 @@ function _check_wine() {
###########################################################
function _install_wine() {
- SRC_URL='https://app-pc.kakaocdn.net/talk/win32/KakaoTalk_Setup.exe'
- DST_FILE="$(mktemp)"
- WINE_EXE="$1"
-
- # Mock home directory
- HOME_ORIGIN="${HOME}"
- HOME_PATCH="${WINEPREFIX}/tmp"
- export HOME="${HOME_PATCH}"
-
- echo 'Installing Kakaotalk...'
- curl -s "${SRC_URL}" -o "${DST_FILE}"
- wineboot
- wine "${DST_FILE}" /S
- rm "${DST_FILE}"
-
- # Install Fonts
- _font_install
-
- # Remove tmp home directory
- rm -rf "${HOME_PATCH}"
-
- # Restore home directory
- export HOME="${HOME_ORIGIN}"
-
- # Link the wine home directory to the wild
- HOME_WINE="$(
- find "${WINEPREFIX}/drive_c/users" \
- -mindepth 1 -maxdepth 1 -type d -not -name 'Public'
- )"
-
- dirs="Desktop Documents Downloads Music Pictures Videos"
- [ -n "$HOME_WINE" ] && for dir in $dirs; do
- [ -d "${HOME_WINE}/${dir}" ] && rm -rf "${HOME_WINE}/${dir:?}"
- ln -sf "${HOME}/${dir:?}" "${HOME_WINE}/${dir:?}"
- done
-
- # Create a desktop shortcut
- if [ -d "${XDG_DATA_HOME:-${HOME}/.local/share}/applications" ]; then
- ICON_SRC='/usr/share/applications/kakaotalk.desktop'
- ICON_DST="${XDG_DATA_HOME:-${HOME}/.local/share}/applications/kakaotalk.desktop"
-
- if [ -f "${ICON_SRC}" ] && [ ! -f "${ICON_DST}" ]; then
- mkdir -p "$(dirname "${ICON_DST}")"
- cp "${ICON_SRC}" "${ICON_DST}"
- chmod u+x "${ICON_DST}"
-
- # # Mark as trusted
- # if which gio >/dev/null 2>/dev/null; then
- # gio set -t string "${ICON_DST}" metadata::xfce-exe-checksum "$(sha256sum "${ICON_SRC}" | awk '{print $1}')"
- # fi
- fi
+ SRC_URL='https://app-pc.kakaocdn.net/talk/win32/KakaoTalk_Setup.exe'
+ DST_FILE="$(mktemp)"
+ WINE_EXE="$1"
+
+ # Mock home directory
+ HOME_ORIGIN="${HOME}"
+ HOME_PATCH="${WINEPREFIX}/tmp"
+ export HOME="${HOME_PATCH}"
+
+ echo 'Installing Kakaotalk...'
+ [ -d "$WINEPREFIX" ] || mkdir -p "$WINEPREFIX"
+ curl -s "${SRC_URL}" -o "${DST_FILE}"
+ wineboot
+ wine "${DST_FILE}" /S
+ rm "${DST_FILE}"
+
+ # Install Fonts
+ _font_install
+
+ # Remove tmp home directory
+ rm -rf "${HOME_PATCH}"
+
+ # Restore home directory
+ export HOME="${HOME_ORIGIN}"
+
+ # Link the wine home directory to the wild
+ HOME_WINE="$(
+ find "${WINEPREFIX}/drive_c/users" \
+ -mindepth 1 -maxdepth 1 -type d -not -name 'Public' >/dev/null 2>&1
+ )"
+
+ dirs="Desktop Documents Downloads Music Pictures Videos"
+ [ -n "$HOME_WINE" ] && for dir in $dirs; do
+ [ -d "${HOME_WINE}/${dir}" ] && rm -rf "${HOME_WINE}/${dir:?}"
+ ln -sf "${HOME}/${dir:?}" "${HOME_WINE}/${dir:?}"
+ done
+
+ # Create a desktop shortcut
+ if [ -d "${XDG_DATA_HOME:-${HOME}/.local/share}/applications" ]; then
+ ICON_SRC='/usr/share/applications/kakaotalk.desktop'
+ ICON_DST="${XDG_DATA_HOME:-${HOME}/.local/share}/applications/kakaotalk.desktop"
+
+ if [ -f "${ICON_SRC}" ] && [ ! -f "${ICON_DST}" ]; then
+ mkdir -p "$(dirname "${ICON_DST}")"
+ cp "${ICON_SRC}" "${ICON_DST}"
+ chmod u+x "${ICON_DST}"
+
+ # # Mark as trusted
+ # if which gio >/dev/null 2>/dev/null; then
+ # gio set -t string "${ICON_DST}" metadata::xfce-exe-checksum "$(sha256sum "${ICON_SRC}" | awk '{print $1}')"
+ # fi
fi
+ fi
}
###########################################################
@@ -80,16 +81,16 @@ function _install_wine() {
###########################################################
function _font_install() {
- FONT_URL='https://campaign-cdn.pstatic.net/0/hangeul/2022/zip_v2/nanum-all.zip'
- DST_FONT="$(mktemp -d)"
- FONT_DIR="${WINEPREFIX}/drive_c/windows/Fonts"
-
- echo 'Installing Fonts...'
- curl -s "${FONT_URL}" -o "${DST_FONT}/nanum-all.zip" >/dev/null 2>&1
- ! command -v unzip &>/dev/null && sudo pacman -Sy unzip
- unzip "${DST_FONT}/nanum-all.zip" -d "${DST_FONT}" >/dev/null 2>&1
- find "${DST_FONT}" -type f -name "*.ttf" -exec mv -f {} "${FONT_DIR}" \;
- rm -rf "${DST_FONT}"
+ FONT_URL='https://campaign-cdn.pstatic.net/0/hangeul/2022/zip_v2/nanum-all.zip'
+ DST_FONT="$(mktemp -d)"
+ FONT_DIR="${WINEPREFIX}/drive_c/windows/Fonts"
+
+ echo 'Installing Fonts...'
+ curl -s "${FONT_URL}" -o "${DST_FONT}/nanum-all.zip" >/dev/null 2>&1
+ ! command -v unzip &>/dev/null && sudo pacman -Sy unzip
+ unzip "${DST_FONT}/nanum-all.zip" -d "${DST_FONT}" >/dev/null 2>&1
+ find "${DST_FONT}" -type f -name "*.ttf" -exec mv -f {} "${FONT_DIR}" \;
+ rm -rf "${DST_FONT}"
}
###########################################################
@@ -97,10 +98,10 @@ function _font_install() {
###########################################################
function _exec_wine() {
- WINE_EXE="$1"
+ WINE_EXE="$1"
- echo 'Executing Kakaotalk...'
- exec wine "${WINE_EXE}"
+ echo 'Executing Kakaotalk...'
+ exec wine "${WINE_EXE}"
}
###########################################################
@@ -109,20 +110,20 @@ function _exec_wine() {
# Define a main function
function main() {
- # Configure environment variables
- export LANG='en_US.UTF-8'
- export LC_ALL='en_US.UTF-8'
- export WINEARCH='win64'
- export WINEPREFIX="${WINEPREFIX:-${XDG_DATA_HOME:-${HOME}/.local/share}/wine}/kakaotalk"
-
- # Install
- WINE_EXE="${WINEPREFIX}/drive_c/Program Files (x86)/Kakao/KakaoTalk/KakaoTalk.exe"
- if ! _check_wine "${WINE_EXE}"; then
- _install_wine "${WINE_EXE}"
- fi
-
- # Exec
- _exec_wine "${WINE_EXE}"
+ # Configure environment variables
+ export LANG='en_US.UTF-8'
+ export LC_ALL='en_US.UTF-8'
+ export WINEARCH='win64'
+ export WINEPREFIX="${WINEPREFIX:-${XDG_DATA_HOME:-${HOME}/.local/share}/wine}/kakaotalk"
+
+ # Install
+ WINE_EXE="${WINEPREFIX}/drive_c/Program Files (x86)/Kakao/KakaoTalk/KakaoTalk.exe"
+ if ! _check_wine "${WINE_EXE}"; then
+ _install_wine "${WINE_EXE}"
+ fi
+
+ # Exec
+ _exec_wine "${WINE_EXE}"
}
# Execute main function