configs/arch-config/scripts/arch-config.sh

480 lines
12 KiB
Bash
Raw Normal View History

2021-06-02 14:17:20 +02:00
#!/usr/bin/env bash
2020-10-12 07:15:20 +02:00
set -euo pipefail
# check if user is root
if [ "$EUID" -ne 0 ]; then
2021-06-06 12:12:19 +02:00
sudo -v
fi
cat <<EOF
2021-06-02 14:17:20 +02:00
############################################################
###################### INSTALL CONFIG ######################
############################################################
EOF
2020-04-10 13:12:35 +02:00
2021-03-08 08:30:26 +01:00
# function to select theme
function func_seltheme {
cmd=(dialog --separate-output --checklist "Select theme (Only select one)" 22 76 16)
options=(1 "Nyarch" off # any option can be set to default to "on"
2 "Spaceengine Pink" off)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear
for choice in $choices
do
case $choice in
1)
2021-03-08 13:13:19 +01:00
echo "nyarch" > "$HOME/.seltheme"
2021-03-08 08:30:26 +01:00
;;
2)
2021-03-08 13:13:19 +01:00
echo "space-pink" > "$HOME/.seltheme"
2021-03-08 08:30:26 +01:00
;;
esac
done
}
2021-06-02 14:36:43 +02:00
echo
cat <<EOF
2021-06-02 14:17:20 +02:00
########################################
################ Setup ################
########################################
EOF
2021-06-02 14:17:20 +02:00
# change to home
2020-10-12 07:18:24 +02:00
cd "$HOME"
2020-03-12 11:44:07 +01:00
2021-06-02 14:17:20 +02:00
# remove old installs
2020-04-18 23:36:24 +02:00
rm -rf ~/config
2020-03-12 11:44:07 +01:00
echo "Checking config file"
2020-03-12 11:44:07 +01:00
#clone this repo
git clone https://gitlab.com/RealStickman-arch/config.git &>/dev/null
2020-03-12 11:44:07 +01:00
# make sure to use master branch
cd config
git checkout master &>/dev/null
cd ..
# check if the install scripts are the same
2021-03-08 09:16:44 +01:00
# NOTE Arguments get passed automatically now
if ! cmp --silent "$HOME/scripts/arch-config.sh" "$HOME/config/scripts/arch-config.sh" ; then
2020-11-10 08:31:35 +01:00
echo Removed old config file and launched new one.
2021-03-08 13:09:12 +01:00
rm "$HOME/scripts/arch-config.sh" && cp "$HOME/config/scripts/arch-config.sh" "$HOME/scripts/" && bash ~/scripts/arch-config.sh "$@"
fi
2021-03-08 08:30:26 +01:00
# if no seltheme file exists, ask to select a theme
if [[ ! -f "$HOME/.seltheme" ]]; then
func_seltheme
fi
2021-06-02 14:17:20 +02:00
####################
#### Arguments ####
####################
2021-03-08 08:34:35 +01:00
# handle arguments
if [[ "$#" -eq 1 ]]; then
2021-03-08 08:34:35 +01:00
# -t/--theme to change theme
if [[ "$1" == "-t" || "$1" == "--theme" ]]; then
func_seltheme
2021-03-08 09:10:05 +01:00
elif [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo "-h, --help Show help menu"
echo "-t, --theme Show theme selection screen"
2021-03-08 08:34:35 +01:00
fi
2021-03-08 09:11:16 +01:00
elif [[ "$#" -gt 1 ]]; then
echo "Too many arguments"
exit 1
2021-03-08 08:34:35 +01:00
fi
2021-06-02 14:36:43 +02:00
echo
cat <<EOF
2021-06-02 14:17:20 +02:00
########################################
################ Backup ################
########################################
EOF
2021-06-02 14:17:20 +02:00
####################
##### Cleaning #####
####################
#delete previous backups
echo Removing old backup
2021-03-09 11:35:55 +01:00
if [[ -d ~/old_dat ]]; then
rm -rf ~/old_dat
fi
2020-09-09 20:56:53 +02:00
2021-06-02 14:17:20 +02:00
####################
##### Creating #####
####################
2020-11-23 13:30:16 +01:00
# make new backup
echo Creating backup
mkdir -p ~/old_dat/.config
mkdir -p ~/old_dat/.doom.d
mkdir -p ~/old_dat/.easystroke
mkdir -p ~/old_dat/.mozilla
mkdir -p ~/old_dat/scripts
mkdir -p ~/old_dat/.elvish
2020-09-09 20:56:53 +02:00
2020-11-10 07:58:07 +01:00
# make subdirectories
mkdir -p ~/old_dat/.local/share
2020-11-10 07:58:07 +01:00
#config folders
2021-03-09 11:35:55 +01:00
if [[ -d ~/.config/MangoHud ]]; then
rsync -ah ~/.config/MangoHud ~/old_dat/.config/
2021-03-09 11:35:55 +01:00
fi
if [[ -d ~/.config/fish ]]; then
rsync -ah ~/.config/fish ~/old_dat/.config/
2021-03-09 11:35:55 +01:00
fi
if [[ -d ~/.config/gtk-3.0 ]]; then
rsync -ah ~/.config/gtk-3.0 ~/old_dat/.config/
2021-03-09 11:35:55 +01:00
fi
if [[ -d ~/.config/i3 ]]; then
rsync -ah ~/.config/i3 ~/old_dat/.config/
2021-03-09 11:35:55 +01:00
fi
if [[ -d ~/.config/neofetch ]]; then
rsync -ah ~/.config/neofetch ~/old_dat/.config/
2021-03-09 11:35:55 +01:00
fi
if [[ -d ~/.config/openbox ]]; then
rsync -ah ~/.config/openbox ~/old_dat/.config/
2021-03-09 11:35:55 +01:00
fi
if [[ -d ~/.config/polybar ]]; then
rsync -ah ~/.config/polybar ~/old_dat/.config/
2021-03-09 11:35:55 +01:00
fi
if [[ -d ~/.config/termite ]]; then
rsync -ah ~/.config/termite ~/old_dat/.config/
2021-03-09 11:35:55 +01:00
fi
if [[ -d ~/.config/variety ]]; then
rsync -ah ~/.config/variety ~/old_dat/.config/
2021-03-09 11:35:55 +01:00
fi
# doom.d folder
2021-03-09 11:35:55 +01:00
if [[ -d ~/.doom.d ]]; then
rsync -ah ~/.doom.d ~/old_dat/
2021-03-09 11:35:55 +01:00
fi
# easystroke
2021-03-09 11:35:55 +01:00
if [[ -d ~/.easystroke ]]; then
rsync -ah ~/.easystroke ~/old_dat/
2021-03-09 11:35:55 +01:00
fi
2021-05-06 13:35:12 +02:00
# elvish
2021-05-06 13:35:52 +02:00
if [[ -d ~/.elvish ]]; then
rsync -ah ~/.elvish ~/old_dat/
2021-05-06 13:35:12 +02:00
fi
# local folder
2021-03-09 11:35:55 +01:00
if [[ -d ~/.local/share/applications ]]; then
rsync -ah ~/.local/share/applications/ ~/old_dat/.local/share/
2021-03-09 11:35:55 +01:00
fi
# mozilla
2021-03-09 11:35:55 +01:00
if [[ -d ~/.mozilla ]]; then
rsync -ah ~/.mozilla ~/old_dat/
2021-03-09 11:35:55 +01:00
fi
# scripts
2021-03-09 11:35:55 +01:00
if [[ -d ~/scripts ]]; then
rsync -ah ~/scripts ~/old_dat/
2021-03-09 11:35:55 +01:00
fi
2021-02-15 11:57:49 +01:00
# remove old templates
2021-03-09 11:35:55 +01:00
if [[ -d ~/.config/Vorlagen ]]; then
rm -r ~/.config/Vorlagen
fi
2021-02-15 11:57:49 +01:00
2021-06-08 12:47:50 +02:00
# remove old scripts in path
if [[ -d ~/scripts/in_path ]]; then
rm -r ~/scripts/in_path
fi
2021-06-02 14:36:43 +02:00
echo
cat <<EOF
2021-06-02 14:17:20 +02:00
########################################
########### Copy New Config ###########
########################################
EOF
2021-06-02 14:17:20 +02:00
2020-05-18 08:09:49 +02:00
#copy folders
cp -r ~/config/.config/ ~/
cp -r ~/config/.local/ ~/
#cp -r ~/config/Dokumente ~/
cp -r ~/config/.mozilla ~/
cp -r ~/config/.easystroke ~/
cp -r ~/config/.elvish ~/
cp -r ~/config/.doom.d ~/
2020-05-18 08:09:49 +02:00
echo Copied folders
2020-07-30 11:46:34 +02:00
2020-09-09 20:56:53 +02:00
#copy single files
cp -r ~/config/.bashrc ~/
cp -r ~/config/.face ~/
cp -r ~/config/.gtkrc-2.0 ~/
cp -r ~/config/.gitconfig ~/
cp -r ~/config/.tmux.conf ~/
cp -r ~/config/.xinitrc ~/
2020-05-18 08:09:49 +02:00
echo Copied files
2020-07-30 11:46:34 +02:00
2021-01-09 10:02:55 +01:00
# make .xinitrc executable
chmod +x ~/.xinitrc
2020-09-09 20:56:53 +02:00
#copy scripts
2020-07-30 12:58:38 +02:00
cp -r ~/config/scripts/ ~/
2020-09-09 20:56:53 +02:00
2020-11-23 13:30:16 +01:00
# copy cache
cp -r ~/config/.cache ~/
2020-04-10 13:03:58 +02:00
#copy stuff to /etc
2021-01-04 17:24:00 +01:00
sudo cp -r ~/config/etc /
#sudo rsync --exclude=default/grub ~/config/etc /etc/
2021-01-04 17:08:27 +01:00
2021-01-04 17:24:00 +01:00
#read -r -p "Do you want to overwrite the grub config? [y/N] " response
#if [[ "$response" =~ ^([yY][eE][sS][jJ]|[yY])$ ]]
#then
2021-01-04 17:08:27 +01:00
# copy config
2021-01-04 17:24:00 +01:00
# sudo cp ~/config/etc/default/grub /etc/default/
2021-01-04 17:08:27 +01:00
# update grub
2021-01-04 17:24:00 +01:00
# sudo grub-mkconfig -o /boot/grub/grub.cfg
#fi
2020-09-09 20:56:53 +02:00
# NOTE Distro specific stuff
distro=$(cat /etc/*-release | grep "^ID=")
if [ "$distro" == "ID=arcolinux" ]; then
sudo mv /etc/arco-pacman.conf /etc/pacman.conf
fi
if [ "$distro" == "ID=arch" ]; then
sudo mv /etc/arch-pacman.conf /etc/pacman.conf
fi
2021-06-02 14:17:20 +02:00
# NOTE only for webkit2gtk version of lightdm
#copy old lightdm themes (and maybe other stuff, idk)
2021-06-02 14:17:20 +02:00
#sudo cp -r ~/config/var /
2020-03-12 11:44:07 +01:00
#copy usr stuff
sudo cp -r ~/config/usr /
2020-10-27 16:32:26 +01:00
# copy xresources
2021-02-28 12:14:30 +01:00
cp ~/config/.Xresources ~/
2020-10-27 16:32:26 +01:00
2021-06-02 14:17:20 +02:00
####################
###### Theme ######
####################
2021-03-08 09:17:40 +01:00
# remove old themes folder
rm -rf ./themes
2021-03-08 08:13:47 +01:00
2021-03-08 08:12:19 +01:00
# install theme selected in themes file
git clone https://gitlab.com/RealStickman-arch/themes.git &>/dev/null
2021-03-08 08:12:19 +01:00
seltheme="$(cat "$HOME/.seltheme")"
if [[ "$seltheme" == "nyarch" ]]; then
2021-03-09 17:32:32 +01:00
#cp -r "./themes/nyarch/i3" "$HOME/.config/"
cat "./themes/nyarch/i3/color" >> "$HOME/.config/i3/config"
2021-03-08 08:23:56 +01:00
cp -r "./themes/nyarch/polybar" "$HOME/.config/"
2021-03-08 20:45:16 +01:00
cp -r "./themes/nyarch/neofetch/lowpoly_flamegirl_blue.txt" "$HOME/.config/neofetch/lowpoly_flamegirl.txt"
2021-03-08 13:06:51 +01:00
cp "./themes/.fehbg-nyarch" "$HOME/.fehbg"
2021-03-11 15:59:35 +01:00
#sed -i 's/^NAME=".*"/NAME="Rawrch Linyux"/' /etc/os-release
2021-03-08 08:12:19 +01:00
elif [[ "$seltheme" == "space-pink" ]]; then
2021-03-09 17:32:32 +01:00
#cp -r "./themes/space-pink/i3" "$HOME/.config/"
cat "./themes/space-pink/i3/color" >> "$HOME/.config/i3/config"
2021-03-08 08:23:56 +01:00
cp -r "./themes/space-pink/polybar" "$HOME/.config/"
2021-03-08 20:45:16 +01:00
cp -r "./themes/space-pink/neofetch/lowpoly_flamegirl_orange.txt" "$HOME/.config/neofetch/lowpoly_flamegirl.txt"
2021-03-08 13:06:51 +01:00
cp "./themes/.fehbg-space-pink" "$HOME/.fehbg"
2021-03-08 08:12:19 +01:00
fi
rm -rf ./themes
# make fehbg executable
chmod +x ~/.fehbg
2021-06-02 14:17:20 +02:00
####################
##### Bash Cat #####
####################
2021-01-09 09:36:00 +01:00
# download cat as cat
2021-05-06 19:13:22 +02:00
echo "Installing bash cat"
git clone https://github.com/RealStickman/bash-cat-with-cat.git &>/dev/null
2021-01-09 09:37:41 +01:00
cp ./bash-cat-with-cat/cat.sh "$HOME/scripts/pieces/cat.sh"
2021-01-09 09:36:00 +01:00
rm -rf ./bash-cat-with-cat
2021-06-02 14:17:20 +02:00
####################
##### PSIPCalc #####
####################
2021-05-25 11:26:58 +02:00
# download ip-calculator with powershell
echo "Installing powershell ip calculator"
git clone https://github.com/RealStickman/PSipcalc &>/dev/null
2021-05-25 11:27:53 +02:00
cp ./PSipcalc/PSipcalc.ps1 "$HOME/scripts/in_path/sc-psipcalc"
2021-05-25 11:26:58 +02:00
rm -rf ./PSipcalc
2021-06-02 14:17:20 +02:00
####################
####### Gimp #######
####################
2020-04-15 11:18:39 +02:00
#gimp plugins
#mkdir ~/.config/GIMP/ || echo Not creating directory
#mkdir ~/.config/GIMP/2.10/ || echo Not creating directory
mkdir -p ~/.config/GIMP/2.10/plug-ins/ || echo Not creating directory
2020-09-09 20:56:53 +02:00
rsync -ah ~/config/gimp-plugins/* ~/.config/GIMP/2.10/plug-ins/
2020-07-30 11:46:34 +02:00
2021-06-02 14:36:43 +02:00
echo
cat <<EOF
2021-06-02 14:17:20 +02:00
########################################
############### Services ###############
########################################
EOF
2021-06-02 14:17:20 +02:00
# set systemd services for vmware (only if installed)
2021-03-20 14:01:39 +01:00
if [[ $(pacman -Q | grep vmware-workstation) ]]; then
sudo systemctl enable --now vmware-networks-server.service
2021-06-02 14:17:20 +02:00
fi
# enable fstrim timer
sudo systemctl enable fstrim.timer
# enable btrfs maintenance timers
if [[ $(pacman -Q | grep btrfsmaintenance) ]]; then
sudo systemctl restart btrfsmaintenance-refresh.service
sudo systemctl enable btrfs-balance.timer
sudo systemctl enable btrfs-scrub.timer
fi
2021-06-02 14:36:43 +02:00
echo
cat <<EOF
2021-06-02 14:17:20 +02:00
########################################
################ Groups ################
########################################
EOF
2021-06-02 14:17:20 +02:00
# set systemd and group for vmware (only if installed)
if [[ $(pacman -Q | grep vmware-workstation) ]]; then
2021-06-01 17:34:13 +02:00
echo "Setting up group for vmware"
sudo groupadd -f vmware
sudo gpasswd -a "$USER" vmware 1>/dev/null
2021-06-02 12:05:07 +02:00
sudo chgrp vmware /dev/vmnet*
2021-06-01 17:34:13 +02:00
sudo chmod g+rw /dev/vmnet*
2021-03-20 14:01:39 +01:00
fi
2021-07-19 20:36:48 +02:00
# set group for libvirt
if [[ $(pacman -Q | grep libvirt) ]]; then
echo "Setting group for libvirt"
sudo gpasswd -a "$USER" libvirt 1>/dev/null
fi
2021-06-02 14:17:20 +02:00
# set group for wireshark (only if installed)
if [[ $(pacman -Q | grep wireshark-qt) ]]; then
echo "Setting up group for wireshark"
sudo groupadd -f wireshark
sudo gpasswd -a "$USER" wireshark 1>/dev/null
fi
# add group for corectrl
2021-06-02 14:17:20 +02:00
if [[ $(pacman -Q | grep corectrl) ]]; then
echo "Setting up group for corectrl"
sudo groupadd -f corectrl
sudo gpasswd -a "$USER" corectrl 1>/dev/null
fi
# group for controlling backlight
echo "Setting group for backlight"
sudo groupadd -f video
sudo gpasswd -a "$USER" video 1>/dev/null
2021-06-02 14:17:20 +02:00
# group for monitoring wireguard
echo "Setting group for wireguard"
sudo groupadd -f wireguard
sudo gpasswd -a "$USER" wireguard 1>/dev/null
2021-06-02 14:36:43 +02:00
echo
cat <<EOF
2021-06-02 14:17:20 +02:00
########################################
############# Misc Config #############
########################################
EOF
# set permissions for sudoers.d to root only
sudo chown root:root -R /etc/sudoers.d/
sudo chmod 600 -R /etc/sudoers.d/
# unzip gimp plugins
2020-04-15 11:27:07 +02:00
echo Unzipping gimp plugins
2020-10-12 20:09:57 +02:00
unzip -o ~/.config/GIMP/2.10/plug-ins/export_layers-3.3.1.zip -d ~/.config/GIMP/2.10/plug-ins/ > /dev/null
rm ~/.config/GIMP/2.10/plug-ins/export_layers-3.3.1.zip > /dev/null
2020-04-15 11:18:39 +02:00
2021-03-08 15:14:22 +01:00
# xfce settings
# disable screensaver & locker
/usr/bin/xfconf-query -c xfce4-session -n -t bool -p /startup/screensaver/enabled -s false
2020-03-12 11:44:07 +01:00
#make bash scripts executable
chmod +x -R ~/.config/polybar/
chmod +x -R ~/.config/i3/scripts
chmod +x -R ~/scripts
# make applications executable
chmod +x -R ~/.local/share/applications
2020-03-12 11:44:07 +01:00
2021-04-07 08:35:40 +02:00
# set settings for nemo
bash ~/config/scripts/nemo-config.sh
2020-03-12 11:44:07 +01:00
#remove downloaded folder
2020-04-18 23:36:24 +02:00
rm -rf ~/config
2020-03-12 11:44:07 +01:00
2021-06-02 14:36:43 +02:00
echo
cat <<EOF
2021-06-02 14:17:20 +02:00
########################################
############## Reloading ##############
########################################
EOF
2021-06-02 14:17:20 +02:00
2020-11-09 20:12:32 +01:00
# reload applications
update-desktop-database ~/.local/share/applications/
2020-09-09 20:56:53 +02:00
#sync doom-emacs
~/.emacs.d/bin/doom sync
# dunst
pkill dunst && dunst &
2021-03-27 12:10:05 +01:00
# reload systemd user scripts
systemctl --user daemon-reload
2020-10-27 16:34:16 +01:00
# reload .Xresources
2021-01-29 20:03:02 +01:00
if [[ -f "$HOME/.Xresources" ]]; then
xrdb ~/.Xresources
fi
2020-10-27 16:34:16 +01:00
2020-12-07 10:39:46 +01:00
# execute feh
"$HOME/.fehbg"
2021-06-02 14:17:20 +02:00
# NOTE working now
2021-05-06 13:55:28 +02:00
# if [[ "$(ps aux | grep "FIXME")" ]]; then ...
# ps aux | grep "\si3\s" breaks if i3 hasn't been restarted yet
# ps aux | grep "\si3" works for both, not certain if other stuff could be detected as well
2021-05-06 13:55:28 +02:00
# ps aux | grep "\si3\$" breaks if i3 has been restarted already in this session
2021-05-06 19:09:38 +02:00
if ps aux | grep -E "\si3(\s|$)" &>/dev/null; then
2021-05-06 19:10:38 +02:00
i3-msg restart 1>/dev/null
fi
2020-03-12 11:44:07 +01:00
2021-06-02 14:36:43 +02:00
echo
cat <<EOF
2021-06-02 14:17:20 +02:00
########################################
############### Finished ###############
########################################
EOF
2021-06-02 14:17:20 +02:00
2020-03-12 11:44:07 +01:00
#output
2021-04-22 10:43:35 +02:00
echo -e "\033[38;2;20;200;20mFinished updating everything!\033[0m"
2020-03-12 11:44:07 +01:00
echo Launching new shell!
2021-03-31 15:34:32 +02:00
# remind user of cgroupsv2 if using podman
if [[ $(pacman -Q | grep podman) ]]; then
2021-04-22 10:43:35 +02:00
echo -e "\033[38;2;200;20;20mRemember to set \"systemd.unified_cgroup_hierarchy=1\" in the kernel!!\033[0m"
2021-03-31 15:34:32 +02:00
fi
# reminder for enable additional gpu features for corectrl with amd gpus
if [[ $(pacman -Q | grep podman) ]]; then
echo -e "\033[38;2;200;20;20mRemember to set \"amdgpu.ppfeaturemask=0xffffffff\" in the kernel!!\033[0m"
fi
# reload user default shell
2021-05-06 13:52:26 +02:00
exec "$(getent passwd $LOGNAME | cut -d: -f7)"
2020-11-17 21:22:06 +01:00
2021-06-02 14:17:20 +02:00
# exit successfully
$(exit 0); echo "$?"