diff --git a/pengwin-setup.d/common.sh b/pengwin-setup.d/common.sh index 407e9ca8..101753e4 100644 --- a/pengwin-setup.d/common.sh +++ b/pengwin-setup.d/common.sh @@ -274,31 +274,37 @@ function setup_env() { process_arguments "$@" - # shellcheck disable=SC1003 + # shellcheck disable=SC1003,SC2262 if (! wslpath 'C:\' >/dev/null 2>&1); then shopt -s expand_aliases alias wslpath=legacy_wslupath fi + # shellcheck disable=SC2155 readonly wHomeWinPath=$(cmd-exe /c 'echo %HOMEDRIVE%%HOMEPATH%' | tr -d '\r') export wHomeWinPath - + + # shellcheck disable=SC2263,SC2155 readonly wHome=$(wslpath -u "${wHomeWinPath}") export wHome - + readonly CANCELLED="CANCELLED" export CANCELLED - + + # shellcheck disable=SC2155 readonly WIN_CUR_VER="$(reg.exe query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v "CurrentBuild" 2>&1 | grep -E -o '([0-9]{5})' | cut -d ' ' -f 2)" export WIN_CUR_VER - + + # bashsupport disable=BP2001 + readonly SHORTCUTS_FOLDER="Pengwin Applications" + export SHORTCUTS_FOLDER SetupDir="/usr/local/pengwin-setup.d" export SetupDir - + readonly GOVERSION="1.15.8" export GOVERSION - + } ####################################### diff --git a/pengwin-setup.d/desktop.sh b/pengwin-setup.d/desktop.sh index 0c0c0404..52c6b879 100644 --- a/pengwin-setup.d/desktop.sh +++ b/pengwin-setup.d/desktop.sh @@ -11,15 +11,15 @@ function create_shortcut() { local cmdToExec="$2" local cmdIcon="$3" # shellcheck disable=SC2155 - local DEST_PATH=$(wslpath "$(wslvar -l Programs)")/Pengwin\ Applications + local dest_path=$(wslpath "$(wslvar -l Programs)")/"${SHORTCUTS_FOLDER}" # shellcheck disable=SC2086 echo wslusc --name "${cmdName}" --icon "${cmdIcon}" --gui "${cmdToExec}" # shellcheck disable=SC2086 bash "${SetupDir}"/generate-shortcut.sh --gui --name "${cmdName}" --icon "${cmdIcon}" "${cmdToExec}" - mkdir -p "${DEST_PATH}" - mv "$(wslpath "$(wslvar -l Desktop)")/${cmdName}.lnk" "${DEST_PATH}" + mkdir -p "${dest_path}" + mv "$(wslpath "$(wslvar -l Desktop)")/${cmdName}.lnk" "${dest_path}" } function package_installed() { @@ -80,7 +80,12 @@ function install_xrdp() { #!/bin/bash function execute_remote_desktop() { - host_ip=\$(ip -o -f inet addr show | grep -v 127.0.0 | awk '{printf "%s", \$4}' | cut -f1 -d/) + if [ -z "${WSL2}" ]; then + host_ip=127.0.0.1 + else + host_ip=\$(ip -o -f inet addr show | grep -v 127.0.0 | awk '{printf "%s", \$4}' | cut -f1 -d/) + fi + user_name=\$(whoami) echo -e "username:s:\$user_name\nsession bpp:i:32\nallow desktop composition:i:1\nconnection type:i:6\n" > /tmp/remote_desktop_config.rdp echo -e "networkautodetect:i:0\nbandwidthautodetect:i:1\n" >> /tmp/remote_desktop_config.rdp @@ -134,6 +139,7 @@ function install_xfce() { } function main() { + # shellcheck disable=SC2155,SC2188 local menu_choice=$( menu --title "Desktop Menu" --checklist --separate-output "Install Desktop environments\n[SPACE to select, ENTER to confirm]:" 10 55 1 \ diff --git a/pengwin-setup.d/shortcut.sh b/pengwin-setup.d/shortcut.sh index 49761a61..d0b8cc35 100644 --- a/pengwin-setup.d/shortcut.sh +++ b/pengwin-setup.d/shortcut.sh @@ -194,7 +194,7 @@ function main() { echo "Generating Start Menu" - DEST_PATH=$(wslpath "$(wslvar -l Programs)")/Pengwin\ Applications + DEST_PATH=$(wslpath "$(wslvar -l Programs)")/"${SHORTCUTS_FOLDER}" rm "${DEST_PATH}"/*\ \(WSL\).lnk diff --git a/pengwin-setup.d/uninstall.sh b/pengwin-setup.d/uninstall.sh index 46b3a024..522ae9a2 100644 --- a/pengwin-setup.d/uninstall.sh +++ b/pengwin-setup.d/uninstall.sh @@ -51,6 +51,7 @@ function main() { "WINTHEME" "Remove Windows 10 theme and LXAppearance" off \ "WSLTTY" "Remove WSLtty" off \ "X410" "Remove the X410 X-server autostart" off \ + "XFCE" "Remove XFCE Desktop environment" off \ # shellcheck disable=SC2188 3>&1 1>&2 2>&3) @@ -254,6 +255,12 @@ function main() { bash "${UninstallDir}"/x410.sh "$@" fi + if [[ ${menu_choice} == *"XFCE"* ]] ; then + echo "XFCE" + bash "${UninstallDir}"/desktop.sh "$@" + fi + + } main "$@" diff --git a/pengwin-setup.d/uninstall/desktop.sh b/pengwin-setup.d/uninstall/desktop.sh new file mode 100644 index 00000000..0ab79b27 --- /dev/null +++ b/pengwin-setup.d/uninstall/desktop.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# shellcheck source=./uninstall-common.sh +source "$(dirname "$0")/uninstall-common.sh" "$@" + +function uninstall_xrdp() { + echo "Removing XRDP" + remove_package 'xrdp' 'xorgxrdp' + sudo_rem_file "/usr/local/bin/remote_desktop.sh" + sudo_rem_file "/usr/local/bin/start-xrdp" + sudo_rem_file "/etc/profile.d/start-xrdp.sh" + sudo_rem_file "/etc/sudoers.d/start-xrdp" +} + +function uninstall_xfce() { + echo "Removing XFCE" + remove_package 'xfce4' 'xfce4-terminal' +} + +function remove_shortcut() { + echo "Removing Shortcuts" + local dest_path + dest_path="$(wslpath "$(wslvar -l Programs)")"/"${SHORTCUTS_FOLDER}" + sudo_rem_file "${dest_path}"/Xfce\ desktop\ -\ Full\ Screen.lnk + sudo_rem_file "${dest_path}"/Xfce\ desktop\ -\ 1024x768.lnk + sudo_rem_file "${dest_path}"/Xfce\ desktop\ -\ 1366x768.lnk + sudo_rem_file "${dest_path}"/Xfce\ desktop\ -\ 1920x1080.lnk +} + +function main() { + uninstall_xrdp + uninstall_xfce + remove_shortcut +} + +main "$@" diff --git a/pengwin-setup.d/uninstall/shortcut.sh b/pengwin-setup.d/uninstall/shortcut.sh index a7544f73..d0db5154 100644 --- a/pengwin-setup.d/uninstall/shortcut.sh +++ b/pengwin-setup.d/uninstall/shortcut.sh @@ -3,15 +3,18 @@ # shellcheck source=./uninstall-common.sh source "$(dirname "$0")/uninstall-common.sh" "$@" -shortcut_path=$(wslpath "$(wslvar -l Programs)")/Pengwin\ Applications +shortcut_path=$(wslpath "$(wslvar -l Programs)")/"${SHORTCUTS_FOLDER}" function main() { echo "Uninstalling Pengwin start-menu shortcuts" - rem_dir "$shortcut_path" + rm "${shortcut_path}"/*\ \(WSL\).lnk + unset shortcut_path } if show_warning "Pengwin start-menu shortcuts" "$@"; then main "$@" fi + + diff --git a/rpm/pengwin-setup.d/shortcut.sh b/rpm/pengwin-setup.d/shortcut.sh index 96137fbd..c50559e2 100644 --- a/rpm/pengwin-setup.d/shortcut.sh +++ b/rpm/pengwin-setup.d/shortcut.sh @@ -190,7 +190,7 @@ function main() { echo "Generating Start Menu" - DEST_PATH=$(wslpath "$(wslvar -l Programs)")/Pengwin\ Applications + DEST_PATH=$(wslpath "$(wslvar -l Programs)")/"${SHORTCUTS_FOLDER}" rm "${DEST_PATH}"/* diff --git a/rpm/pengwin-setup.d/uninstall/shortcut.sh b/rpm/pengwin-setup.d/uninstall/shortcut.sh index a7544f73..68f35daf 100644 --- a/rpm/pengwin-setup.d/uninstall/shortcut.sh +++ b/rpm/pengwin-setup.d/uninstall/shortcut.sh @@ -3,7 +3,7 @@ # shellcheck source=./uninstall-common.sh source "$(dirname "$0")/uninstall-common.sh" "$@" -shortcut_path=$(wslpath "$(wslvar -l Programs)")/Pengwin\ Applications +shortcut_path=$(wslpath "$(wslvar -l Programs)")/"${SHORTCUTS_FOLDER}" function main() {