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: ci:
autoupdate_branch: "rewrite" 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 #!/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..." echo "You need to create a ~/.config/winapps/winapps.conf configuration. Exiting..."
exit exit
fi fi
DIR="$(dirname "$(readlink -f "$0")")" DIR="$(dirname "$(readlink -f "$0")")"
RUN="$(date)-${RANDOM}" RUN="$(date)-$RANDOM"
if [ ! -d "${HOME}/.local/share/winapps" ]; then if [ ! -d "$HOME/.local/share/winapps" ]; then
mkdir -p "${HOME}/.local/share/winapps" mkdir -p "$HOME/.local/share/winapps"
fi fi
RDP_SCALE=100 RDP_SCALE=100
if [ -f "${HOME}/.config/winapps/winapps.conf" ]; then if [ -f "$HOME/.config/winapps/winapps.conf" ]; then
. "${HOME}/.config/winapps/winapps.conf" # shellcheck source=/dev/null
. "$HOME/.config/winapps/winapps.conf"
else else
. "${HOME}/.winapps" # shellcheck source=/dev/null
. "$HOME/.winapps"
fi fi
function dprint() { function dprint() {
if [ "${DEBUG}" = "true" ]; then if [ "$DEBUG" = "true" ]; then
echo "[${RUN}] ${1}" >>"${HOME}/.local/share/winapps/winapps.log" echo "[$RUN] $1" >>"$HOME/.local/share/winapps/winapps.log"
fi fi
} }
dprint "START" dprint "START"
if [ -f "${HOME}/.local/share/winapps/run" ]; then if [ -f "$HOME/.local/share/winapps/run" ]; then
LAST_RAN=$(stat -t -c %Y "${HOME}/.local/share/winapps/run") LAST_RAN=$(stat -t -c %Y "$HOME/.local/share/winapps/run")
dprint "LAST_RAN:${LAST_RAN}" dprint "LAST_RAN:${LAST_RAN}"
touch "${HOME}/.local/share/winapps/run" touch "$HOME/.local/share/winapps/run"
THIS_RUN=$(stat -t -c %Y "${HOME}/.local/share/winapps/run") THIS_RUN=$(stat -t -c %Y "$HOME/.local/share/winapps/run")
dprint "THIS_RUN:${THIS_RUN}" dprint "THIS_RUN:$THIS_RUN"
if ((THIS_RUN - LAST_RAN < 2)); then if ((THIS_RUN - LAST_RAN < 2)); then
exit exit
fi fi
else else
touch "${HOME}/.local/share/winapps/run" touch "$HOME/.local/share/winapps/run"
fi fi
if [ -z "${FREERDP_COMMAND}" ]; then if [ -z "${FREERDP_COMMAND}" ]; then
@ -48,22 +50,22 @@ if [ -z "${FREERDP_COMMAND}" ]; then
then then
FREERDP_COMMAND="xfreerdp3" FREERDP_COMMAND="xfreerdp3"
fi fi
elif command -v $FREERDP_COMMAND &> /dev/null elif command -v "$FREERDP_COMMAND" &> /dev/null
then then
dprint "Using custom freerdp command ${FREERDP_COMMAND}" dprint "Using custom freerdp command $FREERDP_COMMAND"
else else
echo "You have supplied a custom FreeRDP command, but the command is not available." echo "You have supplied a custom FreeRDP command, but the command is not available."
exit exit
fi fi
if [ -z "${RDP_IP}" ]; then if [ -z "$RDP_IP" ]; then
if [ ! "$(groups | grep -v libvirt)" ]; then if groups | grep -vq libvirt; then
echo "You are not a member of the libvirt group. Run the below then reboot." 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 libvirt $(whoami)"
echo ' sudo usermod -a -G kvm $(whoami)' echo " sudo usermod -a -G kvm $(whoami)"
exit exit
fi fi
if [ ! "$(virsh list | grep -v RDPWindows)" ]; then if virsh list | grep -vq RDPWindows; then
echo "RDPWindows is not running, run:" echo "RDPWindows is not running, run:"
echo " virsh start RDPWindows" echo " virsh start RDPWindows"
exit exit
@ -73,50 +75,51 @@ if [ -z "${RDP_IP}" ]; then
fi fi
dprint "1:${1}" dprint "1:$1"
dprint "2:${2}" dprint "2:$2"
# this is just for debug logging anyways # this is just for debug logging anyways
# shellcheck disable=SC2145 # shellcheck disable=SC2145
dprint "@:${@}" dprint "@:${@}"
MULTI_FLAG="+span" MULTI_FLAG="+span"
if [ "${MULTIMON}" = "true" ]; then if [ "$MULTIMON" = "true" ]; then
MULTI_FLAG="/multimon" MULTI_FLAG="/multimon"
fi fi
if [ "${1}" = "windows" ]; 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 & $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 elif [ "$1" = "check" ]; then
dprint "CHECK" 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} $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 elif [ "$1" = "manual" ]; then
dprint "MANUAL:${2}" 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 & $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 elif [ "$1" != "install" ]; then
dprint "DIR:${DIR}" dprint "DIR:${DIR}"
if [ -e "${DIR}/../apps/${1}/info" ]; then if [ -e "${DIR}/../apps/$1/info" ]; then
# shellcheck disable=SC1090 # shellcheck disable=SC1090
. "${DIR}/../apps/${1}/info" . "${DIR}/../apps/$1/info"
ICON="${DIR}/../apps/${1}/icon.svg" ICON="${DIR}/../apps/$1/icon.svg"
elif [ -e "${HOME}/.local/share/winapps/apps/${1}/info" ]; then elif [ -e "$HOME/.local/share/winapps/apps/$1/info" ]; then
# shellcheck disable=SC1090 # shellcheck disable=SC1090
. "${HOME}/.local/share/winapps/apps/${1}/info" . "$HOME/.local/share/winapps/apps/$1/info"
ICON="${HOME}/.local/share/winapps/apps/${1}/icon.svg" ICON="$HOME/.local/share/winapps/apps/$1/icon.svg"
elif [ -e "/usr/local/share/winapps/apps/${1}/info" ]; then elif [ -e "/usr/local/share/winapps/apps/$1/info" ]; then
# shellcheck disable=SC1090 # shellcheck disable=SC1090
. "/usr/local/share/winapps/apps/${1}/info" . "/usr/local/share/winapps/apps/$1/info"
ICON="/usr/local/share/winapps/apps/${1}/icon.svg" ICON="/usr/local/share/winapps/apps/$1/icon.svg"
else else
echo "You need to run 'installer.sh' first." echo "You need to run 'installer.sh' first."
exit 1 exit 1
fi fi
if [ -n "${2}" ]; then if [ -n "$2" ]; then
dprint "HOME:${HOME}" dprint "HOME:$HOME"
FILE=$(echo "${2}" | sed 's|'"${HOME}"'|\\\\tsclient\\home|;s|/|\\|g;s|\\|\\\\|g') FILE=$(echo "$2" | sed 's|'"$HOME"'|\\\\tsclient\\home|;s|/|\\|g;s|\\|\\\\|g')
dprint "FILE:${FILE}" 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 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
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/ 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. 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"")" "EXES+=(""$Exe"")"
"ICONS+=(""$Icon"")" "ICONS+=(""$Icon"")"
} }

View File

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

View File

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

View File

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