Last active
November 2, 2020 21:29
-
-
Save dh-nunes/b7a6aa8544d3c0d48af8a3f653989426 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
## TODO: | |
# browser settings and such | |
# htop-vim-temperature | |
# proper vim setup | |
#### CONSTANTS #### | |
EMAIL="[email protected]" | |
SECTION() { | |
padding=2 | |
str_len=${#1} | |
first_len=$(((str_len+COLUMNS)/2-padding-str_len)) | |
if [[ $((2*first_len+2*padding+str_len)) < $COLUMNS ]]; then | |
second_len=$((first_len+1)) | |
else | |
second_len=$first_len | |
fi | |
echo | |
printf '\033[1;36m%*s\033[0m\n' "$COLUMNS" '' | tr ' ' '=' | |
printf '\033[1;36m%*s\033[0m' "$first_len" '' | tr ' ' '=' | |
printf '%*s' "$padding" '' | |
printf '\033[1;35m%s\033[0m' "$1" | |
printf '%*s' "$padding" '' | |
printf '\033[1;36m%*s\033[0m\n' "$second_len" '' | tr ' ' '=' | |
printf '\033[1;36m%*s\033[0m\n' "$COLUMNS" '' | tr ' ' '=' | |
echo | |
} | |
#### MAKE SUDO GREAT AGAIN #### | |
sudo -v | |
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & | |
#### Misc Changes #### | |
sudo sed -i 's/^#Color/Color/g' /etc/pacman.conf | |
mkdir -p "$HOME"/.cache/makepkg/packages | |
sudo sed -i "s,^#\?PKGDEST=.*,PKGDEST=$HOME/.cache/makepkg/packages,g" /etc/makepkg.conf | |
mkdir -p "$HOME"/.cache/makepkg/sources | |
sudo sed -i "s,^#\?SRCDEST=.*,SRCDEST=$HOME/.cache/makepkg/sources,g" /etc/makepkg.conf | |
sudo sed -i 's/^#\?MAKEFLAGS=.*/MAKEFLAGS="-j'$(($(grep -c ^processor /proc/cpuinfo)+1))'"/g' /etc/makepkg.conf | |
#### Install Apps #### | |
SECTION "Setup Apps" | |
install=" | |
bash-completion | |
breeze-obsidian-cursor-theme | |
evince | |
firefox | |
google-chrome | |
grub-silent | |
gtk-theme-material-black | |
gvim | |
megacmd | |
mousepad | |
neofetch | |
pacgraph | |
pam-gnupg-git | |
pass | |
plymouth | |
plymouth-theme-dark-arch | |
python | |
python2 | |
qbittorrent | |
qtpass | |
spotify | |
steam | |
syncthing | |
syncthingtray | |
tor-browser | |
tree | |
viewnior | |
vlc | |
windscribe-cli | |
xfce4 | |
xfce4-goodies | |
lightdm | |
lightdm-gtk-greeter | |
lightdm-gtk-greeter-settings | |
light-locker | |
noto-fonts | |
noto-fonts-cjk | |
ttf-inconsolata | |
firefox-extension-https-everywhere | |
firefox-ublock-origin | |
firefox-extension-privacybadger | |
" | |
yay --save --sudoloop --answerclean No --nodiffmenu --noeditmenu --cleanafter --pgpfetch --norebuild | |
yay -Rns --noconfirm $(yay -Qqtd) || true | |
yay -Syu --noconfirm --useask --needed $(echo "$install" | xargs) | |
#### Setup Dotfiles #### | |
SECTION "Setup Dotfiles" | |
dotfiles_dir="$HOME"/.dotfiles | |
rm -rf "$dotfiles_dir" | |
git clone "https://github.com/GandaG/dotfiles.git" "$dotfiles_dir" | |
sh "$dotfiles_dir"/install.sh | |
source "$HOME"/.profile | |
# Older apps compat | |
mkdir -p "$HOME"/.share/applications | |
ln -sf "$HOME"/.config/mimeapps.list "$HOME"/.share/applications/mimeapps.list | |
# Move gnupg folder | |
orig_gpg="$HOME"/.gnupg | |
if [ -d "$orig_gpg" ]; then | |
echo "Moving original gnupg files to new location..." | |
mv -f "$orig_gpg"/* "$GNUPGHOME" | |
rm -rf "$orig_gpg" | |
fi | |
sudo chown -R "$USER" "$GNUPGHOME" | |
chmod 700 "$GNUPGHOME" | |
gpgconf --kill gpg-agent | |
# xfce needs to be restarted | |
pkill xfconfd | |
xfce4-panel -r | |
#### Autostart Apps #### | |
SECTION "Setup Autostart" | |
yes | cp --remove-destination /usr/share/applications/syncthingtray.desktop "$HOME"/.config/autostart | |
systemctl --user enable syncthing.service | |
#### File Sharing (Syncthing) #### | |
SECTION "Setup Syncthing" | |
syncthing &>/dev/null & | |
echo " Syncthing instructions:" | |
echo " - Add another device;" | |
echo " - Mark that device as 'introducer';" | |
echo " - Restart syncthing;" | |
echo " - Wait for sync to finish." | |
sleep 5 | |
firefox localhost:8384 & | |
read -n 1 -serp "Press ENTER when finished configuring Syncthing..." | |
syncthing_apikey=$(grep -oP '\s+<apikey>\K.+(?=</apikey>)' "$HOME"/.config/syncthing/config.xml) | |
sed -i --follow-symlinks "s/connections\\\\1\\\\apiKey=.*/connections\\\\1\\\\apiKey=$syncthing_apikey/g" "$HOME"/.config/syncthingtray.ini | |
#### Setup Security (gnupg, pam, pass and gnome-keyring) #### | |
SECTION "Setup Security" | |
gpg --batch --import Sync/keys.asc | |
gpg -K --with-keygrip | grep -i "Keygrip =" | awk '{ print $NF }' > "$HOME"/.pam-gnupg | |
pam_file="/etc/pam.d/lightdm" | |
pam_gnupg=" | |
auth optional pam_gnupg.so | |
session optional pam_gnupg.so | |
" | |
sudo sed -i '/^[[:space:]]*$/d' "$pam_file" | |
sudo sed -i '/pam_gnupg.so/d' "$pam_file" | |
sudo echo "$pam_gnupg" | sudo tee -a "$pam_file" > /dev/null | |
#### File Sharing (Mega) #### | |
SECTION "Setup Mega" | |
mega-login "$EMAIL" "$(pass show mega/$EMAIL | head -n 1)" || true | |
mkdir -p ~/Mega | |
mega-sync ~/Mega / || true | |
#### Boot Up (GRUB, Plymouth) #### | |
SECTION "Boot Up" | |
VGA=$(lspci -v | grep -A10 VGA | grep driver | awk '{ print $NF }') | |
sudo sed -i "s/^MODULES=.*/MODULES=($VGA)/g" /etc/mkinitcpio.conf | |
sudo sed -i 's/\(HOOKS=["(]base udev\)\( plymouth\)\?/\1 plymouth/g' /etc/mkinitcpio.conf | |
sudo systemctl disable lightdm.service && sudo systemctl enable lightdm-plymouth.service | |
sudo plymouth-set-default-theme -R dark-arch | |
echo "Replace '/boot/efi' with efi partition mount point - it's generally /boot/efi:" | |
echo " sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB" | |
echo " sudo grub-mkconfig -o /boot/grub/grub.cfg" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment