install_theme.sh
1#!/usr/bin/env bash
2
3# Function to get the base name of a file
4basename() {
5 echo "${1##*/}"
6}
7
8# Display usage information
9usage() {
10 cat <<EOF
11Usage: $(basename "$0") [options]
12Installs the Catppuccin-Dark GNOME theme.
13
14Options:
15 -h, --help Display this help message.
16EOF
17}
18
19check_if_root() {
20 if [[ $EUID -eq 0 ]]; then
21 echo "Error: This script should not be run as root." 1>&2
22 exit 1
23 fi
24}
25
26# Set the GNOME theme using gsettings
27set_gnome_theme() {
28 local theme_name="Catppuccin-Dark"
29 echo "Setting GNOME theme to $theme_name..."
30
31 if gsettings set org.gnome.desktop.interface gtk-theme "$theme_name"; then
32 echo "GNOME theme set successfully!"
33 else
34 echo "Error: Failed to set GNOME theme. Ensure GNOME is installed and running."
35 exit 1
36 fi
37}
38
39# Check if required dependencies are installed
40check_dependencies() {
41 local dependencies=("git" "gsettings")
42 for cmd in "${dependencies[@]}"; do
43 if ! command -v "$cmd" &> /dev/null; then
44 echo "Error: $cmd is not installed. Please install it using your package manager."
45 exit 1
46 fi
47 done
48}
49
50# Main function to install the theme
51install_theme() {
52 local repo_url="https://github.com/chocoOnEstrogen/dotfiles"
53 local tmp_dir
54 tmp_dir=$(mktemp -d)
55 local theme_dir="$HOME/.themes"
56 local theme_name="Catppuccin-Dark"
57
58 echo "Installing the Catppuccin-Dark theme..."
59
60 # Create the theme directory if it doesn't exist
61 mkdir -p "$theme_dir"
62
63 # Clone the repository
64 if ! git clone "$repo_url" "$tmp_dir"; then
65 echo "Error: Failed to clone repository."
66 exit 1
67 fi
68
69 # Copy the theme files
70 if ! cp -r "$tmp_dir/machines/personal/applications/gnome/theme/$theme_name" "$theme_dir"; then
71 echo "Error: Failed to copy theme files."
72 exit 1
73 fi
74
75 # Clean up the temporary directory
76 rm -rf "$tmp_dir"
77
78 # Set the GNOME theme
79 set_gnome_theme
80
81 echo "Theme installation complete!"
82}
83
84# Parse command-line arguments
85parse_arguments() {
86 while [[ "$#" -gt 0 ]]; do
87 case "$1" in
88 -h|--help) usage; exit 0 ;;
89 *) echo "Error: Unknown option '$1'"; usage; exit 1 ;;
90 esac
91 shift
92 done
93}
94
95# Entry point
96main() {
97 parse_arguments "$@"
98 check_if_root
99 check_dependencies
100 install_theme
101}
102
103# Run the script
104main "$@"
105