-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.sh
More file actions
executable file
·266 lines (235 loc) · 5.72 KB
/
scripts.sh
File metadata and controls
executable file
·266 lines (235 loc) · 5.72 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#!/bin/bash
SWAY_DEPS='
sway
swaybg
swayidle
swaylock'
HYPRLAND_DEPS='
hyprland
hyprshot
hyprpicker
hyprpolkitagent
hyprlock
hypridle
hyprpaper
xdg-desktop-portal-hyprland'
DEPS='
dosfstools
discord
gamemode
mangohud
python-langdetect
python-pyacoustid
python-pylast
chromaprint
python-pymad
python-beautifulsoup4
python-typing_extensions
beets
cdrtools
udiskie
bash-completion
wol
parallel
gst-plugin-spotify
inotify-tools
pass
wireshark-cli
fastfetch
nextcloud-client
pinentry-bemenu
btop
cliphist
which
pandoc-cli
starship
rsync
stow
yt-dlp
ffmpeg
gawk
wf-recorder
calc
tmux
seahorse
fzf
lazygit
newsboat
network-manager-applet
playerctl
pamixer
gnome-themes-extra
jq
bluez-utils
loupe
evince
ttf-dejavu
mpv
ranger
thunderbird
adwaita-icon-theme
libnotify
pop-icon-theme
pavucontrol
firefox
telegram-desktop
papirus-icon-theme
brightnessctl
mpv-mpris
ttf-font-awesome
github-cli
socat
blueman
vim
alacritty
obsidian
nm-connection-editor
noto-fonts-emoji
noto-fonts-cjk
greetd
greetd-tuigreet
wev
ttf-jetbrains-mono-nerd
waybar
bemenu-wayland
bemenu-ncurses
bemenu
slurp
grim
qt6-wayland
wl-clipboard
dunst
curl
borg
retroarch
newsboat
upower
libsecret'
install_systemd_units(){
source "$HOME/.config/scripts/settings.sh"
echo 'installing systemd units'
systemctl --user daemon-reload
# enable all services
for service in ${ENABLED_SERVICES}; do
echo "enabling $service"
systemctl --user enable --now "$service"
done
# enable all services templates
for service in ${TEMPLATE_SERVICES}; do
echo "enabling $service"
systemctl --user enable --now "$service"
done
# enable all services
for timer in ${ENABLED_TIMERS}; do
echo "enabling $timer"
systemctl --user enable --now "$timer"
done
echo ""
echo "if you enable the backup service remember to run backup.sh init to initialize the borg repo"
}
function configure_wallpaper(){
if [[ ! -e "$HOME/.config/hypr/hyprpaper.conf" ]]; then
echo 'create wallpaper config'
"$HOME/.local/bin/L.sh" -b fzf wallpaper
fi
}
function configure_hook(){
# create post merge hook for update
if [[ ! -e ".git/hooks/post-merge" ]]; then
echo 'create post-merge hook'
echo -e "#!/bin/bash\n./scripts.sh" > ".git/hooks/post-merge"
fi
chmod +x ".git/hooks/post-merge"
}
function configure_monitors(){
# create default monitor configuration file if does not exists
if [[ ! -e "$HOME/.config/hypr/monitors.conf" ]]; then
echo 'create monitor config'
echo "monitor = , preferred, auto, auto" > "$HOME/.config/hypr/monitors.conf"
fi
}
function configure_ssh(){
# add include ssh config
mkdir -p "$HOME/.ssh"
touch "$HOME/.ssh/config"
# check if configuration file exist and include ssh config for homelab
if [[ -f "$HOME/.ssh/config" ]] && ! grep -q 'Include ~/.config/ssh/config' "$HOME/.ssh/config" ; then
echo 'include ssh config'
echo "Include ~/.config/ssh/config" >> "$HOME/.ssh/config"
fi
}
function configure_gnupg(){
# add link to gpg folder
mkdir -p "$HOME/.gnupg/"
chmod 700 "$HOME/.gnupg/"
echo "pinentry-program /bin/pinentry-bemenu" > "$HOME/.gnupg/gpg-agent.conf"
}
function configure_system_settings(){
SCRIPT_PATH="$(dirname "$(realpath "$0")")"
if [[ ! -f "$SCRIPT_PATH/etc/scripts/settings.sh" ]]; then echo "no setting.sh file found, exiting"; exit 1; fi
source "$HOME/.config/scripts/settings.sh"
echo "configure greetd"
sudo cp "$SCRIPTS_LIB_FOLDER/greetd/config.toml" "/etc/greetd/config.toml"
echo "configure pam for unlock gnome keyring at startup"
sudo cp "$SCRIPTS_LIB_FOLDER/pam.d/greetd" "/etc/pam.d/greetd"
echo "configuring sudo to execute pacman without password for update automation"
echo "$USER ALL=(ALL:ALL) NOPASSWD:/bin/pacman" |sudo tee "/etc/sudoers.d/$USER"
}
SCRIPT_PATH="$(dirname "$(realpath "$0")")"
# check on settings.sh file
if [[ ! -f "$SCRIPT_PATH/etc/scripts/settings.sh" ]]; then
echo 'no settings.sh file found, creating default one'
echo 'source $HOME/.config/scripts/settings.sh.sample' > "$SCRIPT_PATH/etc/scripts/settings.sh"
grep '""' etc/scripts/settings.sh.sample >> "$SCRIPT_PATH/etc/scripts/settings.sh"
fi
OPTIND=1
# flag to manage packages, script install packages as default
PACKAGES="TRUE"
while getopts p flag; do
case "${flag}" in
p) PACKAGES="FALSE"; shift ;;
*) echo "${flag} is unsupported" ; exit 1 ;;
esac
done
case "$1" in
uninstall)
stow --target="$HOME/.config" -D etc
stow --target="$HOME/.local/lib" -D lib
stow --target="$HOME/.local/bin" -D bin
stow --target="$HOME/.config/systemd/user" -D systemd
stow --target="$HOME/.mozilla/firefox" -D firefox
systemctl --user daemon-reload
sed '/source \$HOME\/\.config\/scripts\/settings.sh/d' -i "$HOME/.bashrc"
sed 'Include ~/.config/ssh/config' -i "$HOME/.ssh/config"
echo "removing packages"
if [[ "$PACKAGES" == 'TRUE' ]];then
sudo pacman -Rns --noconfirm $DEPS $HYPRLAND_DEPS
fi
;;
system)
configure_system_settings
;;
*)
mkdir -p "$HOME/.config/" "$HOME/.config/systemd/user" "$HOME/.local/bin" "$HOME/.local/lib" "$HOME/.mozilla/firefox"
echo 'installing packages'
if [[ "$PACKAGES" == 'TRUE' ]];then
sudo pacman -S --noconfirm $DEPS $HYPRLAND_DEPS
fi
echo 'installing configs'
stow --target="$HOME/.config" etc
stow --target="$HOME/.local/lib" lib
stow --target="$HOME/.local/bin" bin
stow --target="$HOME/.config/systemd/user" systemd
stow --target="$HOME/.mozilla/firefox" firefox
echo 'adding bash integration'
if [[ "$(grep 'source $HOME/.config/scripts/settings.sh' "$HOME/.bashrc" )" == "" ]]; then
echo 'source $HOME/.config/scripts/settings.sh' >> "$HOME/.bashrc";
fi
install_systemd_units
configure_monitors
configure_wallpaper
configure_ssh
configure_gnupg
configure_hook
;;
esac