2017-12-06 18:30:31 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# =======================================
|
2018-04-30 21:35:17 +02:00
|
|
|
# Helper functions
|
2017-12-06 18:30:31 +01:00
|
|
|
# =======================================
|
|
|
|
|
|
|
|
# Ask a question and return true or false based on the users input
|
2018-05-04 19:28:02 +02:00
|
|
|
ask() {
|
|
|
|
# from https://djm.me/ask
|
|
|
|
local prompt default reply
|
|
|
|
|
2017-12-06 18:30:31 +01:00
|
|
|
while true; do
|
2018-05-04 19:28:02 +02:00
|
|
|
|
|
|
|
if [ "${2:-}" = "Y" ]; then
|
|
|
|
prompt="Y/n"
|
|
|
|
default=Y
|
|
|
|
elif [ "${2:-}" = "N" ]; then
|
|
|
|
prompt="y/N"
|
|
|
|
default=N
|
|
|
|
else
|
|
|
|
prompt="y/n"
|
|
|
|
default=
|
|
|
|
fi
|
|
|
|
echo -n "$1 [$prompt] "
|
|
|
|
read reply </dev/tty
|
|
|
|
|
|
|
|
if [ -z "$reply" ]; then
|
|
|
|
reply=$default
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$reply" in
|
|
|
|
[Yy]*) return 0 ;;
|
|
|
|
[Nn]*) return 1 ;;
|
2017-12-06 18:30:31 +01:00
|
|
|
esac
|
2018-05-04 19:28:02 +02:00
|
|
|
|
2017-12-06 18:30:31 +01:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2018-04-30 21:35:17 +02:00
|
|
|
# delete target, create dirs if they don't exist yet and finally symlink the dir
|
|
|
|
function linkDir {
|
|
|
|
rm -rf $2;
|
|
|
|
mkdir -p "${2%/*}"
|
|
|
|
ln -sf $1 $2
|
|
|
|
}
|
|
|
|
|
|
|
|
# replace line endings with a space (for use in package managers)
|
|
|
|
function fileToList {
|
|
|
|
echo $(cat $1 | sed ':a;N;$!ba;s/\n/ /g')
|
|
|
|
}
|
|
|
|
|
2018-07-02 22:16:18 +02:00
|
|
|
# create and copy files to directory
|
|
|
|
function copyToDir {
|
|
|
|
echo $2 | sed 's%/[^/]*$%/%' | xargs mkdir -p
|
|
|
|
cp $1 $2
|
|
|
|
}
|
|
|
|
|
2018-04-30 21:35:17 +02:00
|
|
|
# =======================================
|
|
|
|
# Installation functions
|
|
|
|
# =======================================
|
|
|
|
|
2018-04-08 16:31:05 +02:00
|
|
|
# moves all fonts into the fonts directories (overwriting existing files)
|
2017-12-06 18:30:31 +01:00
|
|
|
function install_fonts {
|
2018-02-13 20:38:48 +01:00
|
|
|
mkdir -p ~/.fonts
|
2018-04-08 16:31:05 +02:00
|
|
|
mkdir -p ~/.local/share/fonts
|
|
|
|
yes | cp -rf ./fonts/* ~/.fonts
|
|
|
|
yes | cp -rf ./fonts/* ~/.local/share/fonts
|
2017-12-06 18:30:31 +01:00
|
|
|
}
|
|
|
|
|
2018-04-20 11:00:27 +02:00
|
|
|
# install trizen, a aur helper
|
|
|
|
function install_trizen {
|
|
|
|
git clone https://aur.archlinux.org/trizen.git
|
|
|
|
pushd trizen
|
2018-04-30 21:35:17 +02:00
|
|
|
makepkg -si
|
2018-04-20 11:00:27 +02:00
|
|
|
popd
|
|
|
|
sudo rm -dRf trizen/
|
|
|
|
}
|
|
|
|
|
2017-12-06 18:30:31 +01:00
|
|
|
# install other configs
|
|
|
|
function install_config {
|
2018-04-30 21:35:17 +02:00
|
|
|
|
|
|
|
# link directories
|
|
|
|
linkDir "$PWD"/wallpapers ~/Pictures/Wallpapers
|
|
|
|
linkDir "$PWD"/i3/ ~/.config/i3
|
|
|
|
linkDir "$PWD"/config/notify-osd/notify-osd ~/.notify-osd
|
|
|
|
linkDir "$PWD"/config/terminal/xfce4-term ~/.config/xfce4/terminal
|
|
|
|
linkDir "$PWD"/config/gtk-3.0/settings.ini ~/.config/gtk-3.0/.config
|
|
|
|
linkDir "$PWD"/templates ~/Templates
|
2019-07-04 22:33:48 +02:00
|
|
|
linkDir "$PWD"/config/ranger ~/.config/
|
|
|
|
|
2018-04-30 21:35:17 +02:00
|
|
|
# link user files
|
2018-04-08 16:31:05 +02:00
|
|
|
ln -sf "$PWD"/bash/.bashrc ~/.bashrc
|
|
|
|
ln -sf "$PWD"/bash/.alias.sh ~/.alias
|
2018-04-23 10:06:10 +02:00
|
|
|
ln -sf "$PWD"/config/nano/.nanorc ~/.nanorc
|
2018-04-30 21:35:17 +02:00
|
|
|
ln -sf "$PWD"/bash/.powerline-shell.json ~/.powerline-shell.json
|
|
|
|
ln -sf "$PWD"/wallpapers/space.jpg ~/Pictures/Wallpapers/wallpaper.jpg
|
2018-08-15 18:42:09 +02:00
|
|
|
mkdir -p ~/.config/rofi
|
2018-05-04 19:28:02 +02:00
|
|
|
ln -sf "$PWD"/config/rofi ~/.config/rofi/config
|
2018-07-20 22:12:59 +02:00
|
|
|
ln -sf "$PWD"/config/.gitconfig ~/.gitconfig
|
2018-08-13 10:38:18 +02:00
|
|
|
ln -sf "$PWD"/config/.npmrc ~/.npmrc
|
2018-10-22 10:49:21 +02:00
|
|
|
ln -sf "$PWD"/config/user-dirs.dirs ~/.config/user-dirs.dirs
|
2018-04-30 21:35:17 +02:00
|
|
|
|
2018-11-27 13:46:34 +01:00
|
|
|
# link system files / directories
|
2018-04-23 10:06:10 +02:00
|
|
|
sudo ln -sf "$PWD"/config/package-managers/pacman.conf /etc/pacman.conf
|
|
|
|
sudo ln -sf "$PWD"/config/package-managers/makepkg.conf /etc/makepkg.conf
|
|
|
|
sudo ln -sf "$PWD"/config/ntp.conf /etc/ntp.conf
|
2018-11-27 13:46:34 +01:00
|
|
|
sudo ln -sf "$PWD"/bash/Completion /etc/bash_completion.d
|
2018-02-13 20:38:48 +01:00
|
|
|
|
2018-07-20 22:12:59 +02:00
|
|
|
# create empty .custom alias file
|
|
|
|
echo "" > ~/.custom
|
2019-06-19 08:27:00 +02:00
|
|
|
echo "" > ~/.variables
|
2018-08-15 18:42:09 +02:00
|
|
|
|
|
|
|
# system fixes
|
|
|
|
echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system
|
2018-09-02 11:31:56 +02:00
|
|
|
mkdir -p ~/Pictures/Screenshots
|
2018-05-04 19:28:02 +02:00
|
|
|
}
|
|
|
|
|
2017-12-06 18:30:31 +01:00
|
|
|
# Installs the dependencies on Arch Linux
|
|
|
|
function install_dependencies {
|
2018-05-04 19:28:02 +02:00
|
|
|
fileToList dependencies/pacman.txt | xargs sudo pacman --noconfirm --force -S
|
2018-04-30 21:35:17 +02:00
|
|
|
|
2018-04-20 11:00:27 +02:00
|
|
|
install_trizen
|
2018-04-30 21:35:17 +02:00
|
|
|
fileToList dependencies/aur.txt | xargs trizen --force -S --noconfirm
|
|
|
|
|
2018-05-04 19:28:02 +02:00
|
|
|
fileToList dependencies/pip.txt | xargs sudo pip install
|
2018-11-27 13:50:22 +01:00
|
|
|
|
|
|
|
fileToList dependencies/npm.txt | xargs sudo npm install -g
|
2017-12-06 18:30:31 +01:00
|
|
|
}
|
|
|
|
|
2018-04-30 21:35:17 +02:00
|
|
|
|
|
|
|
# =======================================
|
|
|
|
# User output functions
|
|
|
|
# =======================================
|
|
|
|
|
2017-12-06 18:30:31 +01:00
|
|
|
# list the dependencies file
|
|
|
|
function list_dependencies {
|
|
|
|
echo ""
|
|
|
|
echo "=========================="
|
|
|
|
echo ""
|
2017-12-06 19:10:41 +01:00
|
|
|
cat dependencies/pacman.txt
|
|
|
|
cat dependencies/aur.txt
|
2018-04-08 16:31:05 +02:00
|
|
|
cat dependencies/pip.txt
|
2018-11-27 13:50:22 +01:00
|
|
|
cat dependencies/npm.txt
|
2017-12-06 18:30:31 +01:00
|
|
|
echo ""
|
2018-04-30 21:35:17 +02:00
|
|
|
echo "=========================="
|
2017-12-06 18:30:31 +01:00
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
|
|
|
|
# Run the intro bit
|
|
|
|
function intro {
|
2018-04-30 21:35:17 +02:00
|
|
|
echo "___ ___ _ _ _ _ _ "
|
|
|
|
echo "| \/ | | | (_) | | | | ( )"
|
|
|
|
echo "| . . | __ _ ___| |_ ___ _ __ _ __ ___ _ _ __ __| |___| |__ |/ "
|
|
|
|
echo "| |\/| |/ _\` / __| __/ _ \ '__| '_ \` _ \| | '_ \ / _' |_ / '_ \ "
|
|
|
|
echo "| | | | (_| \__ \ || __/ | | | | | | | | | | | (_| |/ /| | | | "
|
|
|
|
echo "\_| |_/\__,_|___/\__\___|_| |_| |_| |_|_|_| |_|\__,_/___|_| |_| "
|
|
|
|
echo " "
|
|
|
|
echo " "
|
|
|
|
echo " __ _ _ "
|
|
|
|
echo " / _(_) ___ (_) "
|
|
|
|
echo " ___ ___ _ __ | |_ _ __ _ ( _ ) _ __ _ ___ ___ "
|
|
|
|
echo " / __/ _ \| '_ \| _| |/ _\` | / _ \/\ | '__| |/ __/ _ \ "
|
|
|
|
echo "| (_| (_) | | | | | | | (_| | | (_> < | | | | (_| __/ "
|
|
|
|
echo " \___\___/|_| |_|_| |_|\__, | \___/\/ |_| |_|\___\___| "
|
|
|
|
echo " __/ | "
|
|
|
|
echo " |___/ "
|
|
|
|
echo ""
|
2017-12-06 18:30:31 +01:00
|
|
|
}
|
|
|
|
|
2018-07-20 22:12:59 +02:00
|
|
|
function computer {
|
|
|
|
echo " /\ "
|
|
|
|
echo " / \ "
|
|
|
|
echo " /_ %%==O=% _____________ "
|
|
|
|
echo " % - -% | '\\\\\\\\\\"
|
|
|
|
echo " _____c% > __ | ' ____|_ "
|
|
|
|
echo " (_|. . % \` % .' | + '||:::::: "
|
|
|
|
echo " ||. ___)%%%%_.' | '||_____| "
|
|
|
|
echo " ||.( \ ~ / ,)' \'_______|_____| "
|
|
|
|
echo " || /| \'/ |\ ___/____|___\___ "
|
|
|
|
echo " _,,,;!___*_____\_| _ ' <<<:| "
|
|
|
|
echo " / /| |_________'___o_o| "
|
|
|
|
echo " /_____/ / "
|
|
|
|
echo " |:____|/ \"Boy, I LOVE this stuff\". "
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
|
2017-12-06 18:30:31 +01:00
|
|
|
|
|
|
|
# =======================================
|
|
|
|
# Main loop
|
|
|
|
# =======================================
|
|
|
|
|
2018-07-20 22:12:59 +02:00
|
|
|
clear
|
2017-12-06 18:30:31 +01:00
|
|
|
# Run the intro function
|
|
|
|
intro
|
|
|
|
|
2018-05-04 19:28:02 +02:00
|
|
|
ask "Do you want to continue installing my config and rice?" Y &&
|
2017-12-06 19:10:41 +01:00
|
|
|
|
2017-12-06 18:30:31 +01:00
|
|
|
# Ask for dependency installation
|
|
|
|
list_dependencies
|
2018-05-04 19:28:02 +02:00
|
|
|
if ask "Do you want to install the list of applications above? (might prompt for password)" Y; then
|
|
|
|
install_dependencies
|
|
|
|
fi
|
2017-12-06 19:10:41 +01:00
|
|
|
|
|
|
|
# Ask for config installation
|
2018-05-04 19:28:02 +02:00
|
|
|
if ask "Do you want to install the config files?" Y; then
|
|
|
|
install_config
|
|
|
|
fi
|
2017-12-06 18:30:31 +01:00
|
|
|
|
2018-05-04 19:28:02 +02:00
|
|
|
# Ask for font installation
|
|
|
|
if ask "Do you want to install the fonts?" Y; then
|
|
|
|
install_fonts
|
|
|
|
fi
|
2018-07-20 22:12:59 +02:00
|
|
|
|
2018-04-08 16:31:05 +02:00
|
|
|
# ask to enable gdm
|
2018-05-04 19:28:02 +02:00
|
|
|
if ask "Do you want to enable GDM?" Y; then
|
|
|
|
sudo systemctl enable gdm.service
|
|
|
|
fi
|
2018-04-08 16:31:05 +02:00
|
|
|
|
2018-07-20 22:12:59 +02:00
|
|
|
clear
|
|
|
|
computer
|
|
|
|
# ask for pc specific install
|
|
|
|
prompt=`echo $'\n> ' Please select a specific computer to install or q to finish the install`
|
|
|
|
|
|
|
|
PS3="$prompt: "
|
|
|
|
select opt in "$PWD/computers"/*; do
|
|
|
|
if (( REPLY == "q" )) ; then
|
|
|
|
break
|
|
|
|
|
|
|
|
elif (( REPLY > 0 )) ; then
|
|
|
|
bash "$opt/install.sh"
|
|
|
|
break
|
|
|
|
else
|
|
|
|
echo "Invalid option. Try another one."
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
clear
|
|
|
|
|
|
|
|
echo "Enjoy using my rice! Do not forget to select i3 in GDM :)"
|