Merge remote-tracking branch 'LDprg/precommit-legacy'

This commit is contained in:
Oskar Manhart 2024-05-26 11:04:56 +02:00
commit 505c018998
63 changed files with 1114 additions and 1050 deletions

View File

@ -1,4 +1,53 @@
ci:
autoupdate_branch: "rewrite"
repos: []
repos:
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: chmod
args: ["775"]
files: (\.sh|winapps)$
- id: forbid-crlf
- id: remove-crlf
- id: forbid-tabs
- id: remove-tabs
args: [--whitespaces-count, "2"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: forbid-new-submodules
- id: forbid-submodules
- id: mixed-line-ending
- id: pretty-format-json
args: ["--autofix", "--no-sort-keys"]
- id: sort-simple-yaml
- id: trailing-whitespace
- repo: https://github.com/lovesegfault/beautysh
rev: v6.2.1
hooks:
- id: beautysh
additional_dependencies:
- setuptools
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck

0
apps/acrobat-x-pro/icon.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

0
apps/adobe-cc/icon.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 329 B

0
apps/aftereffects-cc/icon.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 916 B

After

Width:  |  Height:  |  Size: 917 B

0
apps/audition-cc/icon.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 329 B

0
apps/bridge-cc/icon.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

0
apps/bridge-cs6-x86/icon.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

0
apps/bridge-cs6/icon.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

0
apps/illustrator-cc/icon.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 681 B

After

Width:  |  Height:  |  Size: 682 B

0
apps/indesign-cc/icon.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 811 B

After

Width:  |  Height:  |  Size: 812 B

0
apps/lightroom-cc/icon.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 627 B

After

Width:  |  Height:  |  Size: 628 B

View File

@ -1,43 +1,45 @@
#!/usr/bin/env bash
if [ ! -f "${HOME}/.config/winapps/winapps.conf" ] && [ ! -f "${HOME}/.winapps" ]; then
if [ ! -f "$HOME/.config/winapps/winapps.conf" ] && [ ! -f "$HOME/.winapps" ]; then
echo "You need to create a ~/.config/winapps/winapps.conf configuration. Exiting..."
exit
fi
DIR="$(dirname "$(readlink -f "$0")")"
RUN="$(date)-${RANDOM}"
RUN="$(date)-$RANDOM"
if [ ! -d "${HOME}/.local/share/winapps" ]; then
mkdir -p "${HOME}/.local/share/winapps"
if [ ! -d "$HOME/.local/share/winapps" ]; then
mkdir -p "$HOME/.local/share/winapps"
fi
RDP_SCALE=100
if [ -f "${HOME}/.config/winapps/winapps.conf" ]; then
. "${HOME}/.config/winapps/winapps.conf"
if [ -f "$HOME/.config/winapps/winapps.conf" ]; then
# shellcheck source=/dev/null
. "$HOME/.config/winapps/winapps.conf"
else
. "${HOME}/.winapps"
# shellcheck source=/dev/null
. "$HOME/.winapps"
fi
function dprint() {
if [ "${DEBUG}" = "true" ]; then
echo "[${RUN}] ${1}" >>"${HOME}/.local/share/winapps/winapps.log"
if [ "$DEBUG" = "true" ]; then
echo "[$RUN] $1" >>"$HOME/.local/share/winapps/winapps.log"
fi
}
dprint "START"
if [ -f "${HOME}/.local/share/winapps/run" ]; then
LAST_RAN=$(stat -t -c %Y "${HOME}/.local/share/winapps/run")
if [ -f "$HOME/.local/share/winapps/run" ]; then
LAST_RAN=$(stat -t -c %Y "$HOME/.local/share/winapps/run")
dprint "LAST_RAN:${LAST_RAN}"
touch "${HOME}/.local/share/winapps/run"
THIS_RUN=$(stat -t -c %Y "${HOME}/.local/share/winapps/run")
dprint "THIS_RUN:${THIS_RUN}"
touch "$HOME/.local/share/winapps/run"
THIS_RUN=$(stat -t -c %Y "$HOME/.local/share/winapps/run")
dprint "THIS_RUN:$THIS_RUN"
if ((THIS_RUN - LAST_RAN < 2)); then
exit
fi
else
touch "${HOME}/.local/share/winapps/run"
touch "$HOME/.local/share/winapps/run"
fi
if [ -z "${FREERDP_COMMAND}" ]; then
@ -48,22 +50,22 @@ if [ -z "${FREERDP_COMMAND}" ]; then
then
FREERDP_COMMAND="xfreerdp3"
fi
elif command -v $FREERDP_COMMAND &> /dev/null
elif command -v "$FREERDP_COMMAND" &> /dev/null
then
dprint "Using custom freerdp command ${FREERDP_COMMAND}"
dprint "Using custom freerdp command $FREERDP_COMMAND"
else
echo "You have supplied a custom FreeRDP command, but the command is not available."
exit
fi
if [ -z "${RDP_IP}" ]; then
if [ ! "$(groups | grep -v libvirt)" ]; then
if [ -z "$RDP_IP" ]; then
if groups | grep -vq libvirt; then
echo "You are not a member of the libvirt group. Run the below then reboot."
echo ' sudo usermod -a -G libvirt $(whoami)'
echo ' sudo usermod -a -G kvm $(whoami)'
echo " sudo usermod -a -G libvirt $(whoami)"
echo " sudo usermod -a -G kvm $(whoami)"
exit
fi
if [ ! "$(virsh list | grep -v RDPWindows)" ]; then
if virsh list | grep -vq RDPWindows; then
echo "RDPWindows is not running, run:"
echo " virsh start RDPWindows"
exit
@ -73,50 +75,51 @@ if [ -z "${RDP_IP}" ]; then
fi
dprint "1:${1}"
dprint "2:${2}"
dprint "1:$1"
dprint "2:$2"
# this is just for debug logging anyways
# shellcheck disable=SC2145
dprint "@:${@}"
MULTI_FLAG="+span"
if [ "${MULTIMON}" = "true" ]; then
if [ "$MULTIMON" = "true" ]; then
MULTI_FLAG="/multimon"
fi
if [ "${1}" = "windows" ]; then
$FREERDP_COMMAND ${RDP_FLAGS} /d:"${RDP_DOMAIN}" /u:"${RDP_USER}" /p:"${RDP_PASS}" /scale:${RDP_SCALE} +dynamic-resolution +auto-reconnect +home-drive /wm-class:"Microsoft Windows" /v:${RDP_IP} 1>/dev/null 2>&1 &
elif [ "${1}" = "check" ]; then
if [ "$1" = "windows" ]; then
$FREERDP_COMMAND "$RDP_FLAGS" /d:"$RDP_DOMAIN" /u:"$RDP_USER" /p:"$RDP_PASS" /scale:$RDP_SCALE +dynamic-resolution +auto-reconnect +home-drive /wm-class:"Microsoft Windows" /v:"$RDP_IP" 1>/dev/null 2>&1 &
elif [ "$1" = "check" ]; then
dprint "CHECK"
$FREERDP_COMMAND ${RDP_FLAGS} /d:"${RDP_DOMAIN}" /u:"${RDP_USER}" /p:"${RDP_PASS}" /scale:${RDP_SCALE} +auto-reconnect +home-drive -wallpaper +dynamic-resolution ${MULTI_FLAG} /app:program:"explorer.exe" /v:${RDP_IP}
elif [ "${1}" = "manual" ]; then
dprint "MANUAL:${2}"
$FREERDP_COMMAND ${RDP_FLAGS} /d:"${RDP_DOMAIN}" /u:"${RDP_USER}" /p:"${RDP_PASS}" /scale:${RDP_SCALE} +auto-reconnect +home-drive +dynamic-resolution ${MULTI_FLAG} /app:program:"${2}" /v:"${RDP_IP}" 1>/dev/null 2>&1 &
elif [ "${1}" != "install" ]; then
$FREERDP_COMMAND "$RDP_FLAGS" /d:"$RDP_DOMAIN" /u:"$RDP_USER" /p:"$RDP_PASS" /scale:$RDP_SCALE +auto-reconnect +home-drive -wallpaper +dynamic-resolution $MULTI_FLAG /app:program:"explorer.exe" /v:"$RDP_IP"
elif [ "$1" = "manual" ]; then
dprint "MANUAL:$2"
$FREERDP_COMMAND "$RDP_FLAGS" /d:"$RDP_DOMAIN" /u:"$RDP_USER" /p:"$RDP_PASS" /scale:$RDP_SCALE +auto-reconnect +home-drive +dynamic-resolution $MULTI_FLAG /app:program:"$2" /v:"$RDP_IP" 1>/dev/null 2>&1 &
elif [ "$1" != "install" ]; then
dprint "DIR:${DIR}"
if [ -e "${DIR}/../apps/${1}/info" ]; then
if [ -e "${DIR}/../apps/$1/info" ]; then
# shellcheck disable=SC1090
. "${DIR}/../apps/${1}/info"
ICON="${DIR}/../apps/${1}/icon.svg"
elif [ -e "${HOME}/.local/share/winapps/apps/${1}/info" ]; then
. "${DIR}/../apps/$1/info"
ICON="${DIR}/../apps/$1/icon.svg"
elif [ -e "$HOME/.local/share/winapps/apps/$1/info" ]; then
# shellcheck disable=SC1090
. "${HOME}/.local/share/winapps/apps/${1}/info"
ICON="${HOME}/.local/share/winapps/apps/${1}/icon.svg"
elif [ -e "/usr/local/share/winapps/apps/${1}/info" ]; then
. "$HOME/.local/share/winapps/apps/$1/info"
ICON="$HOME/.local/share/winapps/apps/$1/icon.svg"
elif [ -e "/usr/local/share/winapps/apps/$1/info" ]; then
# shellcheck disable=SC1090
. "/usr/local/share/winapps/apps/${1}/info"
ICON="/usr/local/share/winapps/apps/${1}/icon.svg"
. "/usr/local/share/winapps/apps/$1/info"
ICON="/usr/local/share/winapps/apps/$1/icon.svg"
else
echo "You need to run 'installer.sh' first."
exit 1
fi
if [ -n "${2}" ]; then
dprint "HOME:${HOME}"
FILE=$(echo "${2}" | sed 's|'"${HOME}"'|\\\\tsclient\\home|;s|/|\\|g;s|\\|\\\\|g')
if [ -n "$2" ]; then
dprint "HOME:$HOME"
FILE=$(echo "$2" | sed 's|'"$HOME"'|\\\\tsclient\\home|;s|/|\\|g;s|\\|\\\\|g')
dprint "FILE:${FILE}"
$FREERDP_COMMAND ${RDP_FLAGS} /d:"${RDP_DOMAIN}" /u:"${RDP_USER}" /p:"${RDP_PASS}" /scale:${RDP_SCALE} +auto-reconnect +clipboard +home-drive -wallpaper +dynamic-resolution ${MULTI_FLAG} /wm-class:"${FULL_NAME}" /app:program:"${WIN_EXECUTABLE}",icon:"${ICON}",name:"${FULL_NAME}",cmd:"\"$FILE\"" /v:"${RDP_IP}" 1>/dev/null 2>&1 &
# shellcheck disable=SC2140
$FREERDP_COMMAND "$RDP_FLAGS" /d:"$RDP_DOMAIN" /u:"$RDP_USER" /p:"$RDP_PASS" /scale:$RDP_SCALE +auto-reconnect +clipboard +home-drive -wallpaper +dynamic-resolution $MULTI_FLAG /wm-class:"$FULL_NAME" /app:program:"$WIN_EXECUTABLE",icon:"$ICON",name:"$FULL_NAME",cmd:"\"$FILE\"" /v:"$RDP_IP" 1>/dev/null 2>&1 &
else
$FREERDP_COMMAND ${RDP_FLAGS} /d:"${RDP_DOMAIN}" /u:"${RDP_USER}" /p:"${RDP_PASS}" /scale:${RDP_SCALE} +auto-reconnect +clipboard +home-drive -wallpaper +dynamic-resolution ${MULTI_FLAG} /wm-class:"${FULL_NAME}" /app:program:"${WIN_EXECUTABLE}",icon:"${ICON}",name:"${FULL_NAME}" /v:"${RDP_IP}" 1>/dev/null 2>&1 &
$FREERDP_COMMAND "$RDP_FLAGS" /d:"$RDP_DOMAIN" /u:"$RDP_USER" /p:"$RDP_PASS" /scale:$RDP_SCALE +auto-reconnect +clipboard +home-drive -wallpaper +dynamic-resolution $MULTI_FLAG /wm-class:"$FULL_NAME" /app:program:"$WIN_EXECUTABLE",icon:"$ICON",name:"$FULL_NAME" /v:"$RDP_IP" 1>/dev/null 2>&1 &
fi
fi

View File

@ -198,6 +198,3 @@ sudo systemctl restart libvirtd
sudo ln -s /etc/apparmor.d/usr.sbin.libvirtd /etc/apparmor.d/disable/
```
You will likely need to reboot to ensure your current shell is added to the group.

View File

@ -219,4 +219,3 @@ Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\*" |
"EXES+=(""$Exe"")"
"ICONS+=(""$Icon"")"
}

View File

@ -26,6 +26,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# shellcheck disable=all
# store the current set options
OLD_SET=$-
set -e

View File

@ -11,45 +11,51 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
MAKEDEMO=0
USEDEMO=0
. "${DIR}/install/inquirer.sh"
# shellcheck disable=SC1094
. "$DIR/install/inquirer.sh"
INSTALLED_EXES=()
function waUsage() {
echo 'Usage:
./installer.sh --user # Install everything in ${HOME}
./installer.sh --system # Install everything in /usr'
echo "Usage:
./installer.sh --user # Install everything in $HOME
./installer.sh --system # Install everything in /usr"
exit
}
function waNoSudo() {
echo 'You are attempting to switch from a --system install to a --user install.
Please run "./installer.sh --system --uninstall" first.'
echo "You are attempting to switch from a --system install to a --user install.
Please run \"./installer.sh --system --uninstall\" first."
exit
}
function waInstall() {
${SUDO} mkdir -p "${SYS_PATH}/apps"
. "${DIR}/bin/winapps" install
$SUDO mkdir -p "$SYS_PATH/apps"
. "$DIR/bin/winapps" install
}
function waFindInstalled() {
echo -n " Checking for installed apps in RDP machine (this may take a while)..."
if [ $USEDEMO != 1 ]; then
rm -f ${HOME}/.local/share/winapps/installed.bat
rm -f ${HOME}/.local/share/winapps/installed.tmp
rm -f ${HOME}/.local/share/winapps/installed
rm -f ${HOME}/.local/share/winapps/detected
cp "${DIR}/install/ExtractPrograms.ps1" ${HOME}/.local/share/winapps/ExtractPrograms.ps1
for F in $(ls "${DIR}/apps"); do
. "${DIR}/apps/${F}/info"
echo "IF EXIST \"${WIN_EXECUTABLE}\" ECHO ${F} >> \\\\tsclient\\home\\.local\\share\\winapps\\installed.tmp" >>${HOME}/.local/share/winapps/installed.bat
rm -f "$HOME/.local/share/winapps/installed.bat"
rm -f "$HOME/.local/share/winapps/installed.tmp"
rm -f "$HOME/.local/share/winapps/installed"
rm -f "$HOME/.local/share/winapps/detected"
cp "$DIR/install/ExtractPrograms.ps1" "$HOME/.local/share/winapps/ExtractPrograms.ps1"
# FIXME
# shellcheck disable=SC2066
for F in "$DIR/apps"; do
[[ -e "$F" ]] || break
# shellcheck disable=SC1090
. "$DIR/apps/$F/info"
printf "IF EXIST \"%s\" ECHO %s >> \\\\tsclient\\home\\.local\\share\\winapps\\installed.tmp" "$WIN_EXECUTABLE" "$F" >>"$HOME/.local/share/winapps/installed.bat"
done
echo "powershell.exe -ExecutionPolicy Bypass -File \\\\tsclient\\home\\.local\\share\\winapps\\ExtractPrograms.ps1 > \\\\tsclient\home\\.local\\share\\winapps\\detected" >>${HOME}/.local/share/winapps/installed.bat
echo "RENAME \\\\tsclient\\home\\.local\\share\\winapps\\installed.tmp installed" >>${HOME}/.local/share/winapps/installed.bat
$FREERDP_COMMAND /d:"${RDP_DOMAIN}" /u:"${RDP_USER}" /p:"${RDP_PASS}" +auto-reconnect +home-drive -wallpaper +span /app:program:"C:\Windows\System32\cmd.exe",cmd:"/C \\\\tsclient\\home\\.local\\share\\winapps\\installed.bat" /v:${RDP_IP} 1>/dev/null 2>&1 &
printf "powershell.exe -ExecutionPolicy Bypass -File \\\\tsclient\\home\\.local\\share\\winapps\\ExtractPrograms.ps1 > \\\\tsclient\home\\.local\\share\\winapps\\detected" >>"$HOME/.local/share/winapps/installed.bat"
printf "RENAME \\\\tsclient\\home\\.local\\share\\winapps\\installed.tmp installed" >>"$HOME/.local/share/winapps/installed.bat"
# shellcheck disable=SC2140
$FREERDP_COMMAND /d:"$RDP_DOMAIN" /u:"$RDP_USER" /p:"$RDP_PASS" +auto-reconnect +home-drive -wallpaper +span /app:program:"C:\Windows\System32\cmd.exe",cmd:"/C \\\\tsclient\\home\\.local\\share\\winapps\\installed.bat" /v:"$RDP_IP" 1>/dev/null 2>&1 &
COUNT=0
while [ ! -f "${HOME}/.local/share/winapps/installed" ]; do
while [ ! -f "$HOME/.local/share/winapps/installed" ]; do
sleep 5
COUNT=$((COUNT + 1))
if ((COUNT == 15)); then
@ -69,42 +75,41 @@ function waFindInstalled() {
done
if [ $MAKEDEMO = 1 ]; then
rm -rf /tmp/winapps_demo
cp -a ${HOME}/.local/share/winapps /tmp/winapps_demo
cp -a "$HOME/.local/share/winapps" /tmp/winapps_demo
exit
fi
else
rm -rf ${HOME}/.local/share/winapps
cp -a /tmp/winapps_demo ${HOME}/.local/share/winapps
rm -rf "$HOME/.local/share/winapps"
cp -a /tmp/winapps_demo "$HOME/.local/share/winapps"
#sleep 3
fi
echo " Finished."
}
function waConfigureApp() {
if [ -z "${ICON}" ]; then
ICON=${SYS_PATH}/apps/${1}/icon.${2}
if [ -z "$ICON" ]; then
ICON=$SYS_PATH/apps/$1/icon.$2
fi
. "${SYS_PATH}/apps/${1}/info"
echo -n " Configuring ${NAME}..."
if [ ${USEDEMO} != 1 ]; then
${SUDO} rm -f "${APP_PATH}/${1}.desktop"
# shellcheck disable=SC1090
. "$SYS_PATH/apps/$1/info"
echo -n " Configuring $NAME..."
if [ $USEDEMO != 1 ]; then
$SUDO rm -f "$APP_PATH/$1.desktop"
echo "[Desktop Entry]
Name=${NAME}
Exec=${BIN_PATH}/winapps ${1} %F
Name=$NAME
Exec=$BIN_PATH/winapps $1 %F
Terminal=false
Type=Application
Icon=$ICON
StartupWMClass=${FULL_NAME}
Comment=${FULL_NAME}
Categories=${CATEGORIES}
MimeType=${MIME_TYPES}
" | ${SUDO} tee "${APP_PATH}/${1}.desktop" >/dev/null
${SUDO} rm -f "${BIN_PATH}/${1}"
echo "#!/usr/bin/env bash
${BIN_PATH}/winapps ${1} $@
" | ${SUDO} tee "${BIN_PATH}/${1}" >/dev/null
${SUDO} chmod a+x "${BIN_PATH}/${1}"
StartupWMClass=$FULL_NAME
Comment=$FULL_NAME
Categories=$CATEGORIES
MimeType=$MIME_TYPES
" | $SUDO tee "$APP_PATH/$1.desktop" >/dev/null
$SUDO rm -f "$BIN_PATH/$1"
echo "#!/usr/bin/env bash $BIN_PATH/winapps $1 $*
" | $SUDO tee "$BIN_PATH/$1" >/dev/null
$SUDO chmod a+x "$BIN_PATH/$1"
fi
echo " Finished."
@ -113,109 +118,114 @@ ${BIN_PATH}/winapps ${1} $@
function waConfigureApps() {
APPS=()
for F in $(cat "${HOME}/.local/share/winapps/installed" | sed 's/\r/\n/g'); do
. "${DIR}/apps/${F}/info"
APPS+=("${FULL_NAME} (${F})")
while IFS= read -r F; do
# shellcheck disable=SC1090
. "$DIR/apps/$F/info"
APPS+=("$FULL_NAME ($F)")
INSTALLED_EXES+=("$(echo "${WIN_EXECUTABLE##*\\}" | tr '[:upper:]' '[:lower:]')")
done
done < <(sed 's/\r/\n/g' < "$HOME/.local/share/winapps/installed")
# FIXME
# shellcheck disable=SC2207,SC2031
IFS=$'\n' APPS=($(sort <<<"${APPS[*]}"))
unset IFS
OPTIONS=("Set up all detected pre-configured applications" "Select which pre-configured applications to set up" "Do not set up any pre-configured applications")
if [ "${INSTALL_TYPE}" != 'User' ]; then
if [ "$INSTALL_TYPE" != 'User' ]; then
menuFromArr APP_INSTALL "How would you like to handle WinApps pre-configured applications?" "${OPTIONS[@]}"
else "grep -l -d skip"
menuFromArr APP_INSTALL "How would you like to handle WinApps pre-configured applications? If any web browser is set-up, may be configured as default browser." "${OPTIONS[@]}"
fi
if [ "${APP_INSTALL}" = "Select which pre-configured applications to set up" ]; then
if [ "$APP_INSTALL" = "Select which pre-configured applications to set up" ]; then
checkbox_input "Which pre-configured apps would you like to set up?" APPS SELECTED_APPS
echo "" >"${HOME}/.local/share/winapps/installed"
echo "" >"$HOME/.local/share/winapps/installed"
for F in "${SELECTED_APPS[@]}"; do
APP="${F##*(}"
APP="${APP%%)}"
echo "${APP}" >>"${HOME}/.local/share/winapps/installed"
echo "${APP}" >>"$HOME/.local/share/winapps/installed"
done
fi
${SUDO} cp "${DIR}/bin/winapps" "${BIN_PATH}/winapps"
$SUDO cp "$DIR/bin/winapps" "$BIN_PATH/winapps"
COUNT=0
if [ "${APP_INSTALL}" != "Do not set up any pre-configured applications" ]; then
for F in $(cat "${HOME}/.local/share/winapps/installed" | sed 's/\r/\n/g'); do
if [ "$APP_INSTALL" != "Do not set up any pre-configured applications" ]; then
while IFS= read -r F; do
COUNT=$((COUNT + 1))
${SUDO} cp -r "apps/${F}" "${SYS_PATH}/apps"
waConfigureApp "${F}" svg
done
$SUDO cp -r "apps/$F" "$SYS_PATH/apps"
waConfigureApp "$F" svg
done < <(sed 's/\r/\n/g' < "$HOME/.local/share/winapps/installed")
fi
rm -f "${HOME}/.local/share/winapps/installed"
rm -f "${HOME}/.local/share/winapps/installed.bat"
if (($COUNT == 0)); then
rm -f "$HOME/.local/share/winapps/installed"
rm -f "$HOME/.local/share/winapps/installed.bat"
if ((COUNT == 0)); then
echo " No configured applications."
fi
}
function waConfigureAppsAllOfficiallySupported(){
${SUDO} cp "${DIR}/bin/winapps" "${BIN_PATH}/winapps"
$SUDO cp "$DIR/bin/winapps" "$BIN_PATH/winapps"
COUNT=0
for F in $(cat "${HOME}/.local/share/winapps/installed" | sed 's/\r/\n/g'); do
while IFS= read -r F; do
COUNT=$((COUNT + 1))
${SUDO} cp -r "apps/${F}" "${SYS_PATH}/apps"
waConfigureApp "${F}" svg
done
rm -f "${HOME}/.local/share/winapps/installed"
rm -f "${HOME}/.local/share/winapps/installed.bat"
if (($COUNT == 0)); then
$SUDO cp -r "apps/$F" "$SYS_PATH/apps"
waConfigureApp "$F" svg
done < <(sed 's/\r/\n/g' < "$HOME/.local/share/winapps/installed")
rm -f "$HOME/.local/share/winapps/installed"
rm -f "$HOME/.local/share/winapps/installed.bat"
if ((COUNT == 0)); then
echo " No configured applications."
fi
}
function waConfigureDetectedApps() {
if [ -f "${HOME}/.local/share/winapps/detected" ]; then
sed -i 's/\r//g' "${HOME}/.local/share/winapps/detected"
. "${HOME}/.local/share/winapps/detected"
if [ -f "$HOME/.local/share/winapps/detected" ]; then
sed -i 's/\r//g' "$HOME/.local/share/winapps/detected"
# shellcheck disable=SC1091
. "$HOME/.local/share/winapps/detected"
APPS=()
# shellcheck disable=SC2153
for I in "${!NAMES[@]}"; do
EXE=${EXES[$I]##*\\}
EXE_LOWER=$(echo "${EXE}" | tr '[:upper:]' '[:lower:]')
EXE_LOWER=$(echo "$EXE" | tr '[:upper:]' '[:lower:]')
if (
dlm=$'\x1F'
IFS="$dlm"
[[ "$dlm${INSTALLED_EXES[*]}$dlm" != *"$dlm${EXE_LOWER}$dlm"* ]]
[[ "$dlm${INSTALLED_EXES[*]}$dlm" != *"$dlm$EXE_LOWER$dlm"* ]]
); then
APPS+=("${NAMES[$I]} (${EXE})")
APPS+=("${NAMES[$I]} ($EXE)")
fi
done
IFS=$'\n' APPS=($(sort <<<"${APPS[*]}"))
IFS=$'\n' APPS=("$(sort <<<"${APPS[*]}")")
unset IFS
OPTIONS=("Set up all detected applications" "Select which applications to set up" "Do not set up any applications")
menuFromArr APP_INSTALL "How would you like to handle other detected applications?" "${OPTIONS[@]}"
if [ "${APP_INSTALL}" = "Select which applications to set up" ]; then
if [ "$APP_INSTALL" = "Select which applications to set up" ]; then
checkbox_input "Which other apps would you like to set up?" APPS SELECTED_APPS
echo "" >"${HOME}/.local/share/winapps/installed"
echo "" >"$HOME/.local/share/winapps/installed"
for F in "${SELECTED_APPS[@]}"; do
EXE="${F##*(}"
EXE="${EXE%%)}"
APP="${F% (*}"
echo "${EXE}|${APP}" >>"${HOME}/.local/share/winapps/installed"
echo "$EXE|${APP}" >>"$HOME/.local/share/winapps/installed"
done
elif [ "${APP_INSTALL}" = "Set up all detected applications" ]; then
elif [ "$APP_INSTALL" = "Set up all detected applications" ]; then
for I in "${!EXES[@]}"; do
EXE=${EXES[$I]##*\\}
echo "${EXE}|${NAMES[$I]}" >>"${HOME}/.local/share/winapps/installed"
echo "$EXE|${NAMES[$I]}" >>"$HOME/.local/share/winapps/installed"
done
fi
COUNT=0
if [ -f "${HOME}/.local/share/winapps/installed" ]; then
while read LINE; do
if [ -f "$HOME/.local/share/winapps/installed" ]; then
while read -r LINE; do
EXE="${LINE%|*}"
NAME="${LINE#*|}"
for I in "${!NAMES[@]}"; do
if [ "${NAME}" = "${NAMES[$I]}" ] && [[ "${EXES[$I]}" == *"\\${EXE}" ]]; then
EXE=$(echo "${EXE}" | tr '[:upper:]' '[:lower:]')
${SUDO} mkdir -p "${SYS_PATH}/apps/${EXE}"
if [ "$NAME" = "${NAMES[$I]}" ] && [[ "${EXES[$I]}" == *"\\$EXE" ]]; then
EXE=$(echo "$EXE" | tr '[:upper:]' '[:lower:]')
$SUDO mkdir -p "$SYS_PATH/apps/$EXE"
echo "# GNOME shortcut name
NAME=\"${NAME}\"
NAME=\"$NAME\"
# Used for descriptions and window class
FULL_NAME=\"${NAME}\"
FULL_NAME=\"$NAME\"
# The executable inside windows
WIN_EXECUTABLE=\"${EXES[$I]}\"
@ -225,17 +235,18 @@ CATEGORIES=\"WinApps\"
# GNOME mimetypes
MIME_TYPES=\"\"
" | sudo tee "${SYS_PATH}/apps/${EXE}/info" >/dev/null
echo "${ICONS[$I]}" | base64 -d | sudo tee "${SYS_PATH}/apps/${EXE}/icon.ico" >/dev/null
waConfigureApp "${EXE}" ico
" | sudo tee "$SYS_PATH/apps/$EXE/info" >/dev/null
# shellcheck disable=SC2153
echo "${ICONS[$I]}" | base64 -d | sudo tee "$SYS_PATH/apps/$EXE/icon.ico" >/dev/null
waConfigureApp "$EXE" ico
COUNT=$((COUNT + 1))
fi
done
done <"${HOME}/.local/share/winapps/installed"
rm -f "${HOME}/.local/share/winapps/installed"
done <"$HOME/.local/share/winapps/installed"
rm -f "$HOME/.local/share/winapps/installed"
fi
rm -f "${HOME}/.local/share/winapps/installed.bat"
if (($COUNT == 0)); then
rm -f "$HOME/.local/share/winapps/installed.bat"
if ((COUNT == 0)); then
echo " No configured applications."
fi
fi
@ -243,90 +254,94 @@ MIME_TYPES=\"\"
function waConfigureWindows() {
echo -n " Configuring Windows..."
if [ ${USEDEMO} != 1 ]; then
${SUDO} rm -f "${APP_PATH}/windows.desktop"
${SUDO} mkdir -p "${SYS_PATH}/icons"
${SUDO} cp "${DIR}/icons/windows.svg" "${SYS_PATH}/icons/windows.svg"
if [ $USEDEMO != 1 ]; then
$SUDO rm -f "$APP_PATH/windows.desktop"
$SUDO mkdir -p "$SYS_PATH/icons"
$SUDO cp "$DIR/icons/windows.svg" "$SYS_PATH/icons/windows.svg"
echo "[Desktop Entry]
Name=Windows
Exec=${BIN_PATH}/winapps windows %F
Exec=$BIN_PATH/winapps windows %F
Terminal=false
Type=Application
Icon=${SYS_PATH}/icons/windows.svg
Icon=$SYS_PATH/icons/windows.svg
StartupWMClass=Microsoft Windows
Comment=Microsoft Windows
" | ${SUDO} tee "${APP_PATH}/windows.desktop" >/dev/null
${SUDO} rm -f "${BIN_PATH}/windows"
" | $SUDO tee "$APP_PATH/windows.desktop" >/dev/null
$SUDO rm -f "$BIN_PATH/windows"
echo "#!/usr/bin/env bash
${BIN_PATH}/winapps windows
" | ${SUDO} tee "/${BIN_PATH}/windows" >/dev/null
${SUDO} chmod a+x "${BIN_PATH}/windows"
$BIN_PATH/winapps windows
" | $SUDO tee "/$BIN_PATH/windows" >/dev/null
$SUDO chmod a+x "$BIN_PATH/windows"
fi
echo " Finished."
}
function waUninstallUser() {
rm -f "${HOME}/.local/bin/winapps"
rm -rf "${HOME}/.local/share/winapps"
for F in $(grep -l -d skip "bin/winapps" "${HOME}/.local/share/applications/"* -s); do
echo -n " Removing ${F}..."
${SUDO} rm ${F}
rm -f "$HOME/.local/bin/winapps"
rm -rf "$HOME/.local/share/winapps"
grep -l -d skip "bin/winapps" "$HOME/.local/share/applications/"* -s | while IFS= read -r F
do
echo -n " Removing $F..."
"$SUDO" rm "$F"
echo " Finished."
done
for F in $(grep -l -d skip "bin/winapps" "${HOME}/.local/bin/"* -s); do
echo -n " Removing ${F}..."
${SUDO} rm ${F}
grep -l -d skip "bin/winapps" "$HOME/.local/bin/"* -s | while IFS= read -r F
do
echo -n " Removing $F..."
"$SUDO" rm "$F"
echo " Finished."
done
}
function waUninstallSystem() {
${SUDO} rm -f "/usr/local/bin/winapps"
${SUDO} rm -rf "/usr/local/share/winapps"
for F in $(grep -l -d skip "bin/winapps" "/usr/share/applications/"* -s); do
if [ -z "${SUDO}" ]; then
"$SUDO" rm -f "/usr/local/bin/winapps"
"$SUDO" rm -rf "/usr/local/share/winapps"
grep -l -d skip "bin/winapps" "/usr/share/applications/"* -s | while IFS= read -r F
do
if [ -z "$SUDO" ]; then
waNoSudo
fi
echo -n " Removing ${F}..."
${SUDO} rm ${F}
echo -n " Removing $F..."
"$SUDO" rm "$F"
echo " Finished."
done
for F in $(grep -l -d skip "bin/winapps" "/usr/local/bin/"* -s); do
if [ -z "${SUDO}" ]; then
grep -l -d skip "bin/winapps" "/usr/local/bin/"* -s | while IFS= read -r F
do
if [ -z "$SUDO" ]; then
waNoSudo
fi
echo -n " Removing ${F}..."
${SUDO} rm ${F}
echo -n " Removing $F..."
"$SUDO" rm "$F"
echo " Finished."
done
}
if [ -z "${1}" ]; then
if [ -z "$1" ]; then
OPTIONS=(User System)
menuFromArr INSTALL_TYPE "Would you like to install for the current user or the whole system?" "${OPTIONS[@]}"
elif [ "${1}" = '--user' ]; then
elif [ "$1" = '--user' ]; then
INSTALL_TYPE='User'
elif [ "${1}" = '--system' ]; then
elif [ "$1" = '--system' ]; then
INSTALL_TYPE='System'
else
waUsage
fi
if [ "${INSTALL_TYPE}" = 'User' ]; then
if [ "$INSTALL_TYPE" = 'User' ]; then
SUDO=""
BIN_PATH="${HOME}/.local/bin"
APP_PATH="${HOME}/.local/share/applications"
SYS_PATH="${HOME}/.local/share/winapps"
mkdir -p $BIN_PATH
mkdir -p $APP_PATH
mkdir -p $SYS_PATH
if [ -n "${2}" ]; then
if [ "${2}" = '--uninstall' ]; then
BIN_PATH="$HOME/.local/bin"
APP_PATH="$HOME/.local/share/applications"
SYS_PATH="$HOME/.local/share/winapps"
mkdir -p "$BIN_PATH"
mkdir -p "$APP_PATH"
mkdir -p "$SYS_PATH"
if [ -n "$2" ]; then
if [ "$2" = '--uninstall' ]; then
# Uninstall
echo "Uninstalling..."
waUninstallUser
exit
elif [ "${2}" = '--setupAllOfficiallySupportedApps' ]; then
elif [ "$2" = '--setupAllOfficiallySupportedApps' ]; then
echo "Setting up All Officially Supported Apps "
echo "Removing any old configurations..."
waUninstallUser
@ -340,19 +355,19 @@ if [ "${INSTALL_TYPE}" = 'User' ]; then
usage
fi
fi
elif [ "${INSTALL_TYPE}" = 'System' ]; then
elif [ "$INSTALL_TYPE" = 'System' ]; then
SUDO="sudo"
sudo ls >/dev/null
BIN_PATH="/usr/local/bin"
APP_PATH="/usr/share/applications"
SYS_PATH="/usr/local/share/winapps"
if [ -n "${2}" ]; then
if [ "${2}" = '--uninstall' ]; then
if [ -n "$2" ]; then
if [ "$2" = '--uninstall' ]; then
# Uninstall
echo "Uninstalling..."
waUninstallSystem
exit
elif [ "${2}" = '--setupAllOfficiallySupportedApps' ]; then
elif [ "$2" = '--setupAllOfficiallySupportedApps' ]; then
echo "Setting up All Officially Supported Apps "
echo "Removing any old configurations..."
waUninstallUser

View File

@ -208,4 +208,3 @@
<imagelabel>+385601105:+385600513</imagelabel>
</seclabel>
</domain>