-
Notifications
You must be signed in to change notification settings - Fork 6
/
install.sh
executable file
·129 lines (104 loc) · 3.34 KB
/
install.sh
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
#!/usr/bin/env bash
# exit on error
set -e
if [ "$(basename "$PWD")" != "mechabar" ]; then
printf "\n\033[1;31mYou must run this script from the 'mechabar' directory.\033[0m\n"
exit 1
fi
if ! command -v pacman &>/dev/null; then
printf "\n\033[1;31mThis script is intended for Arch-based systems only.\033[0m\n"
exit 1
fi
backup_files() {
printf "\n\033[1;34mBacking up existing config files...\033[0m\n"
CONFIG_DIR=~/.config
TIMESTAMP=$(date +%m-%Y)
declare -A FOLDERS=(
["waybar"]="waybar-backup-$TIMESTAMP"
["rofi"]="rofi-backup-$TIMESTAMP"
)
for SRC in "${!FOLDERS[@]}"; do
DEST="${FOLDERS[$SRC]}"
if [ -d "$CONFIG_DIR/$SRC" ]; then
printf "\033[1;33mBacking up %s to %s...\033[0m\n" "$SRC" "$DEST"
cp -r "$CONFIG_DIR/$SRC" "$CONFIG_DIR/$DEST"
else
printf "\033[1;34mNo existing %s config found. Skipping backup.\033[0m\n" "$SRC"
fi
done
}
check_packages() {
if pacman -Qi "$1" &>/dev/null; then
printf "\033[1;33m%s is already installed.\033[0m\n" "$1"
else
printf "\033[1;32mInstalling %s...\033[0m\n" "$1"
sudo pacman -S --noconfirm "$1"
fi
}
check_aur_packages() {
AUR_HELPER=$(get_aur_helper)
if $AUR_HELPER -Qi "$1" &>/dev/null; then
printf "\033[1;33m%s (AUR) is already installed.\033[0m\n" "$1"
else
printf "\033[1;32mInstalling %s (AUR)...\033[0m\n" "$1"
$AUR_HELPER -S --noconfirm "$1"
fi
}
# Determine the AUR helper (yay or paru)
get_aur_helper() {
if command -v yay &>/dev/null; then
echo "yay"
elif command -v paru &>/dev/null; then
echo "paru"
else
printf "\n\033[1;31mNeither yay nor paru were found. Install one to proceed:\033[0m\n"
printf "\033[1;32myay: \033[0msudo pacman -S --needed git base-devel && git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si\n"
printf "\033[1;32mparu: \033[0msudo pacman -S --needed base-devel && git clone https://aur.archlinux.org/paru.git && cd paru && makepkg -si\n"
printf "\n\033[1;31mor use your preferred AUR helper to install these packages:\033[0m\n"
printf "bluetui\nrofi-lbonn-wayland-git\n"
printf "\n\033[1;33mOnce installed, rerun the script.\033[0m\n"
exit 1
fi
}
install_dependencies() {
printf "\n\033[1;32mInstalling dependencies...\033[0m\n"
DEPENDENCIES=(
bluez-utils brightnessctl hyprlock pipewire pipewire-pulse python ttf-jetbrains-mono-nerd wireplumber
)
for PACKAGE in "${DEPENDENCIES[@]}"; do
check_packages "$PACKAGE"
done
}
install_aur_packages() {
printf "\n\033[1;32mUsing %s to install AUR packages...\033[0m\n" "$(get_aur_helper)"
check_aur_packages bluetui
check_aur_packages rofi-lbonn-wayland-git
}
copy_configs() {
printf "\n\033[1;32mCopying config files...\033[0m\n"
mkdir -p ~/.config/waybar/
cp config.jsonc style.css theme.css ~/.config/waybar/
mkdir -p ~/.config/rofi
cp rofi/* ~/.config/rofi/
}
setup_scripts() {
printf "\n\033[1;32mSetting up scripts...\033[0m\n"
mkdir -p ~/.config/waybar/scripts/
cp scripts/* ~/.config/waybar/scripts/
chmod +x ~/.config/waybar/scripts/*
}
restart_waybar() {
printf "\n\033[1;32mRestarting Waybar...\033[0m\n"
killall waybar || true
nohup waybar >/dev/null 2>&1 &
}
main() {
backup_files
install_dependencies
install_aur_packages
copy_configs
setup_scripts
restart_waybar
printf "\n\033[1;32mInstallation complete!\033[0m\n\n"
}
main