generated from AitorAstorga/Best-README-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apply_customisations.sh
55 lines (47 loc) · 2.09 KB
/
apply_customisations.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
#!/bin/bash
# Determine the directory where the script is being executed
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Capture the current user's name who invoked sudo
CURRENT_USER=${SUDO_USER:-$USER}
# Define an associative array (similar to a dictionary in other languages) for paths
declare -A PATHS
PATHS["GRUB Themes"]="/usr/share/grub/themes/"
PATHS["SDDM Themes"]="/usr/share/sddm/themes/"
PATHS["Plasma Look & Feel Themes"]="/usr/share/plasma/look-and-feel/"
PATHS["Plasma Desktop Themes"]="/usr/share/plasma/desktoptheme/"
PATHS["Plasma Color Schemes"]="/usr/share/color-schemes/"
PATHS["KWin Window Decorations"]="/usr/share/kwin/decorations/"
PATHS["Plasma Layout Templates"]="/usr/share/plasma/layout-templates/"
PATHS["Icon Themes"]="/usr/share/icons/"
PATHS["Konsole Themes"]="/usr/share/konsole/"
PATHS["Cursor Themes"]="/usr/share/icons/"
PATHS["Wallpapers"]="/usr/share/wallpapers/"
PATHS["Aurorae Window Decorations"]="/usr/share/aurorae/themes/"
PATHS["Plasmoid Widgets"]="/usr/share/plasma/plasmoids/"
PATHS["Kvantum Themes"]="/usr/share/Kvantum/"
PATHS["Application Configuration"]="~/.config/"
PATHS["Global Shortcuts"]="~/.config/kglobalshortcutsrc"
# Check if root (since we are writing to system directories)
if [[ $EUID -ne 0 ]]; then
echo "Please run this script as root."
exit 1
fi
# Iterate through each item and copy from source to destination
for ITEM in "${!PATHS[@]}"; do
if [[ -d "$DIR/$ITEM" ]]; then
echo "Copying $ITEM..."
cp -r "$DIR/$ITEM" "${PATHS[$ITEM]}"
# After copying, check for the two paths and chown them back to the user
if [[ "$ITEM" == "Application Configuration" || "$ITEM" == "Global Shortcuts" ]]; then
# Check if it's a directory or file and then chown
if [[ -d "${PATHS[$ITEM]}" ]]; then
chown -R $CURRENT_USER: "${PATHS[$ITEM]}"
elif [[ -f "${PATHS[$ITEM]}" ]]; then
chown $CURRENT_USER: "${PATHS[$ITEM]}"
fi
fi
else
echo "Directory $ITEM not found in $DIR, skipping..."
fi
done
echo "Done copying customisations!"