Skip to content

Commit

Permalink
Merge pull request #364 from WhitewaterFoundry/javier/ftr/PEN-160
Browse files Browse the repository at this point in the history
[PEN-160] Add uninstall XFCE support
  • Loading branch information
crramirez authored Mar 18, 2022
2 parents 5df460a + 9fa8935 commit 877bf49
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 16 deletions.
20 changes: 13 additions & 7 deletions pengwin-setup.d/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

}

#######################################
Expand Down
14 changes: 10 additions & 4 deletions pengwin-setup.d/desktop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion pengwin-setup.d/shortcut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions pengwin-setup.d/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -254,6 +255,12 @@ function main() {
bash "${UninstallDir}"/x410.sh "$@"
fi

if [[ ${menu_choice} == *"XFCE"* ]] ; then
echo "XFCE"
bash "${UninstallDir}"/desktop.sh "$@"
fi


}

main "$@"
36 changes: 36 additions & 0 deletions pengwin-setup.d/uninstall/desktop.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
7 changes: 5 additions & 2 deletions pengwin-setup.d/uninstall/shortcut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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


2 changes: 1 addition & 1 deletion rpm/pengwin-setup.d/shortcut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"/*

Expand Down
2 changes: 1 addition & 1 deletion rpm/pengwin-setup.d/uninstall/shortcut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down

0 comments on commit 877bf49

Please sign in to comment.