diff --git a/.gitignore b/.gitignore deleted file mode 100644 index c18dd8d..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -__pycache__/ diff --git a/build.sh b/build.sh index dfa9316..9f05537 100755 --- a/build.sh +++ b/build.sh @@ -85,7 +85,7 @@ update_system() { install_packages() { log_info "Installing packages..." - pacman -S --noconfirm --needed \ + pacman -Sy --noconfirm --needed \ $ESSENTIAL_PACKAGES \ $DISPLAY_MANAGER \ $WAYLAND_ENVIRONMENT \ @@ -94,6 +94,39 @@ install_packages() { $MEDIA_PACKAGES } +install_nvidia_drivers() { + log_info "Checking for NVIDIA GPU..." + + if lspci | grep -i 'vga\|3d' | grep -iq 'nvidia'; then + log_success "NVIDIA GPU detected." + + log_info "Installing NVIDIA drivers..." + pacman -Sy --noconfirm --needed nvidia nvidia-utils + + log_info "Running mkinitcpio..." + mkinitcpio -P + + log_info "Enabling NVIDIA modeset..." + mkdir -p /etc/modprobe.d + echo "options nvidia_drm modeset=1" > /etc/modprobe.d/nvidia.conf + + else + log_info "No NVIDIA GPU detected. Skipping NVIDIA driver installation." + fi +} + +install_system_files() { + log_info "Installing system files from ./system_files to /..." + + if [ -d "system_files" ]; then + cp -a ./system_files/. / + + log_success "System files copied to root (/)." + else + log_warn "'system_files' directory not found." + fi +} + apply_gtk_settings() { log_info "Applying GTK settings..." export XDG_RUNTIME_DIR="/run/user/$(id -u "$ORIG_USER")" @@ -143,23 +176,55 @@ run_dotfiles_setup() { log_info "Running dotfiles setup..." cd "$ORIG_PWD" - [ -f "setup_user.py" ] && sudo -u "$ORIG_USER" HOME="$ORIG_HOME" python3 setup_user.py \ - || log_warn "setup_user.py not found." - - [ -f "setup_system.py" ] && python3 setup_system.py \ - || log_warn "setup_system.py not found." - sudo -u "$ORIG_USER" mkdir -p \ "$ORIG_HOME/Downloads" \ "$ORIG_HOME/Documents" \ "$ORIG_HOME/Pictures" \ "$ORIG_HOME/Videos" \ "$ORIG_HOME/Repositories" + + if [ -d "home" ]; then + log_info "Copying files from ./home to $ORIG_HOME..." + + # Copy including hidden files, preserving structure + cp -a ./home/. "$ORIG_HOME/" + + # Fix ownership to the original user + chown -R "$ORIG_USER:$ORIG_USER" "$ORIG_HOME" + + log_info "Select monitor configuration:" + echo "1) monitors-1.conf" + echo "2) monitors-2.conf" + printf "${MAGENTA}Enter your choice (1 or 2): ${RESET}" + read -r MONITOR_CHOICE + + MONITORS_DIR="$ORIG_HOME/.config/hypr" + case "$MONITOR_CHOICE" in + 1) + cp "$MONITORS_DIR/monitors-1.conf" "$MONITORS_DIR/monitors.conf" + ;; + 2) + cp "$MONITORS_DIR/monitors-2.conf" "$MONITORS_DIR/monitors.conf" + ;; + *) + log_warn "Invalid choice. Skipping monitor config setup." + ;; + esac + + chown "$ORIG_USER:$ORIG_USER" "$MONITORS_DIR/monitors.conf" 2>/dev/null || true + log_success "Monitor config set to monitors.conf" + + log_success "Files copied to user home directory." + else + log_warn "'home' directory not found in script directory." + fi } # === Main flow === update_system install_packages +install_nvidia_drivers +install_system_files apply_gtk_settings enable_sddm install_sddm_theme diff --git a/setup_system.py b/setup_system.py deleted file mode 100644 index c5d6a2b..0000000 --- a/setup_system.py +++ /dev/null @@ -1,17 +0,0 @@ -import sys -from utils import choice_files, copy_with_structure, require_root, log_info, log_error, CYAN, RESET - -SRC_DIR = "system_files" -DST_DIR = "/" -CHOICES = {} - - -def main(): - require_root() - override_all = input(f"{CYAN}Override all existing system files? (Y/N): {RESET}").strip().lower() == 'y' - choice_files(SRC_DIR, DST_DIR, CHOICES, override_all) - copy_with_structure(SRC_DIR, DST_DIR, override_all) - - -if __name__ == '__main__': - main() diff --git a/setup_user.py b/setup_user.py deleted file mode 100644 index 78210de..0000000 --- a/setup_user.py +++ /dev/null @@ -1,22 +0,0 @@ -import os -from utils import choice_files, copy_with_structure, CYAN, RESET - - -SRC_DIR = "home" -HOME_DIR = os.path.expanduser("~") -CHOICES = { - '.config/hypr/monitors.conf': [ - '.config/hypr/monitors-1.conf', - '.config/hypr/monitors-2.conf' - ] -} - - -def main(): - override_all = input(f"{CYAN}Override all existing files for user (mainly .config)? (Y/N): {RESET}").strip().lower() == 'y' - choice_files(SRC_DIR, HOME_DIR, CHOICES, override_all) - copy_with_structure(SRC_DIR, HOME_DIR, override_all) - - -if __name__ == '__main__': - main() diff --git a/utils.py b/utils.py deleted file mode 100644 index 9578cf7..0000000 --- a/utils.py +++ /dev/null @@ -1,83 +0,0 @@ -import os -import shutil -import sys - - -RED = "\033[1;31m" -GREEN = "\033[1;32m" -YELLOW = "\033[1;33m" -CYAN = "\033[1;36m" -RESET = "\033[0m" - - -def log_info(msg): print(f"{CYAN}[*]{RESET} {msg}") -def log_success(msg): print(f"{GREEN}[✓]{RESET} {msg}") -def log_warn(msg): print(f"{YELLOW}[!]{RESET} {msg}") -def log_error(msg): print(f"{RED}[✗]{RESET} {msg}") - - -def ask_override(path): - resp = input(f"{YELLOW}'{path}' already exists. Override? (Y/N): {RESET}").strip().lower() - return resp == 'y' - - -def choice_files(src_root, dst_root, choices_map, override_all=False): - for final_name, options in choices_map.items(): - existing_options = [ - f for f in options - if os.path.exists(os.path.join(src_root, f.lstrip('/'))) - ] - if not existing_options: - log_warn(f"No source file found among options for {final_name}. Skipping.") - continue - - if len(existing_options) == 1: - chosen = existing_options[0] - else: - log_info(f"Choose which file to copy as '{final_name}':") - for idx, opt in enumerate(existing_options, 1): - print(f"{idx}: {opt}") - while True: - try: - choice_idx = int(input(f"{CYAN}Enter number (1-{len(existing_options)}): {RESET}")) - if 1 <= choice_idx <= len(existing_options): - chosen = existing_options[choice_idx - 1] - break - except ValueError: - pass - log_warn("Invalid choice, try again.") - - src_file = os.path.join(src_root, chosen.lstrip('/')) - dst_file = os.path.join(dst_root, final_name.lstrip('/')) - - if os.path.exists(dst_file): - if not override_all and not ask_override(dst_file): - log_warn(f"Skipped overriding {dst_file}") - continue - - shutil.copy2(src_file, dst_file) - log_success(f"Copied {chosen} -> {final_name}") - -def copy_with_structure(src_root, dst_root, override_all=False): - for root, dirs, files in os.walk(src_root): - rel_path = os.path.relpath(root, src_root) - target_dir = os.path.join(dst_root, rel_path) if rel_path != '.' else dst_root - - os.makedirs(target_dir, exist_ok=True) - - for file in files: - src_file = os.path.join(root, file) - dst_file = os.path.join(target_dir, file) - - if os.path.exists(dst_file): - if not override_all and not ask_override(dst_file): - log_warn(f"Skipped overriding {dst_file}") - continue - - shutil.copy2(src_file, dst_file) - log_success(f"Copied: {src_file} -> {dst_file}") - -def require_root(): - if os.geteuid() != 0: - log_error("This script must be run as root (sudo). Exiting.") - sys.exit(1)