More
This commit is contained in:
188
build.sh
188
build.sh
@@ -1,115 +1,141 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
ORIG_PWD=$(pwd)
|
||||
|
||||
# Elevate to root if needed
|
||||
# === Colors ===
|
||||
RED="\033[1;31m"
|
||||
GREEN="\033[1;32m"
|
||||
YELLOW="\033[1;33m"
|
||||
BLUE="\033[1;34m"
|
||||
MAGENTA="\033[1;35m"
|
||||
CYAN="\033[1;36m"
|
||||
RESET="\033[0m"
|
||||
|
||||
log_info() { printf "${CYAN}[*]${RESET} %s\n" "$1"; }
|
||||
log_success() { printf "${GREEN}[✓]${RESET} %s\n" "$1"; }
|
||||
log_warn() { printf "${YELLOW}[!]${RESET} %s\n" "$1"; }
|
||||
log_error() { printf "${RED}[✗]${RESET} %s\n" "$1"; }
|
||||
|
||||
ORIG_PWD=$(pwd)
|
||||
ORIG_USER=$(logname)
|
||||
ORIG_HOME=$(getent passwd "$ORIG_USER" | cut -d: -f6)
|
||||
|
||||
# === Elevate to root if needed ===
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
exec sudo "$0" "$@"
|
||||
fi
|
||||
|
||||
ORIG_USER=$(logname)
|
||||
ORIG_HOME=$(getent passwd "$ORIG_USER" | cut -d: -f6)
|
||||
|
||||
# === Update system ===
|
||||
echo "Updating system..."
|
||||
pacman -Syu --noconfirm
|
||||
|
||||
# === Essential tools ===
|
||||
# === Package groups ===
|
||||
ESSENTIAL_PACKAGES="
|
||||
python3
|
||||
vim
|
||||
neovim
|
||||
ranger
|
||||
firefox
|
||||
base-devel python3 vim neovim ranger firefox
|
||||
"
|
||||
|
||||
# === Display manager ===
|
||||
DISPLAY_MANAGER="
|
||||
sddm
|
||||
sddm qt5-graphicaleffects
|
||||
"
|
||||
|
||||
# === Wayland & Hyprland environment ===
|
||||
WAYLAND_ENVIRONMENT="
|
||||
hyprland
|
||||
hyprpaper
|
||||
waybar
|
||||
kitty
|
||||
wofi
|
||||
mako
|
||||
libnotify
|
||||
grim
|
||||
slurp
|
||||
wl-clipboard
|
||||
wayland-utils
|
||||
xorg-xwayland
|
||||
hyprland hyprpaper waybar kitty wofi mako libnotify grim slurp
|
||||
wl-clipboard wl-clip-persist wayland-utils xorg-xwayland
|
||||
"
|
||||
|
||||
# === Audio ===
|
||||
AUDIO_PACKAGES="
|
||||
pipewire
|
||||
wireplumber
|
||||
pipewire-pulse
|
||||
pavucontrol
|
||||
pipewire wireplumber pipewire-pulse pavucontrol
|
||||
"
|
||||
|
||||
# === Fonts & theming ===
|
||||
FONTS_AND_THEME="
|
||||
otf-font-awesome
|
||||
noto-fonts
|
||||
noto-fonts-cjk
|
||||
ttf-jetbrains-mono
|
||||
orchis-theme
|
||||
otf-font-awesome noto-fonts noto-fonts-cjk ttf-jetbrains-mono orchis-theme
|
||||
"
|
||||
|
||||
# === Multimedia ===
|
||||
MEDIA_PACKAGES="
|
||||
mpv
|
||||
eog
|
||||
ffmpeg
|
||||
mpv eog ffmpeg
|
||||
"
|
||||
|
||||
# === Install all packages ===
|
||||
echo "Installing packages..."
|
||||
pacman -S --noconfirm --needed \
|
||||
$ESSENTIAL_PACKAGES \
|
||||
$DISPLAY_MANAGER \
|
||||
$WAYLAND_ENVIRONMENT \
|
||||
$AUDIO_PACKAGES \
|
||||
$FONTS_AND_THEME \
|
||||
$MEDIA_PACKAGES
|
||||
# === Functions ===
|
||||
update_system() {
|
||||
log_info "Updating system..."
|
||||
pacman -Syu --noconfirm
|
||||
}
|
||||
|
||||
# === Enable display manager ===
|
||||
echo "Enabling SDDM..."
|
||||
systemctl enable sddm
|
||||
# === Apply GTK settings for theme and color scheme ===
|
||||
echo "Applying GTK settings..."
|
||||
install_packages() {
|
||||
log_info "Installing packages..."
|
||||
pacman -S --noconfirm --needed \
|
||||
$ESSENTIAL_PACKAGES \
|
||||
$DISPLAY_MANAGER \
|
||||
$WAYLAND_ENVIRONMENT \
|
||||
$AUDIO_PACKAGES \
|
||||
$FONTS_AND_THEME \
|
||||
$MEDIA_PACKAGES
|
||||
}
|
||||
|
||||
# Extract DBus address from the user's environment
|
||||
USER_DBUS_ENV=$(sudo -u "$ORIG_USER" -- dbus-launch)
|
||||
eval "$USER_DBUS_ENV"
|
||||
apply_gtk_settings() {
|
||||
log_info "Applying GTK settings..."
|
||||
export XDG_RUNTIME_DIR="/run/user/$(id -u "$ORIG_USER")"
|
||||
DBUS_ADDR="unix:path=${XDG_RUNTIME_DIR}/bus"
|
||||
|
||||
export DBUS_SESSION_BUS_ADDRESS
|
||||
export XDG_RUNTIME_DIR="/run/user/$(id -u $ORIG_USER)"
|
||||
for setting in \
|
||||
"org.gnome.desktop.interface gtk-theme Orchis-Dark-Compact" \
|
||||
"org.gnome.desktop.interface icon-theme Orchis-Dark-Compact" \
|
||||
"org.gnome.desktop.interface color-scheme prefer-dark"
|
||||
do
|
||||
if sudo -u "$ORIG_USER" \
|
||||
DBUS_SESSION_BUS_ADDRESS="$DBUS_ADDR" \
|
||||
gsettings set $setting; then
|
||||
log_success "Set $setting"
|
||||
else
|
||||
log_warn "Failed to set $setting"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
sudo -u "$ORIG_USER" DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS" \
|
||||
XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" \
|
||||
gsettings set org.gnome.desktop.interface gtk-theme "Orchis-Dark-Compact"
|
||||
enable_sddm() {
|
||||
log_info "Enabling SDDM..."
|
||||
systemctl enable sddm
|
||||
}
|
||||
|
||||
sudo -u "$ORIG_USER" DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS" \
|
||||
XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" \
|
||||
gsettings set org.gnome.desktop.interface icon-theme "Orchis-Dark-Compact"
|
||||
install_sddm_theme() {
|
||||
log_info "Installing SDDM theme..."
|
||||
if pacman -Q where-is-my-sddm-theme-git >/dev/null 2>&1; then
|
||||
log_success "SDDM theme already installed."
|
||||
return
|
||||
fi
|
||||
|
||||
sudo -u "$ORIG_USER" DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS" \
|
||||
XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" \
|
||||
gsettings set org.gnome.desktop.interface color-scheme "prefer-dark"
|
||||
sudo -u "$ORIG_USER" mkdir -p "$ORIG_HOME/Repositories"
|
||||
cd "$ORIG_HOME/Repositories"
|
||||
|
||||
echo "GTK settings applied successfully."
|
||||
if [ ! -d "where-is-my-sddm-theme" ]; then
|
||||
sudo -u "$ORIG_USER" git clone https://aur.archlinux.org/where-is-my-sddm-theme-git.git where-is-my-sddm-theme
|
||||
else
|
||||
log_warn "Theme repo already exists, skipping clone."
|
||||
fi
|
||||
|
||||
# === Run dotfiles setup ===
|
||||
echo "Running dotfiles setup as $ORIG_USER..."
|
||||
cd "$ORIG_PWD" || exit 1
|
||||
sudo -u "$ORIG_USER" HOME="$ORIG_HOME" python3 setup.py
|
||||
sudo -E -u "$ORIG_USER" HOME="$ORIG_HOME" mkdir -p "$ORIG_HOME/Downloads" "$ORIG_HOME/Documents" "$ORIG_HOME/Pictures" "$ORIG_HOME/Videos" "$ORIG_HOME/Repositories"
|
||||
cd "$ORIG_HOME/Repositories/where-is-my-sddm-theme"
|
||||
sudo -u "$ORIG_USER" makepkg -si --noconfirm
|
||||
}
|
||||
|
||||
echo "Dotfiles installed successfully."
|
||||
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"
|
||||
}
|
||||
|
||||
# === Main flow ===
|
||||
update_system
|
||||
install_packages
|
||||
apply_gtk_settings
|
||||
enable_sddm
|
||||
install_sddm_theme
|
||||
run_dotfiles_setup
|
||||
|
||||
log_success "Setup completed successfully."
|
||||
|
||||
Reference in New Issue
Block a user