From 60f53a3b51a9577e1c844b09ec7e4f1cddfd8ba7 Mon Sep 17 00:00:00 2001 From: natemaia Date: Sun, 20 Oct 2019 19:49:12 -0700 Subject: [PATCH] Add jwm --- archlabs-installer | 140 ++++++++++++++++++++++++--------------------- 1 file changed, 75 insertions(+), 65 deletions(-) diff --git a/archlabs-installer b/archlabs-installer index 41a8a8b..e5f1b93 100755 --- a/archlabs-installer +++ b/archlabs-installer @@ -8,9 +8,9 @@ # check for syntax errors # set -n -VER=2.0.89 +VER=2.0.90 -# bulk default values { +# default values { : ${DIST=ArchLabs} # distro name if not set MNT=/mnt # installation root mountpoint @@ -26,6 +26,7 @@ RUN=/run/archiso/bootmnt/arch/boot # path for live system /boot VM="$(dmesg | grep -i hypervisor)" # system running in a virtual machine EXMNTS="" # extra partitions that were mounted, used to verify mountpoint and show user FORMATTED="" # partitions that have been formatted, allows skipping the format step +USER_CMD="" # optional command(s) entered by the user to run in the chroot export DIALOGOPTS="--cr-wrap" # dialog environment variable to hold default options, see `man dialog` BASE_PKGS="base xorg xorg-drivers sudo git gvfs gtk3 libmad libmatroska tumbler " @@ -57,13 +58,13 @@ declare -A BCMDS=( # executable name for each wm/de used in ~/.xinitrc { declare -A WM_SESSIONS=( -[dwm]='dwm' [i3-gaps]='i3' [bspwm]='bspwm' [awesome]='awesome' [plasma]='startkde' [xfce4]='startxfce4' +[dwm]='dwm' [jwm]='jwm' [i3-gaps]='i3' [bspwm]='bspwm' [awesome]='awesome' [plasma]='startkde' [xfce4]='startxfce4' [gnome]='gnome-session' [fluxbox]='startfluxbox' [openbox]='openbox-session' [cinnamon]='cinnamon-session' ) # } # packages installed for each wm/de, most are depends of the skel packages { declare -A WM_EXT=( -[dwm]='' [gnome]='' [cinnamon]='gnome-terminal' [plasma]='kdebase-meta' +[dwm]='' [jwm]='' [gnome]='' [cinnamon]='gnome-terminal' [plasma]='kdebase-meta' [awesome]='archlabs-skel-awesome' [bspwm]='archlabs-skel-bspwm' [fluxbox]='archlabs-skel-fluxbox' [i3-gaps]='archlabs-skel-i3-gaps' [openbox]='archlabs-skel-openbox' [xfce4]='archlabs-skel-xfce4 xfce4-goodies' ) # } @@ -135,6 +136,7 @@ _sessions="\nUse [Space] to toggle available sessions, use [Enter] to accept the _login="\nSelect which of your session choices to use for the initial login.\n\nYou can be change this later by editing your ~/.xinitrc" _autologin="\nDo you want autologin enabled for USER?\n\nIf so the following two files will be created (disable autologin by removing them):\n\n - /home/USER/RC (run startx when logging in on tty1)\n - /etc/systemd/system/getty@tty1.service.d/autologin.conf (login USER without password)\n" _packages="\nUse [Space] to move a package into the selected area and press [Enter] to accept the selection.\n\nPackages may be installed by your DE/WM (if any), or for the packages you select." +_usercmd="\nEnter command(s) to be run in the newly installed system (chroot).\n\nAn example use case would be installing packages or editing files not offered in the menus.\n\nBecause the command will be run in a chroot not everything may function correctly, additionally the command will not be sanity checked, it's your system so exercise caution.\n\nYou may string more than one command together by using standard bash syntax.\n" _edit="\nBefore exiting you can select configuration files to review/change.\n\nIf you need to make other changes with the drives still mounted, use Ctrl-z to pause the installer, when finished type 'fg' and [Enter] to resume the installer, if you want to avoid the automatic reboot using Ctrl-c will cleanly exit." # LUKS @@ -174,7 +176,7 @@ _lvmerrlvsize="\nInvalid value Entered.\n\nMust be a numeric value with 'M' (meg main() { - (( SEL < 12 )) && (( SEL++ )) + (( SEL < 13 )) && (( SEL++ )) tput civis dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " Prepare " --default-item $SEL --cancel-label 'Exit' --menu "$_prep" 0 0 0 \ 1 "Show device tree" \ @@ -188,7 +190,8 @@ main() 9 "Select window manager or desktop" \ 10 "Select additional packages" \ 11 "View configuration selections" \ - 12 "* Confirm choices and start the installation" 2> "$ANS" + 12 "Add a command to be run on the system during install" \ + 13 "* Confirm choices and start the installation" 2> "$ANS" read -r SEL < "$ANS" [[ -z $WARN && $SEL =~ (2|5) ]] && { msg "Data Warning" "$_warn"; WARN=true; } @@ -204,7 +207,8 @@ main() 9) prechecks 3 && { select_sessions || (( SEL-- )); } ;; 10) prechecks 3 && { select_packages || (( SEL-- )); } ;; 11) prechecks 3 && select_show ;; - 12) prechecks 3 && install_main ;; + 12) prechecks 3 && select_usercmd ;; + 13) prechecks 3 && install_main ;; *) yesno "Exit" "\nUnmount partitions (if any) and exit the installer?\n" && die 0 esac } @@ -270,8 +274,6 @@ select_show() select_login() { - [[ $INSTALL_WMS ]] || return 0 - AUTOLOGIN='' # no autologin unless using xinit dlg LOGIN_TYPE menu "Login Management" "\nSelect what kind of login management to use." \ @@ -414,14 +416,20 @@ select_keymap() return 0 } +select_usercmd() +{ + dlg MYHOST input "User Command" "$_usercmd" "$USER_CMD" nolimit +} + select_sessions() { LOGIN_CHOICES='' dlg INSTALL_WMS check "Sessions" "$_sessions\n" \ - openbox "A lightweight, powerful, and highly configurable stacking wm" "$(ofn openbox "${INSTALL_WMS[*]}")" \ i3-gaps "A fork of i3wm with more features including gaps" "$(ofn i3-gaps "${INSTALL_WMS[*]}")" \ + openbox "A lightweight, powerful, and highly configurable stacking wm" "$(ofn openbox "${INSTALL_WMS[*]}")" \ dwm "A dynamic WM for X that manages windows in tiled, floating, or monocle layouts" "$(ofn dwm "${INSTALL_WMS[*]}")" \ bspwm "A tiling wm that represents windows as the leaves of a binary tree" "$(ofn bspwm "${INSTALL_WMS[*]}")" \ + jwm "A lightweight window manager for Xorg written in C" "$(ofn jwm "${INSTALL_WMS[*]}")" \ xfce4 "A lightweight and modular desktop environment based on gtk+2/3" "$(ofn xfce4 "${INSTALL_WMS[*]}")" \ awesome "A customized Awesome WM session created by @elanapan" "$(ofn awesome "${INSTALL_WMS[*]}")" \ fluxbox "A lightweight and highly-configurable window manager" "$(ofn fluxbox "${INSTALL_WMS[*]}")" \ @@ -430,10 +438,9 @@ select_sessions() cinnamon "A desktop environment combining traditional desktop with modern effects" "$(ofn cinnamon "${INSTALL_WMS[*]}")" [[ $INSTALL_WMS ]] || return 0 - - WM_PKGS="${INSTALL_WMS/dwm/}" # remove dwm from package list - WM_PKGS="${WM_PKGS// / }" # remove double spaces - WM_PKGS="${WM_PKGS# }" # remove leading space + WM_PKGS="${INSTALL_WMS/dwm/}" + WM_PKGS="${WM_PKGS// / }" + WM_PKGS="${WM_PKGS# }" for i in $INSTALL_WMS; do LOGIN_CHOICES+="$i - " @@ -1127,7 +1134,7 @@ select_extra_partitions() install_main() { install_base - genfstab -U "$MNT" > "$MNT/etc/fstab" 2> $ERR 2>&1 + genfstab -U "$MNT" > "$MNT/etc/fstab" 2> "$ERR" 2>&1 errshow 1 "genfstab -U $MNT > $MNT/etc/fstab" [[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" "$MNT/etc/fstab" install_packages @@ -1139,6 +1146,10 @@ install_main() install_user install_login chrun "chown -Rf $NEWUSER:users /home/$NEWUSER" + if [[ "$USER_CMD" ]]; then + chrun "$USER_CMD" 2> "$ERR" 2>&1 + errshow 0 "$USER_CMD" + fi while :; do dlg choice menu "Finalization" "$_edit" \ @@ -1156,18 +1167,18 @@ install_main() login "${EDIT_FILES[login]}" if [[ -z $choice || $choice == 'finished' ]]; then - [[ $DEBUG == true && -r $DBG ]] && ${EDITOR:-vim} $DBG - clear && die 127 + [[ $DEBUG == true && -r $DBG ]] && ${EDITOR:-vim} "$DBG" + clear + die 127 else local exists='' for f in ${EDIT_FILES[$choice]}; do - [[ -e ${MNT}$f ]] && exists+=" ${MNT}$f" + if [[ -e ${MNT}$f ]]; then + ${EDITOR:-vim} "${MNT}$f" + else + msg "File Missing" "\nThe file(s) selected do not exist:\n\n${MNT}$f\n" + fi done - if [[ $exists ]]; then - ${EDITOR:-vim} -O $exists - else - msg "File Missing" "\nThe file(s) selected do not exist:\n\n${EDIT_FILES[$choice]}\n" - fi fi done } @@ -1291,32 +1302,30 @@ install_boot() install_user() { local groups='audio,video,floppy,log,network,rfkill,scanner,storage,optical,power,wheel' - if [[ -e $MNT/etc/X11/xorg.conf.d/20-nvida.conf && -e $MNT/usr/bin/optirun ]]; then - groups+=',bumblebee' - fi + [[ -e $MNT/etc/X11/xorg.conf.d/20-nvida.conf && -e $MNT/usr/bin/optirun ]] && groups+=',bumblebee' rm -f "$MNT/root/.zlogin" # remove welcome message - chrun "chpasswd <<< 'root:$ROOT_PASS'" 2> $ERR 2>&1 + chrun "chpasswd <<< 'root:$ROOT_PASS'" 2> "$ERR" 2>&1 errshow 1 "set root password" if [[ $MYSHELL != 'zsh' ]]; then # root uses zsh by default - chrun "usermod -s /bin/$MYSHELL root" 2> $ERR 2>&1 + chrun "usermod -s /bin/$MYSHELL root" 2> "$ERR" 2>&1 errshow 1 "usermod -s /bin/$MYSHELL root" # copy the default mkshrc to /root if it was selected [[ $MYSHELL == 'mksh' ]] && cp -fv "$MNT/etc/skel/.mkshrc" "$MNT/root/.mkshrc" fi echo "Creating new user $NEWUSER and setting password" - chrun "useradd -m -u 1000 -g users -G $groups -s /bin/$MYSHELL $NEWUSER" 2> $ERR 2>&1 + chrun "useradd -m -u 1000 -g users -G $groups -s /bin/$MYSHELL $NEWUSER" 2> "$ERR" 2>&1 errshow 1 "useradd -m -u 1000 -g users -G $groups -s /bin/$MYSHELL $NEWUSER" - chrun "chpasswd <<< '$NEWUSER:$USER_PASS'" 2> $ERR 2>&1 + chrun "chpasswd <<< '$NEWUSER:$USER_PASS'" 2> "$ERR" 2>&1 errshow 1 "set $NEWUSER password" if [[ $INSTALL_WMS == *dwm* ]];then install_suckless "/home/$NEWUSER" chroot [[ $INSTALL_WMS == 'dwm' ]] && rm -rf "$MNT/home/$NEWUSER/.config/xfce4" fi - + [[ $INSTALL_WMS == *jwm* ]] && cp -rf "$MNT/etc/system.jwmrc" "$MNT/home/$NEWUSER/.jwmrc" [[ $INSTALL_WMS != *bspwm* && $INSTALL_WMS != *openbox* ]] && rm -rf "$MNT/home/$NEWUSER/.config/"{jgmenu,tint2} [[ $USER_PKGS != *geany* ]] && rm -rf "$MNT/home/$NEWUSER/.config/geany" [[ $MYSHELL != 'bash' ]] && rm -rf "$MNT/home/$NEWUSER/.bash"* @@ -1329,9 +1338,6 @@ install_user() 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 } @@ -1368,7 +1374,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 ] && startx + [ \$XDG_VTNR -eq 1 ] && exec startx EOF else rm -rf $serv @@ -1386,14 +1392,6 @@ install_packages() rmpkg+="archlabs-installer " fi - if [[ $VM ]] && dmesg | grep -qi 'vbox'; then - inpkg+="virtualbox-guest-utils " - case "$KERNEL" in - linux) inpkg+="virtualbox-guest-modules-arch " ;; - *) inpkg+="virtualbox-guest-modules-dkms ${KERNEL}-headers " ;; - esac - fi - if [[ $MYSHELL == 'zsh' ]]; then inpkg+="zsh-completions " else @@ -1433,6 +1431,13 @@ install_packages() errshow 1 "pacman -S efibootmgr --needed --noconfirm" fi + if [[ $VM ]] && dmesg | grep -qi 'vbox'; then + case "$KERNEL" in + linux) chrun "pacman -S virtualbox-guest-utils virtualbox-guest-modules-arch --needed --noconfirm" ;; + *) chrun "pacman -S virtualbox-guest-utils virtualbox-guest-modules-dkms ${KERNEL}-headers --needed --noconfirm" ;; + esac + fi + # allow members of the wheel group to run commands as root sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" "$MNT/etc/sudoers" @@ -1443,7 +1448,6 @@ install_suckless() { local dir="$1/suckless" shift - if [[ $2 == 'chroot' ]]; then chrun "mkdir -pv '$dir'" for i in dwm dmenu st; do @@ -1573,6 +1577,14 @@ install_tearfree_conf() return 0 fi + if lspci | grep ' VGA ' | grep -q 'Intel\|AMD/ATI'; then + if [[ $xpath == *"$MNT"* ]]; then + sed 's/xrender/glx/g' "$MNT/etc/skel/.config/compton.conf" + else + sed 's/xrender/glx/g' /etc/skel/.config/compton.conf + fi + fi + # remove nvidia installer from installed system when not running nvidia gpu [[ $xpath == *"$MNT"* ]] && rm -rf "$MNT/usr/bin/nvidia-installer" "$MNT/var/lib/nvidia-installer" } @@ -1582,19 +1594,6 @@ install_tearfree_conf() # 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() { : #TODO @@ -1610,6 +1609,19 @@ sddm_config() : #TODO } +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 +} + ############################################################################### # bootloader setup # prerun_* set up the configs needed before actually running the commands @@ -2173,9 +2185,7 @@ die() tput cnorm if [[ -d $MNT ]]; then umount_dir "$MNT" - if (( e == 127 )); then - umount_dir /run/archiso/bootmnt && sleep 0.5 && reboot -f - fi + (( e == 127 )) && umount_dir /run/archiso/bootmnt && sleep 0.5 && reboot -f fi exit $e } @@ -2248,18 +2258,18 @@ live() mount /run/archiso/cowspace -o remount,size=2G install_mirrorlist "/etc/pacman.d/mirrorlist" pacman -Syyu --noconfirm || die 1 - rm -rf "/var/cache/pacman/pkg/"* + rm -rf /var/cache/pacman/pkg/* pacman -S $BASE_PKGS $AL_BASE_PKGS xorg-xinit --needed --noconfirm || die 1 - rm -rf "/var/cache/pacman/pkg/"* + rm -rf /var/cache/pacman/pkg/* case "$ses" in - i3-gaps|openbox|fluxbox|bspwm|awesome|xfce4) pacman -S "$ses" $WM_BASE_PKGS ${WM_EXT[$ses]} --needed --noconfirm || die 1 ;; + i3-gaps|openbox|fluxbox|bspwm|awesome|xfce4|jwm) pacman -S "$ses" $WM_BASE_PKGS ${WM_EXT[$ses]} --needed --noconfirm || die 1 ;; gnome|plasma|cinnamon) pacman -S "$ses" ${WM_EXT[$ses]} --needed --noconfirm || die 1 ;; dwm) { pacman -S git --needed --noconfirm || die 1; }; install_suckless "/root" nochroot ;; esac - rm -rf "/var/cache/pacman/pkg/"* + rm -rf /var/cache/pacman/pkg/* [[ $VM ]] && dmesg | grep -qi 'vbox' && pacman -S virtualbox-guest-utils virtualbox-guest-modules-arch --needed --noconfirm pacman -Scc --noconfirm - rm -rf "/var/cache/pacman/pkg/"* + rm -rf /var/cache/pacman/pkg/* cp -rfT /etc/skel /root install_tearfree_conf "/etc/X11/xorg.conf.d" case "$ses" in