#!/usr/bin/env sh # vim: syntax=sh if [ -n "${SH_TRACE}" ]; then # shellcheck disable=2016 PS4="$(printf '%b%s%b:\n' '\033[31m' 'L${LINENO}' '\033[0m')" export PS4 set -x fi readonly appName='notepadpp' readonly exeName='notepad++.exe' readonly pkgDir="/usr/share/${appName}" readonly localDir="${HOME}/.local/share/${appName}" readonly configDir="${HOME}/.config/${appName}" readonly cacheDir="${HOME}/.cache/${appName}" # shellcheck disable=2155 readonly uid="$(id -u)" # shellcheck disable=2155 readonly gid="$(id -g)" cleanup() { while umount "${localDir}" 2>&1 | grep -q 'busy\.$' ; do sleep 2 done } # Create necessary directories for appDir in "${localDir}" "${cacheDir}" "${configDir}"; do if [ ! -d "${appDir}" ]; then mkdir -p "${appDir}" fi done # Unmount fuse-overlayfs just in case if mount | grep -q "${localDir}"; then cleanup fi # Mount the necessary directories with id mapping if ! fuse-overlayfs -o squash_to_uid="${uid}" -o squash_to_gid="${gid}" \ -o lowerdir="${pkgDir}" -o upperdir="${configDir}" -o workdir="${cacheDir}" \ "${localDir}"; then print 'Mount failed: cannot mount fuse-overlayfs\n' >&2 exit 1 fi trap 'cleanup' INT TERM EXIT # Use default WINEPREFIX - usually ~/.wine unset WINEPREFIX # Don't prompt to wine-mono and wine-gecko install - neither is needed WINEDLLOVERRIDES="${WINEDLLOVERRIDES};mscoree=d;mshtml=d" # If WINEDEBUG is explicitly set as env var use it if [ -z "${WINEDEBUG}" ]; then WINEDEBUG=-all fi export WINEPREFIX WINEDLLOVERRIDES WINEDEBUG wine "${localDir}/${exeName}" "${@}"