#!/usr/bin/env bash # # _ _ _____ _____ _____ # | \ | |_ _| _ / ___| # | \| | | | | | | \ `--. # | . ` | | | | | | |`--. \ # | |\ | | | \ \_/ /\__/ / # \_| \_/ \_/ \___/\____/ # # NAME: NTOS # DESC: An installation and deployment script for Naves Qtile Desktop # WARNING: Run this script at your own risk. # DEPENDENCIES: libnewt (probably already on the system) if [ "$(id -u)" = 0 ]; then echo "##################################################################" echo "This script MUST NOT be run as root user since it makes changes" echo "to the \$HOME directory of the \$USER executing this script." echo "The \$HOME directory of the root user is, of course, '/root'." echo "We don't want to mess around in there. So run this script as a" echo "normal user. You will be asked for a sudo password when necessary." echo "##################################################################" exit 1 fi error() { \ clear; printf "ERROR:\\n%s\\n" "$1" >&2; exit 1; } export NEWT_COLORS=" root=,blue window=,black shadow=,blue border=blue,black title=blue,black textbox=blue,black radiolist=black,black label=black,blue checkbox=black,blue compactbutton=black,blue button=black,red" echo "##################################################################" echo "## Syncing the repos and installing 'whiptail' if not installed ##" echo "##################################################################" sudo pacman --noconfirm --needed -Sy sudo pacman --noconfirm --needed -Syu libnewt || error "Error syncing the repos." welcome() { \ whiptail --title "Installing NTOS!" --msgbox "This script will install the basic arch packages for some DE and clone my personal(private) repo's. You must have your key in git for this to work" 16 60 } welcome || error "User choose to exit." speedwarning() { \ whiptail --title "Installing NTOS!" --yesno "WARNING! The ParallelDownloads option is not enabled in /etc/pacman.conf. This may result in slower installation speeds. Are you sure you want to continue?" 16 60 || error "User choose to exit." } distrowarning() { \ whiptail --title "Installing DTOS!" --msgbox "WARNING! While this script works on all Arch based distros, some distros choose to package certain things that we also package, which may result in errors when trying to install DTOS packages. If this happens, please look at the package list and remove conflicts manually." 16 60 || error "User choose to exit." } grep -qs "#ParallelDownloads" /etc/pacman.conf && speedwarning grep -qs "ID=arch" /etc/os-release || distrowarning lastchance() { \ whiptail --title "Installing NTOS!" --msgbox "WARNING! The NTOS installation script is currently in public beta testing. There are almost certainly errors in it; therefore, it is strongly recommended that you not install this on production machines. It is recommended that you try this out in either a virtual machine or on a test machine." 16 60 whiptail --title "Are You Sure You Want To Do This?" --yesno "Shall we begin installing NTOS?" 8 60 || { clear; exit 1; } } lastchance || error "User choose to exit." grep "LC_CTYPE" /etc/locale.conf && echo "Checking the LC_CYPE variable in /etc/locale.conf. Variable is already set." || grep "LANG=" /etc/locale.conf | sed 's/LANG=/LC_CTYPE=/g' | sudo tee -a /etc/locale.conf sudo locale-gen addrepo() { \ echo "#########################################################" echo "## Adding the DTOS core repository to /etc/pacman.conf ##" echo "## this is needed for some dm-scripts and a few other ##" echo "## things. This will likely get removed in future vers ##" echo "#########################################################" grep -qxF "[dtos-core-repo]" /etc/pacman.conf || ( echo " "; echo "[dtos-core-repo]"; echo "SigLevel = Optional DatabaseOptional"; \ echo "Server = https://gitlab.com/dtos/\$repo/-/raw/main/\$arch") | sudo tee -a /etc/pacman.conf } addrepo || error "Error adding DTOS repo to /etc/pacman.conf." install_paru() { # Create the /usr/external directory with sudo privileges sudo mkdir -p /usr/external sudo chown $(whoami):$(whoami) /usr/external # Navigate to the /usr/external directory cd /usr/external # Install base-devel sudo pacman -S --needed base-devel # Clone the paru repository git clone https://aur.archlinux.org/paru.git # Change the current directory to the paru directory cd paru # Build and install paru makepkg -srci } install_paru || error "Error paru" choosewm() { \ whiptail --title "CHOOSE YOUR WINDOW MANAGER(S)" --msgbox "Choose at least one window manager to install. The choices are: Xmonad, Awesome and Qtile. If unsure, Qtile is the recommended choice, or install all options and try out each of them." 16 60 } installxmonad() { \ whiptail --title "Window Managers - Xmonad" --yesno "Would you like to install Xmonad?" 8 60 } installawesome() { \ whiptail --title "Window Managers - Awesome" --yesno "Would you like to install Awesome?" 8 60 } installbspwm() { \ whiptail --title "Window Managers - Bspwm" --yesno "Would you like to install Bspwm?" 8 60 } installdwm() { \ whiptail --title "Window Managers - Dwm" --yesno "Would you like to install Dwm?" 8 60 } installqtile() { \ whiptail --title "Window Managers - Qtile" --yesno "Would you like to install Qtile?" 8 60 } choosewm || error "User chose to exit" installxmonad && sudo pacman -Sy xmonad xmonad-contrib xmobar polybar || echo "User chose not to install XMonad" installawesome && sudo pacman -Sy awesome || echo "User chose not to install Awesome" installqtile && paru --needed --ask 4 -Sy qtile qtile-extras python-psutil || echo "User chose not to install Qtile" max() { echo -e "$1\n$2" | sort -n | tail -1 } getbiggestword() { echo "$@" | sed "s/ /\n/g" | wc -L } replicate() { local n="$1" local x="$2" local str for _ in $(seq 1 "$n"); do str="$str$x" done echo "$str" } programchoices() { choices=() local maxlen; maxlen="$(getbiggestword "${!checkboxes[@]}")" linesize="$(max "$maxlen" 42)" local spacer; spacer="$(replicate "$((linesize - maxlen))" " ")" for key in "${!checkboxes[@]}" do # A portable way to check if a command exists in $PATH and is executable. # If it doesn't exist, we set the tick box to OFF. # If it exists, then we set the tick box to ON. if ! command -v "${checkboxes[$key]}" > /dev/null; then # $spacer length is defined in the individual window functions based # on the needed length to make the checkbox wide enough to fit window. choices+=("${key}" "${spacer}" "OFF") else choices+=("${key}" "${spacer}" "ON") fi done } selectedprograms() { result=$( # Creates the whiptail checklist. Also, we use a nifty # trick to swap stdout and stderr. whiptail --title "$title" \ --checklist "$text" 22 "$((linesize + 16))" 12 \ "${choices[@]}" \ 3>&2 2>&1 1>&3 ) } exitorinstall() { exitstatus=$? # Check the exit status, if 0 we will install the selected # packages. A command which exits with zero (0) has succeeded. # A non-zero (1-255) exit status indicates failure. if [ $exitstatus = 0 ]; then # Take the results and remove the "'s and add new lines. # Otherwise, pacman is not going to like how we feed it. programs=$(echo $result | sed 's/" /\n/g' | sed 's/"//g' ) echo $programs paru --needed --ask 4 -Sy "$programs" || \ echo "Failed to install required packages." else echo "User selected Cancel." fi } browsers () { title="Web Browsers" text="Select one or more web browsers to install.\nAll programs marked with '*' are already installed.\nUnselecting them will NOT uninstall them." spacer=$(for i in $(seq 1 38); do echo -n " "; done) local -A checkboxes checkboxes["brave-bin"]="brave" checkboxes["chromium"]="chromium" checkboxes["firefox"]="firefox" checkboxes["google-chrome"]="google-chrome-stable" checkboxes["icecat-bin"]="icecat" checkboxes["librewolf-bin"]="librewolf" checkboxes["microsoft-edge-stable-bin"]="microsoft-edge-stable" checkboxes["opera"]="opera" checkboxes["qutebrowser"]="qutebrowser" checkboxes["ungoogled-chromium-bin"]="ungoogled-chromium" checkboxes["vivaldi"]="vivaldi" programchoices && selectedprograms && exitorinstall } otherinternet () { title="Other Internet Programs" text="Other Internet programs available for installation.\nAll programs marked with '*' are already installed.\nUnselecting them will NOT uninstall them." spacer=$(for i in $(seq 1 47); do echo -n " "; done) local -A checkboxes checkboxes["deluge"]="deluge" checkboxes["discord"]="discord" checkboxes["element-desktop"]="element-desktop" checkboxes["filezilla"]="filezilla" checkboxes["geary"]="geary" checkboxes["hexchat"]="hexchat" checkboxes["jitsi-meet-bin"]="jitsi-meet-desktop" checkboxes["mailspring"""]="mailspring" checkboxes["telegram-desktop"]="telegram" checkboxes["thunderbird"]="thunderbird" checkboxes["transmission-gtk"]="transmission-gtk" programchoices && selectedprograms && exitorinstall } multimedia() { title="Multimedia Programs" text="Multimedia programs available for installation.\nAll programs marked with '*' are already installed.\nUnselecting them will NOT uninstall them." spacer=$(for i in $(seq 1 53); do echo -n " "; done) local -A checkboxes checkboxes["blender"]="blender" checkboxes["deadbeef"]="deadbeef" checkboxes["gimp"]="gimp" checkboxes["inkscape"]="inkscape" checkboxes["kdenlive"]="kdenlive" checkboxes["krita"]="krita" checkboxes["mpv"]="mpv" checkboxes["obs-studio"]="obs" checkboxes["rhythmbox"]="rhythmbox" checkboxes["ristretto"]="ristretto" checkboxes["vlc"]="vlc" programchoices && selectedprograms && exitorinstall } office() { title="Office Programs" text="Office and productivity programs available for installation.\nAll programs marked with '*' are already installed.\nUnselecting them will NOT uninstall them." spacer=$(for i in $(seq 1 46); do echo -n " "; done) local -A checkboxes checkboxes["abiword"]="abiword" checkboxes["evince"]="evince" checkboxes["gnucash"]="gnucash" checkboxes["gnumeric"]="gnumeric" checkboxes["libreoffice-fresh"]="lowriter" checkboxes["libreoffice-still"]="lowriter" checkboxes["scribus"]="scribus" checkboxes["zathura"]="zathura" programchoices && selectedprograms && exitorinstall } games () { title="Games" text="Gaming programs available for installation.\nAll programs marked with '*' are already installed.\nUnselecting them will NOT uninstall them." spacer=$(for i in $(seq 1 51); do echo -n " "; done) local -A checkboxes checkboxes["0ad"]="0ad" checkboxes["gnuchess"]="gnuchess" checkboxes["lutris"]="lutris" checkboxes["neverball"]="neverball" checkboxes["openarena"]="openarena" checkboxes["steam"]="steam" checkboxes["supertuxkart"]="supertuxkart" checkboxes["sauerbraten"]="sauerbraten-client" checkboxes["teeworlds"]="teeworlds" checkboxes["veloren-bin"]="veloren" checkboxes["wesnoth"]="wesnoth" checkboxes["xonotic"]="xonotic-glx" programchoices && selectedprograms && exitorinstall } browsers otherinternet multimedia office games # Let's install each package listed in the pkglist.txt file. sudo pacman --needed --ask 4 -Sy - < pkglist.txt || error "Failed to install a required package from pkglist.txt." echo "################################################################" echo "## Cloning Mordent Minds Personal Repos. You are required to ##" echo "## have a key. You have been warned. ##" echo "################################################################" paru --noconfirm starship mkdir -p $HOME/.config/{doom,qtile,alacritty} mkdir -p $HOME/dotfiles git clone ssh://git@git.nave.house:222/jnave/zsh-extras.git $HOME/dotfiles/zsh-extras git clone ssh://git@git.nave.house:222/jnave/qtile-config.git $HOME/dotfiles/qtile-config git clone ssh://git@git.nave.house:222/jnave/zsh-config.git $HOME/dotfiles/zsh-config git clone ssh://git@git.nave.house:222/jnave/doom-emacs.git $HOME/.config/doom git clone ssh://git@git.nave.house:222/jnave/zsh-extras.git $HOME/dotfiles/zsh-extras git clone ssh://git@git.nave.house:222/jnave/alacritty-dotfiles.git $HOME/dotfiles/alacritty-dotfiles git clone ssh://git@git.nave.house:222/jnave/starship-dotfiles.git $HOME/dotfiles/starship-dotfiles # Change all scripts in .local/bin to be executable. find $HOME/.local/bin -type f -print0 | xargs -0 chmod 775 echo "#########################################################" echo "## Installing Doom Emacs. This may take a few minutes. ##" echo "#########################################################" [ -d ~/.emacs.d ] && mv ~/.emacs.d ~/.emacs.d.bak.$(date +"%Y%m%d_%H%M%S") [ -f ~/.emacs ] && mv ~/.emacs ~/.emacs.bak.$(date +"%Y%m%d_%H%M%S") git clone --depth 1 https://github.com/doomemacs/doomemacs ~/.config/emacs ~/.config/emacs/bin/doom --force install ~/.config/emacs/bin/doom sync [ ! -d /etc/pacman.d/hooks ] && sudo mkdir /etc/pacman.d/hooks [ -f /usr/bin/xmonad ] && sudo cp /etc/dtos/.config/xmonad/pacman-hooks/recompile-xmonad.hook /etc/pacman.d/hooks/ [ -f /usr/bin/xmonad ] && sudo cp /etc/dtos/.config/xmonad/pacman-hooks/recompile-xmonadh.hook /etc/pacman.d/hooks/ xmonad_recompile() { \ echo "########################" echo "## Recompiling XMonad ##" echo "########################" xmonad --recompile } [ -f /usr/bin/xmonad ] && xmonad_recompile || echo "Recompiling Xmonad failed!" xmonadctl_compile() { \ echo "####################################" echo "## Compiling the xmonadctl script ##" echo "####################################" ghc -dynamic "$HOME"/.config/xmonad/xmonadctl.hs } xmonadctl_compile || echo "Compiling the xmonadctl script failed!" PS3='Set default user shell (enter number): ' shells=("fish" "bash" "zsh" "quit") select choice in "${shells[@]}"; do case $choice in fish | bash | zsh) sudo chsh $USER -s "/bin/$choice" && \ echo -e "$choice has been set as your default USER shell. \ \nLogging out is required for this take effect." break ;; quit) echo "User quit without changing shell." break ;; *) echo "invalid option $REPLY" ;; esac done # Disable the current login manager sudo systemctl disable $(grep '/usr/s\?bin' /etc/systemd/system/display-manager.service | awk -F / '{print $NF}') || echo "Cannot disable current display manager." # Enable sddm as login manager sudo systemctl enable sddm echo "###################################" echo "## Enable sddm as login manager. ##" echo "###################################" ## Make multicolor-sddm-theme the default sddm theme ## # This is the sddm system configuration file. [ -f "/usr/lib/sddm/sddm.conf.d/default.conf" ] && \ sudo cp /usr/lib/sddm/sddm.conf.d/default.conf /usr/lib/sddm/sddm.conf.d/default.conf.backup && \ sudo sed -i 's/^Current=*.*/Current=multicolor-sddm-theme/g' /usr/lib/sddm/sddm.conf.d/default.conf # This is the sddm local configuration file. [ -f "/etc/sddm.conf" ] && \ sudo cp /etc/sddm.conf /etc/sddm.conf.backup && \ sudo sed -i 's/^Current=*.*/Current=multicolor-sddm-theme/g' /etc/sddm.conf # Create a local configuration file if it doesn't exist. # Standard Arch Linux does not create this file by default. [ ! -f "/etc/sddm.conf" ] && \ sudo cp /usr/lib/sddm/sddm.conf.d/default.conf /etc/sddm.conf || echo "Default sddm system config file is not found." # ArcoLinux B Awesome uses this config location. [ -f "/etc/sddm.conf.d/kde_settings.conf" ] && \ sudo cp /etc/sddm.conf.d/kde_settings.conf /etc/sddm.conf.d/kde_settings.backup && \ sudo sed -i 's/^Current=*.*/Current=multicolor-sddm-theme/g' /etc/sddm.conf.d/kde_settings.conf echo "##############################" echo "## DTOS has been installed! ##" echo "##############################" while true; do read -p "Do you want to reboot to get your dtos? [Y/n] " yn case $yn in [Yy]* ) reboot;; [Nn]* ) break;; "" ) reboot;; * ) echo "Please answer yes or no.";; esac done