Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #379

Merged
merged 4 commits into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion completions/pengwin-setup
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ function _pengwin_setup() { # By convention, the function name
mapfile -t COMPREPLY < <(compgen -W 'CODE EMACS NEOVIM' -- "${cur}")
;;
GUI)
mapfile -t COMPREPLY < <(compgen -W 'DESKTOP NLI GUILIB HIDPI STARTMENU TERMINAL SYNAPTIC VCXSRV WINTHEME X410' -- "${cur}")
mapfile -t COMPREPLY < <(compgen -W 'CONFIGURATION DESKTOP NLI GUILIB HIDPI TERMINAL SYNAPTIC WINTHEME WSLG' -- "${cur}")
;;
CONFIGURE)
mapfile -t COMPREPLY < <(compgen -W 'DISPLAY STARTMENU VCXSRV X410' -- "${cur}")
;;
DESKTOP)
mapfile -t COMPREPLY < <(compgen -W 'XFCE' -- "${cur}")
Expand Down
3 changes: 2 additions & 1 deletion pengwin-setup
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ source ${SetupDir}/common.sh "$@"
declare CANCELLED
declare SKIP_UPDATES
declare JUST_UPDATE
declare REQUIRES_X

rm -f "${HOME}"/.should-restart

Expand Down Expand Up @@ -138,7 +139,7 @@ function install_menu() {
local menu_choice=$(

menu --title "pengwin-setup" --checklist --separate-output "\nHand-curated add-ons [SPACE to select, ENTER to confirm]:" 16 99 8 \
"EDITORS" "Install text editors neovim, emacs, or Visual Studio Code (requires X) " off \
"EDITORS" "Install text editors neovim, emacs, or Visual Studio Code${REQUIRES_X} " off \
"GUI" "Install an X server or various other GUI applications" off \
"MAINTENANCE" "Various maintenance tasks like home backup" off \
"PROGRAMMING" "Install various programming languages support" off \
Expand Down
188 changes: 118 additions & 70 deletions pengwin-setup.d/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,35 @@
declare -a -x CMD_MENU_OPTIONS

export LANG=en_US.utf8
export NEWT_COLORS='
root=lightgray,black
roottext=lightgray,black
shadow=black,gray
title=magenta,lightgray
actcheckbox=lightgray,magenta
emptyscale=lightgray,blue
fullscale=lightgray,magenta
button=lightgray,magenta
actbutton=magenta,lightgray
compactbutton=magenta,lightgray
'

readonly PENGWIN_SETUP_TITLE="Pengwin Setup"

declare WSL2
# shellcheck disable=SC2155
declare -i -r WSLG=3

if [[ "${WSL2}" == "${WSLG}" ]]; then
readonly REQUIRES_X=" "
else
readonly REQUIRES_X=" (requires X)"
fi

declare -i -x PROGRESS_STATUS

readonly PENGWIN_CONFIG_DIR="${HOME}/.config/pengwin"

#######################################
# description
# Globals:
Expand All @@ -21,67 +47,67 @@ declare -i -x PROGRESS_STATUS
function process_arguments() {
while [[ $# -gt 0 ]]; do
case "$1" in
--debug | -d | --verbose | -v)
echo "Running in debug/verbose mode"
set -x
shift
;;
-y | --yes | --assume-yes)
echo "Skipping confirmations"
export SKIP_CONFIMATIONS=1
shift
;;
--noupdate)
echo "Skipping updates"
export SKIP_UPDATES=1
shift
;;
--norebuildicons)
echo "Skipping rebuild start menu"
export SKIP_STARTMENU=1
shift
;;
-q | --quiet | --noninteractive)
echo "Skipping confirmations"
export NON_INTERACTIVE=1
shift
;;
update | upgrade)
echo "Just update packages"
export JUST_UPDATE=1
export SKIP_CONFIMATIONS=1
shift
;;
autoinstall | install)
echo "Automatically install without prompts or updates"
export SKIP_UPDATES=1
export NON_INTERACTIVE=1
export SKIP_CONFIMATIONS=1
export SKIP_STARTMENU=1
shift
;;
uninstall | remove)
echo "Automatically uninstall without prompts or updates"
export SKIP_UPDATES=1
export NON_INTERACTIVE=1
export SKIP_CONFIMATIONS=1
export SKIP_STARTMENU=1
CMD_MENU_OPTIONS+=("UNINSTALL")
shift
;;
startmenu)
echo "Regenerates the start menu"
export SKIP_UPDATES=1
export NON_INTERACTIVE=1
export SKIP_CONFIMATIONS=1
CMD_MENU_OPTIONS+=("GUI")
CMD_MENU_OPTIONS+=("STARTMENU")
shift
;;
*)
CMD_MENU_OPTIONS+=("$1")
shift
;;
--debug | -d | --verbose | -v)
echo "Running in debug/verbose mode"
set -x
shift
;;
-y | --yes | --assume-yes)
echo "Skipping confirmations"
export SKIP_CONFIMATIONS=1
shift
;;
--noupdate)
echo "Skipping updates"
export SKIP_UPDATES=1
shift
;;
--norebuildicons)
echo "Skipping rebuild start menu"
export SKIP_STARTMENU=1
shift
;;
-q | --quiet | --noninteractive)
echo "Skipping confirmations"
export NON_INTERACTIVE=1
shift
;;
update | upgrade)
echo "Just update packages"
export JUST_UPDATE=1
export SKIP_CONFIMATIONS=1
shift
;;
autoinstall | install)
echo "Automatically install without prompts or updates"
export SKIP_UPDATES=1
export NON_INTERACTIVE=1
export SKIP_CONFIMATIONS=1
export SKIP_STARTMENU=1
shift
;;
uninstall | remove)
echo "Automatically uninstall without prompts or updates"
export SKIP_UPDATES=1
export NON_INTERACTIVE=1
export SKIP_CONFIMATIONS=1
export SKIP_STARTMENU=1
CMD_MENU_OPTIONS+=("UNINSTALL")
shift
;;
startmenu)
echo "Regenerates the start menu"
export SKIP_UPDATES=1
export NON_INTERACTIVE=1
export SKIP_CONFIMATIONS=1
CMD_MENU_OPTIONS+=("GUI")
CMD_MENU_OPTIONS+=("STARTMENU")
shift
;;
*)
CMD_MENU_OPTIONS+=("$1")
shift
;;
esac
done

Expand All @@ -96,7 +122,7 @@ function process_arguments() {
# None
#######################################
function createtmp() {
echo "Saving current directory as \$CURDIR"
echo 'Saving current directory as $CURDIR'
CURDIR=$(pwd)
TMPDIR=$(mktemp -d)
echo "Going to \$TMPDIR: $TMPDIR"
Expand Down Expand Up @@ -180,7 +206,7 @@ function confirm() {

if [[ ! ${SKIP_CONFIMATIONS} ]]; then

whiptail "$@"
whiptail --backtitle "${PENGWIN_SETUP_TITLE}" "$@"

return $?
else
Expand All @@ -202,7 +228,7 @@ function message() {

if [[ ! ${NON_INTERACTIVE} ]]; then

whiptail "$@"
whiptail --backtitle "${PENGWIN_SETUP_TITLE}" "$@"

return $?
else
Expand All @@ -223,8 +249,8 @@ function menu() {

local menu_choice #Splitted to preserve exit code

if [[ "${#CMD_MENU_OPTIONS[*]}" == 0 ]]; then
menu_choice=$(whiptail "$@" 3>&1 1>&2 2>&3)
if [[ ${#CMD_MENU_OPTIONS[*]} == 0 ]]; then
menu_choice=$(whiptail --backtitle "${PENGWIN_SETUP_TITLE}" "$@" 3>&1 1>&2 2>&3)
else
menu_choice="${CMD_MENU_OPTIONS[*]}"
fi
Expand All @@ -236,9 +262,9 @@ function menu() {
return
fi

if [[ -z "${menu_choice}" ]]; then
if [[ -z ${menu_choice} ]]; then

if (whiptail --title "None Selected" --yesno "No item selected. Would you like to return to the menu?" 8 60 3>&1 1>&2 2>&3); then
if (whiptail --backtitle "${PENGWIN_SETUP_TITLE}" --title "None Selected" --yesno "No item selected. Would you like to return to the menu?" 8 60 3>&1 1>&2 2>&3); then
menu "$@"

return
Expand Down Expand Up @@ -267,7 +293,7 @@ function menu() {
function setup_env() {

if (! command -v cmd.exe >/dev/null); then
whiptail --title "An environment problem was found" --msgbox "The Windows PATH is not available, and pengwin-setup requires it to run. Please check that: \n\n pengwin-setup is not running with sudo.\n pengwin-setup wasn't run with the root user.\n appendWindowsPath is true in /etc/wsl.conf file or is not defined. \n\n\nIf you don't want to have Windows PATH in Pengwin, enable it temporally to run pengwin-setup" 15 100
whiptail --backtitle "${PENGWIN_SETUP_TITLE}" --title "An environment problem was found" --msgbox "The Windows PATH is not available, and pengwin-setup requires it to run. Please check that: \n\n pengwin-setup is not running with sudo.\n pengwin-setup wasn't run with the root user.\n appendWindowsPath is true in /etc/wsl.conf file or is not defined. \n\n\nIf you don't want to have Windows PATH in Pengwin, enable it temporally to run pengwin-setup" 15 100

exit 0
fi
Expand Down Expand Up @@ -329,7 +355,7 @@ function update_packages() {
if [[ ${NON_INTERACTIVE} ]]; then
sudo apt-get update -y -q "$@"
else
sudo debconf-apt-progress -- apt-get update -y "$@"
sudo --preserve-env=NEWT_COLORS debconf-apt-progress -- apt-get update -y "$@"
fi
}

Expand Down Expand Up @@ -396,4 +422,26 @@ function stop_indeterminate_progress() {

}

#######################################
# Instruct to pengwin-setup to terminate the Pengwin instance
# Globals:
# HOME
# Arguments:
# None
#######################################
function enable_should_restart() {
touch "${HOME}"/.should-restart
}

#######################################
# Creates the config dir for pengwin in the user home
# Globals:
# PENGWIN_CONFIG_DIR
# Arguments:
# None
#######################################
function setup_pengwin_config() {
mkdir -p "${PENGWIN_CONFIG_DIR}"
}

setup_env "$@"
2 changes: 1 addition & 1 deletion pengwin-setup.d/editors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function editor_menu() {
local editor_choice=$(

menu --title "Editor Menu" --checklist --separate-output "Custom editors (nano and vi included)\n[SPACE to select, ENTER to confirm]:" 12 70 3 \
"CODE" "Visual Studio Code (Linux version, requires X) " off \
"CODE" "Visual Studio Code Linux version${REQUIRES_X} " off \
"EMACS" "Emacs" off \
"NEOVIM" "Neovim" off

Expand Down
Loading