-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_script.sh
More file actions
executable file
·189 lines (154 loc) · 5.53 KB
/
setup_script.sh
File metadata and controls
executable file
·189 lines (154 loc) · 5.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/bin/bash
set -euo pipefail
exec > >(tee output.log) 2>&1
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
log() {
echo -e "${GREEN}[INFO]: $1${NC}"
}
warn() {
echo -e "${YELLOW}[WARNING]: $1${NC}"
}
error() {
echo -e "${RED}[ERROR]: $1${NC}"
exit 1
}
# UNDER NO CIRCUMSTANCE PUT A TRAILING SLASH ON THIS ONE'S ARGUMENTS
install_dotfile() {
local src="$1"
local dest="$2"
[[ ! -d "$src" ]] && {
error "Source must be a directory."
}
[[ "$src" -ef "$dest" ]] && {
error "Source and destination must differ."
}
mkdir -p "$dest"
# current dots are backuped
for file in "$dest"; do
local backup="${file}.bak.$(date +%Y%m%d%H%M%S)"
log "Backing up $file -> $backup"
mv "$file" "$backup"
done
cp -vr "$src/." "$dest"
}
check_deps() {
local missing=()
for bin in "$@"; do
if ! command -v "$bin" >/dev/null 2>&1; then
missing+=("$bin")
fi
done
if [[ ${#missing[@]} -ne 0 ]]; then
warn "The following dependencies are missing:"
for item in "${missing[@]}"; do
warn " - $item"
done
error "Please install them and run the script again."
fi
}
install_apps() {
BASE_PKGS=(git rsync nano fastfetch greetd greetd-agreety fish fisher github-cli micro jdk-openjdk shfmt otf-monaspace ttf-material-symbols-variable noto-fonts noto-fonts-cjk noto-fonts-emoji noto-fonts-extra timidity++ mpd mpc rmpc mpdscribble brightnessctl flatpak tree beets bash-completion chromaprint ffmpeg gst-plugins-bad gst-plugins-good gst-plugins-ugly gst-libav gst-python imagemagick python-beautifulsoup4 python-discogs-client python-flask python-gobject python-langdetect python-librosa python-mpd2 python-pyacoustid python-pylast python-requests-oauthlib python-xdg python-titlecase)
DESKTOP_PKGS=(wayland niri xorg xwayland-satellite wl-clipboard fuzzel mako foot polkit-gnome xdg-desktop-portal xdg-desktop-portal-gnome gnome-keyring awww swayidle)
APP_PKGS=(zed nicotine+ nautilus vesktop gimp steam celluloid loupe fragments obsidian seahorse gaphor solanum)
PACMAN_PKGS=("${BASE_PKGS[@]}" "${DESKTOP_PKGS[@]}" "${APP_PKGS[@]}")
PARU_PKGS=(mpd-discord-rpc)
FLATPAK_PKGS=(io.github.arijanj.Mimic com.stremio.Stremio)
log "Installing packages..."
sudo pacman -Syu --needed "${PACMAN_PKGS[@]}"
paru -S --needed "${PARU_PKGS[@]}"
flatpak install -y flathub "${FLATPAK_PKGS[@]}"
fish -c 'fisher install pure-fish/pure' # i just use this package...
log "Finished installing apps."
}
configure_apps() {
# mpd doesn't create these itself
mkdir -p "$HOME/.local/share/mpd/playlists"
mkdir -p "$HOME/.local/state/mpd"
local SOURCES=(
"Pictures/Wallpapers"
".config/niri"
".config/rmpc"
".config/fastfetch"
".config/foot"
".config/fuzzel"
".config/mako"
".config/mpd"
".config/beets"
)
log "Setting up dotfiles..."
for src in "${SOURCES[@]}"; do
if [[ -d "giffoni/${src}" ]]; then
install_dotfile "giffoni/${src}" "$HOME/${src}"
else
warn "Source not found, skipping: $src"
fi
done
log "Setting up system config files..."
sudo cp -vr sys_configs/greetd_config.toml /etc/greetd/config.toml
log "Enabling services..."
local USER_SERVICES=(mpd mpd-discord-rpc mpdscribble)
local SYS_SERVICES=(greetd)
for service in "${USER_SERVICES[@]}"; do
systemctl --user enable "$service" || warn "Failed to enable $service."
done
for service in "${SYS_SERVICES[@]}"; do
sudo systemctl enable "$service" || warn "Failed to enable $service."
done
log "Adding ASCII greeting..."
sudo cp -vr sys_configs/login_greet.txt /etc/issue
log "Configuring git..."
git config --global color.ui auto
log "Changing user shell to fish..."
chsh -s /bin/fish
log "Finished configuring apps."
}
giffoni_related() {
while true; do
read -p "Are you Giffoni, and is your HD plugged in? (y/n): " yn
case $yn in
[Yy]*)
log "Configuring git for Giffoni..."
git config --global user.name "Giffoni Lopes"
git config --global user.email "kgiffoni_@tuta.com"
log "Getting external hard drive files..."
sudo mount /dev/sda1 /mnt
install_dotfile /mnt/.mpdscribble $HOME/.mpdscribble
rsync -av --delete --progress /mnt/Music/ $HOME/Music/
rsync -av --delete --progress /mnt/Code $HOME/
log "Unmounting external hard drive..."
sudo umount /mnt
break
;;
[Nn]*)
log "Alrighty then..."
break
;;
*)
warn "Please answer yes or no."
;;
esac
done
}
grub_tweaks() {
log "Tweaking grub config..."
# find a line that starts with GRUB_CMDLINE_LINUX_DEFAULT, if it has the word "splash", removes that word
sudo sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT=.*splash/{
s/ splash//
s/splash //
s/splash//
}' /etc/default/grub
# find a line that starts with GRUB_TIMEOUT= and replace whatever its value is with, including quotes, '0'
sudo sed -i "s/^\(GRUB_TIMEOUT=\).*/\1'0'/" /etc/default/grub
log "Applying new grub config..."
sudo grub-mkconfig -o /boot/grub/grub.cfg
log "Finished tweaking grub."
}
check_deps pacman paru git awk sudo
install_apps
configure_apps
grub_tweaks
giffoni_related
log "All done. Restart and enjoy."