OSDN Git Service

Allow setting root and boot partitions before running
[pacbang-linux/installer-arch.git] / archlabs-installer
index 550be13..fc3a768 100755 (executable)
@@ -5,7 +5,7 @@
 # Some ideas and code reworked from other resources
 # AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due
 
-VER=2.0.72
+VER=2.0.80
 
 # bulk default values {
 
@@ -23,17 +23,21 @@ RUN=/run/archiso/bootmnt/arch/boot # path for live system /boot
 VM="$(dmesg | grep -i hypervisor)" # system running in a virtual machine
 export DIALOGOPTS="--cr-wrap"      # see `man dialog`
 
-BASE_PKGS="base-devel xorg xorg-drivers sudo git gvfs gtk3 libmad libmatroska "
-BASE_PKGS+="tumbler playerctl pulseaudio pulseaudio-alsa pavucontrol pamixer scrot "
-BASE_PKGS+="xdg-user-dirs ffmpeg gstreamer gst-libav gst-plugins-base gst-plugins-good"
-AL_BASE_PKGS="archlabs-skel-base archlabs-fonts archlabs-themes "
-AL_BASE_PKGS+="archlabs-icons archlabs-wallpapers archlabs-scripts archlabs-baph"
-WM_BASE_PKGS="arandr archlabs-networkmanager-dmenu nitrogen polkit-gnome "
+BASE_PKGS="base base-devel xorg xorg-drivers sudo git gvfs gtk3 libmad libmatroska tumbler "
+BASE_PKGS+="playerctl pulseaudio pulseaudio-alsa pavucontrol pamixer scrot xdg-user-dirs "
+BASE_PKGS+="ffmpeg gstreamer gst-libav gst-plugins-base gst-plugins-good bash-completion "
+
+AL_BASE_PKGS="archlabs-keyring archlabs-icons archlabs-fonts archlabs-themes "
+AL_BASE_PKGS+="archlabs-baph archlabs-wallpapers archlabs-scripts archlabs-skel-base"
+
+WM_BASE_PKGS="arandr nitrogen polkit-gnome network-manager-applet "
 WM_BASE_PKGS+="volumeicon xclip exo laptop-detect xdotool compton wmctrl feh "
 WM_BASE_PKGS+="gnome-keyring dunst gsimplecal xfce4-power-manager xfce4-settings"
+
 SYS_MEM="$(awk '/MemTotal/ {print int($2 / 1024) "M"}' /proc/meminfo)"
 LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if ($1) {print $1 " - "}}' /etc/locale.gen)"
 CMAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " - "}' | sort)"
+
 [[ $LINES ]] || LINES=$(tput lines)
 [[ $COLUMNS ]] || COLUMNS=$(tput cols)
 
@@ -109,7 +113,7 @@ _device="\nSelect a device to use from the list below.\n\nDevices (/dev) are the
 _resize="\nSelect a new filesystem size in MB, a new partition will be created from the free space but will be left unformatted.\nThe lowest size is just enough to fit the currently in use space on the partition while the default is set to split the free space evenly.\n\nUse Tab or the arrow keys move the cursor between the buttons and the value, when the cursor is on the value, you can edit it by:\n\n - left/right cursor movement to select a digit to modify\n - +/-  characters to increment/decrement the digit by one\n - 0 through 9 to set the digit to the given value\n\nSome keys are also recognized in all cursor positions:\n\n - Home/End set the value to its maximum or minimum\n - Pageup/Pagedown increment the value so that the slider moves by one column."
 _mount="\nUse [Space] to toggle mount options from below, press [Enter] when done to confirm selection.\n\nNot selecting any and confirming will run an automatic mount."
 _warn="\nIMPORTANT:\n\nChoose carefully when editing, formatting, and mounting partitions or your DATA MAY BE LOST.\n\nTo mount a partition without formatting it, select 'skip' when prompted to choose a filesystem during the mounting stage.\nThis can only be used for partitions that already contain a filesystem and cannot be the root (/) partition, it needs to be formatted before install.\n"
-_part="\nFull device auto partitioning is available for beginners otherwise cfdisk is recommended.\n\n  - All systems will require a root partition (8G or greater).\n  - UEFI (and BIOS using LUKS without LVM) require a separate boot partition (100-512M)."
+_part="\nFull device auto partitioning is available for beginners otherwise cfdisk is recommended.\n\n  - All systems will require a root partition (8G or greater).\n  - UEFI or BIOS using LUKS without LVM require a separate boot partition (100-512M)."
 _uefi="\nSelect the EFI boot partition (/boot), required for UEFI boot.\n\nIt's usually the first partition on the device, 100-512M, and will be formatted as vfat/fat32 if not already."
 _bios="\nDo you want to use a separate boot partition? (optional)\n\nIt's usually the first partition on the device, 100-512M, and will be formatted as ext3/4 if not already."
 _biosluks="\nSelect the boot partition (/boot), required for LUKS.\n\nIt's usually the first partition on the device, 100-512M, and will be formatted as ext3/4 if not already."
@@ -322,7 +326,11 @@ select_config()
                (( i++ )) # progress through to the next choice
        done
 
-       case $MYSHELL in bash) LOGINRC='.bash_profile' ;; zsh) LOGINRC='.zprofile' ;; mksh) LOGINRC='.profile' ;; esac
+       case $MYSHELL in
+               bash) LOGINRC='.bash_profile' ;;
+               zsh) LOGINRC='.zprofile' ;;
+               mksh) LOGINRC='.profile' ;;
+       esac
 
        return 0
 }
@@ -330,40 +338,37 @@ select_config()
 select_mkuser()
 {
        NEWUSER=''
-       local v='' u='' p='' p2='' rp='' rp2=''
+       typeset -a ans
 
        until [[ $NEWUSER ]]; do
-               i=0
                tput cnorm
                dialog --insecure --backtitle "$DIST Installer - $SYS - v$VER" --separator $'\n' --title " User " --mixedform "$_user" 0 0 0 \
-                       "Username:"  1 1 "$u" 1 11 "$COLUMNS" 0 0 \
-                       "Password:"  2 1 ''   2 11 "$COLUMNS" 0 1 \
-                       "Password2:" 3 1 ''   3 12 "$COLUMNS" 0 1 \
+                       "Username:"  1 1 "${ans[0]}" 1 11 "$COLUMNS" 0 0 \
+                       "Password:"  2 1 ''          2 11 "$COLUMNS" 0 1 \
+                       "Password2:" 3 1 ''          3 12 "$COLUMNS" 0 1 \
                        "--- Root password, if left empty the user password will be used ---" 6 1 '' 6 68 "$COLUMNS" 0 2 \
-                       "Password:"  8 1 ''   8 11 "$COLUMNS" 0 1 \
-                       "Password2:" 9 1 ''   9 12 "$COLUMNS" 0 1 2>"$ANS" || return 1
+                       "Password:"  8 1 ''          8 11 "$COLUMNS" 0 1 \
+                       "Password2:" 9 1 ''          9 12 "$COLUMNS" 0 1 2>"$ANS" || return 1
 
-               while read -r line; do
-                       case $i in 0) u="$line" ;; 1) p="$line" ;; 2) p2="$line" ;; 4) rp="$line" ;; 5) rp2="$line" ;; esac
-                       (( i++ ))
-               done < "$ANS"
+               mapfile -t ans <"$ANS"
 
                # root passwords empty, so use the user passwords
-               [[ -z $rp && -z $rp2 ]] && { rp="$p"; rp2="$p2"; }
+               if [[ -z "${ans[4]}" && -z "${ans[5]}" ]]; then
+                       ans[4]="${ans[1]}"
+                       ans[5]="${ans[2]}"
+               fi
 
                # make sure a username was entered and that the passwords match
-               if [[ ${#u} -eq 0 || $u =~ \ |\' || $u =~ [^a-z0-9] ]]; then
-                       msg "Invalid Username" "\nIncorrect user name.\n\nPlease try again.\n"; u=''
-               elif [[ -z $p ]]; then
-                       msg "Empty Password" "\nThe user password cannot be left empty.\n\nPlease try again.\n"
-               elif [[ "$p" != "$p2" ]]; then
+               if [[ -z ${ans[0]} || ${ans[0]} =~ \ |\' || ${ans[0]} =~ [^a-z0-9] ]]; then
+                       msg "Invalid Username" "\nInvalid user name.\n\nPlease try again.\n"; u=''
+               elif [[ -z "${ans[1]}" || "${ans[1]}" != "${ans[2]}" ]]; then
                        msg "Password Mismatch" "\nThe user passwords do not match.\n\nPlease try again.\n"
-               elif [[ "$rp" != "$rp2" ]]; then
+               elif [[ "${ans[4]}" != "${ans[5]}" ]]; then
                        msg "Password Mismatch" "\nThe root passwords do not match.\n\nPlease try again.\n"
                else
-                       NEWUSER="$u"
-                       USER_PASS="$p"
-                       ROOT_PASS="$rp"
+                       NEWUSER="${ans[0]}"
+                       USER_PASS="${ans[1]}"
+                       ROOT_PASS="${ans[4]}"
                fi
        done
        return 0
@@ -399,10 +404,10 @@ select_keymap()
                dlg CMAP menu "Console Keymap" "$_vconsole" $CMAPS || return 1
        fi
 
-       if [[ $DISPLAY && $TERM != 'linux' ]]; then
-               setxkbmap "$KEYMAP" >/dev/null 2>&1
-       else
+       if [[ $TERM == 'linux' ]]; then
                loadkeys "$CMAP" >/dev/null 2>&1
+       else
+               setxkbmap "$KEYMAP" >/dev/null 2>&1
        fi
 
        return 0
@@ -429,9 +434,6 @@ select_sessions()
        WM_PKGS="${WM_PKGS//  / }"    # remove double spaces
        WM_PKGS="${WM_PKGS# }"        # remove leading space
 
-       # add archlabs base when choosing any session
-       [[ $WM_PKGS ]] && WM_PKGS+=" $AL_BASE_PKGS"
-
        for i in $INSTALL_WMS; do
                LOGIN_CHOICES+="$i - "
                [[ ${WM_EXT[$i]} && $WM_PKGS != *"${WM_EXT[$i]}"* ]] && WM_PKGS+=" ${WM_EXT[$i]}"
@@ -562,9 +564,9 @@ part_menu()
 
        while :; do
                choice=""
-               dlg choice menu "Edit Partitions" "$_part" \
+               dlg choice menu "Edit Partitions" "$_part\n\n$(lsblk -no NAME,MODEL,SIZE,TYPE,FSTYPE $device)" \
                        "auto"   "Whole device automatic partitioning" \
-                       "shrink" "Shrink an existing ext2/3/4 or ntfs partition to make room for a new partition" \
+                       "shrink" "Shrink an existing ext or ntfs partition" \
                        "cfdisk" "Curses based variant of fdisk" \
                        "parted" "GNU partition editor" \
                        "fdisk"  "Dialog-driven creation and manipulation of partitions" \
@@ -667,7 +669,7 @@ part_shrink()
 
        part_find "${device##*/}[^ ]" || return 1
        (( COUNT == 1 )) && part="$(awk '{print $1}' <<< "${PARTS[@]}" )"
-       
+
        if (( COUNT == 1 )) || dlg part menu "Resize" "\nWhich partition on $device do you want to resize?" $PARTS; then
                fs=$(lsblk -lno FSTYPE "$part")
                case "$fs" in
@@ -1005,6 +1007,7 @@ select_mountpoint()
                        EXMNT=''
                fi
        done
+       msg "Mount Extra" "\nMounting Finished\n\n\nNo extra partitions available to mount, returning to main menu.\n" 2
        return 0
 }
 
@@ -1031,26 +1034,27 @@ select_filesystem()
 
 select_efi_partition()
 {
-       if [[ $AUTO_BOOT_PART ]]; then
-               msg "EFI Boot Partition" "\nUsing partition created during automatic format.\n" 2
-               BOOT_PART="$AUTO_BOOT_PART"
-               return 0 # were done here
-       else
-               local pts size dev isize bsize ptcount=0
-
-               # walk partition list and skip ones that are too small/big for boot
-               while read -r dev size; do
-                       size_t="${size: -1:1}"  # size type eg. K, M, G, T
-                       isize=${size:0:-1}      # remove trailing size type character
-                       isize=${isize%.*}       # remove any decimal (round down)
-                       [[ $size_t =~ [KT] || ($size_t == 'G' && $isize -gt 2) || ($size_t == 'M' && $isize -lt 100) ]] || { pts+="$dev $size "; (( ptcount++ )); }
-               done <<< "$PARTS"
-
-               if (( ptcount == 1 )); then
-                       msg "EFI Boot Partition" "\nOnly one partition available that meets size requirements.\n" 1
-                       BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$pts")"
+       if [[ -z $BOOT_PART ]]; then
+               if [[ $AUTO_BOOT_PART ]]; then
+                       BOOT_PART="$AUTO_BOOT_PART"
+                       return 0 # were done here
                else
-                       dlg BOOT_PART menu "EFI Partition" "$_uefi" $pts
+                       local pts size dev isize bsize ptcount=0
+
+                       # walk partition list and skip ones that are too small/big for boot
+                       while read -r dev size; do
+                               size_t="${size: -1:1}"  # size type eg. K, M, G, T
+                               isize=${size:0:-1}      # remove trailing size type character
+                               isize=${isize%.*}       # remove any decimal (round down)
+                               [[ $size_t =~ [KT] || ($size_t == 'G' && $isize -gt 2) || ($size_t == 'M' && $isize -lt 100) ]] || { pts+="$dev $size "; (( ptcount++ )); }
+                       done <<< "$PARTS"
+
+                       if (( ptcount == 1 )); then
+                               msg "EFI Boot Partition" "\nOnly one partition available that meets size requirements.\n" 1
+                               BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$pts")"
+                       else
+                               dlg BOOT_PART menu "EFI Partition" "$_uefi" $pts
+                       fi
                fi
        fi
 
@@ -1070,27 +1074,28 @@ select_efi_partition()
 
 select_boot_partition()
 {
-       if [[ $AUTO_BOOT_PART && ! $LVM ]]; then
-               msg "Boot Partition" "\nUsing partition created during automatic format.\n" 2
-               BOOT_PART="$AUTO_BOOT_PART"
-               return 0 # were done here
-       else
-               local pts size dev isize bsize ptcount=0
-
-               # walk partition list and skip ones that are too small/big for boot
-               while read -r dev size; do
-                       size_t="${size: -1:1}"  # size type eg. K, M, G, T
-                       isize=${size:0:-1}      # remove trailing size type character
-                       isize=${isize%.*}       # remove any decimal (round down)
-                       [[ $size_t =~ [KT] || ($size_t == 'G' && $isize -gt 2) || ($size_t == 'M' && $isize -lt 100) ]] || { pts+="$dev $size "; (( ptcount++ )); }
-               done <<< "$PARTS"
-
-               if [[ $LUKS && ! $LVM ]]; then
-                       dlg BOOT_PART menu "Boot Partition" "$_biosluks" $pts
-                       [[ $BOOT_PART ]] || return 1
+       if [[ -z $BOOT_PART ]]; then
+               if [[ $AUTO_BOOT_PART && ! $LVM ]]; then
+                       BOOT_PART="$AUTO_BOOT_PART"
+                       return 0 # were done here
                else
-                       dlg BOOT_PART menu "Boot Partition" "$_bios" "skip" "don't use a separate boot" $pts
-                       [[ -z $BOOT_PART || $BOOT_PART == "skip" ]] && { BOOT_PART=''; return 0; }
+                       local pts size dev isize bsize ptcount=0
+
+                       # walk partition list and skip ones that are too small/big for boot
+                       while read -r dev size; do
+                               size_t="${size: -1:1}"  # size type eg. K, M, G, T
+                               isize=${size:0:-1}      # remove trailing size type character
+                               isize=${isize%.*}       # remove any decimal (round down)
+                               [[ $size_t =~ [KT] || ($size_t == 'G' && $isize -gt 2) || ($size_t == 'M' && $isize -lt 100) ]] || { pts+="$dev $size "; (( ptcount++ )); }
+                       done <<< "$PARTS"
+
+                       if [[ $LUKS && ! $LVM ]]; then
+                               dlg BOOT_PART menu "Boot Partition" "$_biosluks" $pts
+                               [[ $BOOT_PART ]] || return 1
+                       else
+                               dlg BOOT_PART menu "Boot Partition" "$_bios" "skip" "don't use a separate boot" $pts
+                               [[ -z $BOOT_PART || $BOOT_PART == "skip" ]] && { BOOT_PART=''; return 0; }
+                       fi
                fi
        fi
 
@@ -1107,27 +1112,29 @@ select_boot_partition()
 
 select_root_partition()
 {
-       if [[ $AUTO_ROOT_PART && -z $LVM && -z $LUKS ]]; then
-               ROOT_PART="$AUTO_ROOT_PART"
-               msg "Root Partition (/)" "\nUsing partition created during automatic format.\n" 2
-               part_mount "$ROOT_PART" || { ROOT_PART=''; return 1; }
-               return 0  # we're done here
-       else
-               local pts size dev isize bsize ptcount=0
-
-               # walk partition list and skip ones that are too small for / (root)
-               while read -r dev size; do
-                       size_t="${size: -1:1}"  # size type eg. K, M, G, T
-                       isize=${size:0:-1}      # remove trailing size type character
-                       isize=${isize%.*}       # remove any decimal (round down)
-                       [[ $size_t =~ [MK] || ($size_t == 'G' && $isize -lt 4) ]] || { pts+="$dev $size "; (( ptcount++ )); }
-               done <<< "$PARTS"
-
-               if (( ptcount == 1 )); then  # only one available device
-                       msg "Root Partition (/)" "\nOnly one partition available that meets size requirements.\n" 2
-                       ROOT_PART="$(awk 'NF > 0 {print $1}' <<< "$pts")"
+       if [[ -z $ROOT_PART ]]; then
+               if [[ $AUTO_ROOT_PART && -z $LVM && -z $LUKS ]]; then
+                       ROOT_PART="$AUTO_ROOT_PART"
+                       msg "Mount Menu" "\nUsing partitions created during automatic format.\n" 2
+                       part_mount "$ROOT_PART" || { ROOT_PART=''; return 1; }
+                       return 0  # we're done here
                else
-                       dlg ROOT_PART menu "Mount Root" "\nSelect the root (/) partition, this is where $DIST will be installed.\n\nDevices smaller than 8G will not be shown here." $pts
+                       local pts size dev isize bsize ptcount=0
+
+                       # walk partition list and skip ones that are too small for / (root)
+                       while read -r dev size; do
+                               size_t="${size: -1:1}"  # size type eg. K, M, G, T
+                               isize=${size:0:-1}      # remove trailing size type character
+                               isize=${isize%.*}       # remove any decimal (round down)
+                               [[ $size_t =~ [MK] || ($size_t == 'G' && $isize -lt 4) ]] || { pts+="$dev $size "; (( ptcount++ )); }
+                       done <<< "$PARTS"
+
+                       if (( ptcount == 1 )); then  # only one available device
+                               msg "Root Partition (/)" "\nOnly one partition available that meets size requirements.\n" 2
+                               ROOT_PART="$(awk 'NF > 0 {print $1}' <<< "$pts")"
+                       else
+                               dlg ROOT_PART menu "Mount Root" "\nSelect the root (/) partition, this is where $DIST will be installed.\n\nDevices smaller than 8G will not be shown here." $pts
+                       fi
                fi
        fi
 
@@ -1135,7 +1142,6 @@ select_root_partition()
                ROOT_PART=''
                return 1
        fi
-
        return 0
 }
 
@@ -1198,7 +1204,7 @@ install_main()
                        login      "${EDIT_FILES[login]}"
 
                if [[ -z $choice || $choice == 'finished' ]]; then
-                       [[ $DEBUG == true && -r $DBG ]] && $EDITOR $DBG
+                       [[ $DEBUG == true && -r $DBG ]] && ${EDITOR:-vim} $DBG
                        clear && die 127
                else
                        local exists=''
@@ -1206,7 +1212,7 @@ install_main()
                                [[ -e ${MNT}$f ]] && exists+=" ${MNT}$f"
                        done
                        if [[ $exists ]]; then
-                               $EDITOR -O $exists
+                               ${EDITOR:-vim} -O $exists
                        else
                                msg "File Missing" "\nThe file(s) selected do not exist:\n\n${EDIT_FILES[$choice]}\n"
                        fi
@@ -1244,7 +1250,7 @@ install_base()
                EOF
        fi
 
-       [[ -e /run/archiso/sfs/airootfs && $KERNEL == 'linux' ]] && cp -vf $RUN/x86_64/vmlinuz $MNT/boot/vmlinuz-linux
+       [[ -e /run/archiso/sfs/airootfs ]] && cp -vf $RUN/x86_64/vmlinuz $MNT/boot/vmlinuz-linux
        [[ -d /etc/netctl ]] && cp -rfv /etc/netctl $MNT/etc/
        [[ -f /etc/resolv.conf ]] && cp -fv /etc/resolv.conf $MNT/etc/
        [[ -e /etc/NetworkManager/system-connections ]] && cp -rvf /etc/NetworkManager/system-connections $MNT/etc/NetworkManager/
@@ -1358,18 +1364,19 @@ install_user()
                done
        fi
 
-       [[ $WM_PKGS == *xfce* ]] && echo 'volumeicon &' >> $MNT/home/$NEWUSER/.xprofile
+       [[ $MYSHELL != 'bash' ]] && rm -rf "$MNT/home/$NEWUSER/.bash"*
+       [[ $MYSHELL != 'zsh' ]] && rm -rf "$MNT/home/$NEWUSER/.z"*
 
        # remove some commands from ~/.xprofile when using KDE or Gnome as the login session
-       if [[ $LOGIN_WM =~ (startkde|gnome-session) || ($LOGIN_TYPE =~ (lightdm|ly) && $WM_PKGS =~ (plasma|gnome)) ]]; then
-               sed -i '/super/d' $MNT/home/$NEWUSER/.xprofile $MNT/root/.xprofile
-               sed -i '/nitrogen/d' $MNT/home/$NEWUSER/.xprofile $MNT/root/.xprofile
-               sed -i '/compton/d' $MNT/home/$NEWUSER/.xprofile $MNT/root/.xprofile
+       if [[ $LOGIN_WM =~ (startkde|gnome-session) || ($LOGIN_TYPE != 'xinit' && $WM_PKGS =~ (plasma|gnome)) ]]; then
+               sed -i '/super/d; /nitrogen/d; /compton/d' "$MNT/home/$NEWUSER/.xprofile" "$MNT/root/.xprofile"
+       elif [[ $LOGIN_WM == 'dwm' ]]; then # and dwm
+               sed -i '/super/d; /compton/d' "$MNT/home/$NEWUSER/.xprofile" "$MNT/root/.xprofile"
        fi
 
        # create user home directories (Music, Documents, Downloads, etc..)
        chrun 'xdg-user-dirs-update'
-       
+
        return 0
 }
 
@@ -1379,20 +1386,21 @@ install_login()
        echo "Setting up $LOGIN_TYPE"
        case $LOGIN_TYPE in
                ly|sddm|gdm|lightdm)
+                       if [[ $LOGIN_WM == *dwm* ]]; then # dwm doesn't include an xsession file for display managers
+                               mkdir -p $MNT/usr/share/xsessions
+                               cat >$MNT/usr/share/xsessions/dwm.desktop <<- EOF
+                               [Desktop Entry]
+                               Encoding=UTF-8
+                               Name=Dwm
+                               Comment=Dynamic Window Manager
+                               Exec=dwm
+                               Type=XSession
+                               EOF
+                       fi
                        rm -rf "$serv" "$MNT/home/$NEWUSER/.xinitrc"
                        chrun "systemctl enable $LOGIN_TYPE.service" 2>$ERR
                        errshow 1 "systemctl enable $LOGIN_TYPE.service"
-                       if [[ $LOGIN_TYPE == 'lightdm' ]]; then
-                               cat > $MNT/etc/lightdm/lightdm-gtk-greeter.conf <<- EOF
-                               [greeter]
-                               default-user-image=/usr/share/icons/ArchLabs-Dark/64x64/places/distributor-logo-archlabs.png
-                               background=/usr/share/backgrounds/archlabs/archlabs.jpg
-                               theme-name=Adwaita-dark
-                               icon-theme-name=Adwaita
-                               font-name=DejaVu Sans Mono 11
-                               position=30%,end 50%,end
-                               EOF
-                       fi
+                       ${LOGIN_TYPE}_config
                        ;;
                xinit)
                        if [[ $INSTALL_WMS ]]; then
@@ -1405,7 +1413,7 @@ install_login()
                                sed -i "s/root/${NEWUSER}/g" $serv/autologin.conf
                                cat > "$MNT/home/$NEWUSER/$LOGINRC" <<- EOF
                                # automatically run startx when logging in on tty1
-                               [ -z \$DISPLAY ] && [ \$XDG_VTNR -eq 1 ] && exec startx
+                               [ -z "\$DISPLAY" ] && [ \$XDG_VTNR -eq 1 ] && startx
                                EOF
                        else
                                rm -rf $serv
@@ -1417,28 +1425,28 @@ install_login()
 install_packages()
 {
        local rmpkg="archlabs-installer "
-       local inpkg="$BASE_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $PACKAGES $USER_PKGS "
-
-       case $MYSHELL in zsh) inpkg+="zsh-completions " ;; mksh) inpkg+="mksh " rmpkg+="zsh " ;; bash) inpkg+="bash-completion " rmpkg+="zsh " ;; esac
+       local inpkg="$PACKAGES $USER_PKGS $AL_BASE_PKGS "
 
-       # using a different kernel, remove the stock one
-       [[ $KERNEL != 'linux' ]] && inpkg+="$KERNEL " rmpkg+="linux "
+       if [[ $MYSHELL == 'zsh' ]]; then
+               inpkg+="zsh-completions "
+       else
+               rmpkg+="zsh "
+       fi
 
-       # don't install extras on dwm only installs
-       if [[ $INSTALL_WMS != 'dwm' ]]; then
-               # gnome, plasma, and cinnamon have their own superkey bind and ksuperkey conflicts
-               [[ $INSTALL_WMS =~ ^(plasma|gnome|cinnamon)$ ]] || inpkg+="archlabs-ksuperkey "
-               # window manager only packages
-               [[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps|fluxbox) ]] && inpkg+="$WM_BASE_PKGS "
+       if [[ $INSTALL_WMS == 'dwm' ]]; then # dwm only needs a very limited package set
+               inpkg+="nitrogen polkit-gnome gnome-keyring dunst "
        else
-               inpkg+="arandr nitrogen polkit-gnome xclip xdotool compton gnome-keyring dunst feh "
+               [[ $INSTALL_WMS =~ (plasma|gnome|cinnamon) ]] || inpkg+="archlabs-ksuperkey "
+               [[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps|fluxbox) ]] && inpkg+="$WM_BASE_PKGS "
+               [[ $inpkg =~ (term|plasma|rxvt|tilda|tilix|sakura) || $INSTALL_WMS =~ (gnome|plasma|xfce4) ]] || inpkg+="xterm "
        fi
 
-       # update first to avoid issues
-       chrun "pacman -Syyu --noconfirm"
+       # update and install crucial packages first to avoid issues
+       chrun "pacman -Syyu $KERNEL $BASE_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $MYSHELL --noconfirm --needed" 2>$ERR
+       errshow 1 "pacman -Syyu $KERNEL $BASE_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $MYSHELL --noconfirm --needed"
 
        # remove the packages we don't want on the installed system
-       [[ $rmpkg ]] && chrun "pacman -Rnsc $rmpkg --noconfirm"
+       chrun "pacman -Rnsc $rmpkg --noconfirm"
 
        # reinstalling iputils fixes the network issue for non-root users
        chrun "pacman -S iputils $UCODE --noconfirm"
@@ -1512,6 +1520,39 @@ install_background()
 }
 
 ###############################################################################
+# display manager config
+# these are called based on which DM is chosen after it is installed
+# additional config can be  handled here, for now only lightdm has one
+
+lightdm_config()
+{
+       cat > $MNT/etc/lightdm/lightdm-gtk-greeter.conf <<- EOF
+       [greeter]
+       default-user-image=/usr/share/icons/ArchLabs-Dark/64x64/places/distributor-logo-archlabs.png
+       background=/usr/share/backgrounds/archlabs/archlabs.jpg
+       theme-name=Adwaita-dark
+       icon-theme-name=Adwaita
+       font-name=DejaVu Sans Mono 11
+       position=30%,end 50%,end
+       EOF
+}
+
+ly_config()
+{
+       :
+}
+
+gdm_config()
+{
+       :
+}
+
+sddm_config()
+{
+       :
+}
+
+###############################################################################
 # bootloader setup
 # prerun_* set up the configs needed before actually running the commands
 # setup_* are run after selecting a bootloader and build the command used later
@@ -1948,32 +1989,26 @@ luks_open()
 luks_pass()
 {
        LUKS_PASS=''
-       local t="$1" n='' p='' p2=''
+       local t="$1"
+       typeset -a ans=(cryptroot) # default name to start
 
        until [[ $LUKS_PASS ]]; do
-               local i=0
                tput cnorm
                dialog --insecure --backtitle "$DIST Installer - $SYS - v$VER" --separator $'\n' --title " $t " --mixedform "$_luksomenu" 0 0 0 \
-                       "Name:"      1 1 "${LUKS_NAME:-cryptroot}" 1  7 "$COLUMNS" 0 0 \
-                       "Password:"  2 1 ''                        2 11 "$COLUMNS" 0 1 \
-                       "Password2:" 3 1 ''                        3 12 "$COLUMNS" 0 1 2>"$ANS" || return 1
-
-               while read -r line; do
-                       case $i in
-                               0) n="$line" ;;
-                               1) p="$line" ;;
-                               2) p2="$line" ;;
-                       esac
-                       (( i++ ))
-               done < "$ANS"
+                       "Name:"      1 1 "${ans[0]}" 1  7 "$COLUMNS" 0 0 \
+                       "Password:"  2 1 ''          2 11 "$COLUMNS" 0 1 \
+                       "Password2:" 3 1 ''          3 12 "$COLUMNS" 0 1 2>"$ANS" || return 1
 
-               if [[ -z $n ]]; then
+               mapfile -t ans <"$ANS"
+
+               if [[ -z "${ans[0]}" ]]; then
                        msg "Name Empty" "\nEncrypted device name cannot be empty.\n\nPlease try again.\n" 2
-               elif [[ -z $p || "$p" != "$p2" ]]; then
-                       LUKS_NAME="$n"
+               elif [[ -z "${ans[1]}" || "${ans[1]}" != "${ans[2]}" ]]; then
+                       LUKS_NAME="${ans[0]}"
                        msg "Password Mismatch" "\nThe passwords entered do not match.\n\nPlease try again.\n" 2
                else
-                       LUKS_NAME="$n" LUKS_PASS="$p"
+                       LUKS_NAME="${ans[0]}"
+                       LUKS_PASS="${ans[1]}"
                fi
        done
 
@@ -2072,7 +2107,7 @@ dlg()
        # adjust n when passed a large list
        local l=$((LINES - 20))
        (( ($# / 2) > l )) && n=$l
-       
+
        tput civis
        case "$dlg_t" in
                menu) dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " $title " --menu "$body" 0 0 $n "$@" 2>"$ANS" || return 1 ;;
@@ -2111,7 +2146,11 @@ live()
 {
        local e=0
 
-       if ! select_keymap; then
+       if (( $# == 0 )); then
+               msg "No Session" "\nRunning live requires a session to use.\n\nExiting..\n" 2
+               clear
+               die 1
+       elif ! select_keymap; then
                clear
                die 0
        elif ! net_connect; then
@@ -2119,8 +2158,8 @@ live()
                die 1
        else
                clear
-               pacman -Syyu --noconfirm || die 1
-               pacman -S $AL_BASE_PKGS $WM_BASE_PKGS xorg-xinit xorg-server --needed --noconfirm || die 1
+               pacman -Syyu archlinux-keyring --needed --noconfirm || die 1
+               pacman -S $AL_BASE_PKGS xorg-xinit xorg-server --needed --noconfirm || die 1
                for ses; do
                        case "$ses" in
                                dwm)
@@ -2130,7 +2169,10 @@ live()
                                                git clone https://git.suckless.org/$i /root/suckless/$i && cd /root/suckless/$i && make PREFIX=/usr install
                                        done
                                        ;;
-                               i3-gaps|oepnbox|fluxbox|bspwm|xfce4|gnome|plasma|cinnamon|awesome)
+                               i3-gaps|oepnbox|fluxbox|bspwm|awesome)
+                                       pacman -S "$ses" $WM_BASE_PKGS ${WM_EXT[$ses]} xterm --needed --noconfirm || die 1
+                                       ;;
+                               gnome|plasma|cinnamon|xfce4)
                                        pacman -S "$ses" ${WM_EXT[$ses]} xterm --needed --noconfirm || die 1
                                        ;;
                                *) echo "error: invalid session for -l, --live, see -h, --help"; die 1 ;;
@@ -2140,7 +2182,7 @@ live()
                rm -rf "/var/cache/pacman/pkg/"*
                cp -rfT /etc/skel /root || die 1
                sed -i "/exec/ c exec ${WM_SESSIONS[$ses]}" /root/.xinitrc
-               printf "\n%s has been set as the login session in /root/.xinitrc, to start the session simply run\n\n\tstartx\n\n" "${WM_SESSIONS[$ses]}"
+               printf "\n%s has been set as the login session in ~/.xinitrc, to start the session simply run\n\n\tstartx\n\n" "${WM_SESSIONS[$ses]}"
                die 0
        fi
 }
@@ -2153,7 +2195,7 @@ usage()
        options:
            -h, --help     print this message and exit
            -l, --live     install and setup a live session
-           -d, --debug    enable debugging and log output to $DBG
+           -d, --debug    enable xtrace and log output to $DBG
 
        sessions:
            i3-gaps  - A fork of i3wm with more features including gaps
@@ -2167,6 +2209,18 @@ usage()
            plasma   - A kde software project currently comprising a full desktop environment
            xfce4    - A lightweight and modular desktop environment based on gtk+2/3
 
+       distro name:
+
+           set the DIST environment variable before launching the installer eg.
+
+                   DIST='MyDistro' $1
+
+       editor used:
+
+           set the EDITOR environment variable before launching the installer eg.
+
+                   EDITOR='nano' $1
+
        EOF
        exit 0
 }
@@ -2228,22 +2282,19 @@ errshow()
 
        local fatal=0 err=""
        err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")"
+       [[ -z $err ]] && err="no error message was found"
 
        (( $1 == 1 )) && { fatal=1; shift; }
 
-       if [[ $err ]]; then
-               local txt+="\nThe command exited abnormally:\n\n$1\n\nWith the following message:\n\n$err\n\n"
-       else
-               local txt+="\nThe command exited abnormally:\n\n$1\n\nWith no error message:\n\n"
-       fi
+       local txt="\nCommand: $1\n\n\n\nError: $err\n\n"
 
        if (( fatal )); then
-               msg "Install Error" "${txt}Errors at this stage are fatal and the install cannot continue.\n"
+               msg "Install Error" "${txt}Errors at this stage are fatal, the install cannot continue.\n"
                [[ -r $DBG && $TERM == 'linux' ]] && less "$DBG"
                die 1
        fi
 
-       msg "Install Error" "${txt}Errors at this stage are non-fatal and can be either fixed or ignored depending on the error.\n"
+       msg "Install Error" "${txt}Errors at this stage are non-fatal and may be fixed or ignored depending on the error.\n"
        return 1
 }
 
@@ -2375,7 +2426,11 @@ elif ! grep -qwm 1 'lm' /proc/cpuinfo; then
        msg "Not x86_64 Architecture" "\nThis installer only supports x86_64 architectures.\n\nExiting..\n" 2
        die 1
 else
-       case "$1" in -d|--debug) debug ;; -h|--help) usage "$0" ;; -l|--live) shift; live "$@" ;; esac
+       case "$1" in
+               -d|--debug) debug ;;
+               -h|--help) usage "$0" ;;
+               -l|--live) shift; live "$@" ;;
+       esac
 fi
 
 # trap ^C to perform cleanup