forked from diinki/linux-retroism
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·126 lines (102 loc) · 3.67 KB
/
install.sh
File metadata and controls
executable file
·126 lines (102 loc) · 3.67 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
#!/usr/bin/env bash
set -e
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
NC='\033[0m'
USERNAME=$(whoami)
BACKUP_DIR="$HOME/${USERNAME}_BACKUPS"
CONFIG_DIR="$HOME/.config"
RICE_CONFIGS="./configs"
print_txt() {
echo -e "${2}${1}${NC}"
}
echo "
"
print_txt "【 Welcome to the Retroism Setup Process. 】" "$GREEN"
print_txt " _________________________________________" "$GREEN"
echo
print_txt "Are you using Hyprland or Sway/SwayFX?" "$YELLOW"
echo "1) Hyprland"
echo "2) Sway/SwayFX"
read -p "Enter (1 or 2):" option
case $option in
1)
DEPS=("hyprpaper" "nemo" "kitty" "nwg-look" "quickshell" "hyprshot" "mako" "dconf" "jq" "socat")
WINDOW_MANAGER="Hyprland"
;;
2)
DEPS=("swaybg" "nemo" "kitty" "nwg-look" "quickshell" "grim" "slurp" "swappy" "mako" "dconf" "jq" "socat")
WINDOW_MANAGER="Sway"
;;
*)
print_txt "Invalid option, exiting!" "$RED"
exit 1
;;
esac
print_txt "You've opted to use $WINDOW_MANAGER" "$GREEN"
echo
print_txt "Verifiying existence of dependencies..." "$YELLOW"
missing_deps=()
# Best way to do this? Unsure if this has high compat
for dep in "${DEPS[@]}"; do
if command -v "$dep" >/dev/null 2>&1 ; then
print_txt "✓ $dep - Found." "$GREEN"
else
missing_deps+=("$dep")
print_txt "✗ $dep - Not Found!" "$RED"
fi
done
if [ ${#missing_deps[@]} -gt 0 ]; then
echo
print_txt "Missing dependencies: ${missing_deps[*]}" "$RED"
print_txt "Please install the required dependencies, and then run this script again." "$RED"
# Some hints bcz we're nice.
if command -v apt &> /dev/null; then
print_txt "Hint: sudo apt install ${missing_deps[*]}" "$YELLOW"
elif command -v pacman &> /dev/null; then
print_txt "Hint: sudo pacman -S ${missing_deps[*]}" "$YELLOW"
fi
exit 1
fi
if [ ! -d "$RICE_CONFIGS" ]; then
print_txt "Error: Corrupt repository! '$RICE_CONFIGS' not found! Please re-install Retroism. Exiting." "$RED"
exit 1
fi
# Create backup directory if it doesn't exist
mkdir -p "$BACKUP_DIR"
echo
print_txt "Copying configs for programs..." "$YELLOW"
# A bit messy, here we copy all config dirs and also detect if we need to create a backup of something.
for dir in "$RICE_CONFIGS"/*/ ; do
if [ -d "$dir" ]; then
dirname=$(basename "$dir")
target_dir="$CONFIG_DIR/$dirname"
# Create backup if a directory already exists.
if [ -d "$target_dir" ]; then
backup_target="$BACKUP_DIR/$dirname"
print_txt "Backing up existing $dirname to $backup_target" "$YELLOW"
# Append timestamp to backup, in case of multiple backups existing.
if [ -d "$backup_target" ]; then
timestamp=$(date +"%Y%m%d_%H%M%S")
backup_target="${backup_target}_${timestamp}"
fi
mv "$target_dir" "$backup_target"
print_txt "✓ Backed up $dirname" "$GREEN"
fi
# Copy config.
cp -r "$dir" "$target_dir"
print_txt "✓ Copied $dirname to ~/.config/" "$GREEN"
fi
done
echo
print_txt "All configurations have been installed to ~/.config/" "$GREEN"
if [ "$(ls -A $BACKUP_DIR 2>/dev/null)" ]; then
print_txt "Backups of existing files have been created in: $BACKUP_DIR" "$YELLOW"
fi
echo
print_txt "_____________________________________________________________________________" "$NC"
echo
print_txt "Successfully installed Retroism!" "$GREEN"
print_txt "It's recommended to restart your computer, to ensure all changes take effect." "$NC"
print_txt "_____________________________________________________________________________" "$NC"