macbook-setup/setup-desktop.sh

134 lines
6.6 KiB
Bash
Raw Normal View History

#!/bin/bash
# macbook-setup/setup-desktop.sh
# Desktop-Setup: oh-my-zsh, Claude Code, PrusaSlicer, Dotfiles, XFCE-Einstellungen
# Braucht eine laufende Desktop-Session (XFCE) — NICHT in chroot ausführen!
# Verwendung: bash setup-desktop.sh
# Wird automatisch beim ersten Login gestartet (via Autostart)
set -e
FORGEJO="https://git.motocamp.de"
DOTFILES_REPO="$FORGEJO/rene/dotfiles-rene.git"
# ── Farben ──────────────────────────────────────────────────────────────
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
ok() { echo -e "${GREEN}$*${NC}"; }
warn() { echo -e "${YELLOW}$*${NC}"; }
err() { echo -e "${RED}$*${NC}"; exit 1; }
# ── Root-Check ───────────────────────────────────────────────────────────
[[ $EUID -eq 0 ]] && err "Nicht als root ausführen!"
echo ""
echo "════════════════════════════════════════════"
echo " setup-desktop.sh startet"
echo "════════════════════════════════════════════"
# ── 1. oh-my-zsh ────────────────────────────────────────────────────────
echo -e "\n=== 1/5 oh-my-zsh ==="
if [[ ! -d ~/.oh-my-zsh ]]; then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
fi
ok "oh-my-zsh installiert"
# ── 2. npm global + Claude Code ─────────────────────────────────────────
echo -e "\n=== 2/5 Claude Code ==="
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH="$HOME/.npm-global/bin:$PATH"
npm install -g @anthropic-ai/claude-code
ok "Claude Code installiert"
# ── 3. PrusaSlicer (Flatpak) ──────────────────────────────────────────────
echo -e "\n=== 3/5 PrusaSlicer ==="
if ! command -v flatpak &>/dev/null; then
sudo apt install -y flatpak
fi
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install --user -y flathub com.prusa3d.PrusaSlicer
ok "PrusaSlicer installiert (Flatpak)"
# ── 4. Dot-Files ────────────────────────────────────────────────────────
echo -e "\n=== 4/5 Dot-Files ==="
DOTFILES_DIR="$HOME/git-projekte/dotfiles-rene"
if [[ ! -d "$DOTFILES_DIR" ]]; then
mkdir -p "$HOME/git-projekte"
git clone "$DOTFILES_REPO" "$DOTFILES_DIR"
fi
# Neovim
if [[ -f "$DOTFILES_DIR/nvim/install-nvim-dotfiles.sh" ]]; then
bash "$DOTFILES_DIR/nvim/install-nvim-dotfiles.sh"
ok "Dot-Files: nvim"
fi
# Micro
if [[ -f "$DOTFILES_DIR/micro/install-micro-dotfiles.sh" ]]; then
bash "$DOTFILES_DIR/micro/install-micro-dotfiles.sh"
ok "Dot-Files: micro"
fi
# oh-my-zsh custom (Plugins, Themes, Aliase)
if [[ -d "$DOTFILES_DIR/oh-my-zsh/custom" ]] && [[ -d ~/.oh-my-zsh/custom ]]; then
for f in "$DOTFILES_DIR/oh-my-zsh/custom"/*.zsh; do
[[ -f "$f" ]] && ln -sf "$f" ~/.oh-my-zsh/custom/
done
# Custom Plugins
if [[ -d "$DOTFILES_DIR/oh-my-zsh/custom/plugins" ]]; then
for plugin_dir in "$DOTFILES_DIR/oh-my-zsh/custom/plugins"/*/; do
plugin_name=$(basename "$plugin_dir")
ln -sfn "$plugin_dir" ~/.oh-my-zsh/custom/plugins/"$plugin_name"
done
fi
# Custom Themes
if [[ -d "$DOTFILES_DIR/oh-my-zsh/custom/themes" ]]; then
for theme_dir in "$DOTFILES_DIR/oh-my-zsh/custom/themes"/*/; do
theme_name=$(basename "$theme_dir")
ln -sfn "$theme_dir" ~/.oh-my-zsh/custom/themes/"$theme_name"
done
fi
ok "Dot-Files: oh-my-zsh custom"
fi
# heic-scripts nach ~/bin
if [[ -d "$DOTFILES_DIR/heic-scripts" ]]; then
mkdir -p ~/bin
for script in "$DOTFILES_DIR/heic-scripts"/*; do
[[ -f "$script" ]] && ln -sf "$script" ~/bin/
done
ok "Dot-Files: heic-scripts → ~/bin"
fi
# ── 5. XFCE Energieeinstellungen ────────────────────────────────────────
echo -e "\n=== 5/5 XFCE Energieeinstellungen ==="
if command -v xfconf-query &>/dev/null; then
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-ac-off -s 0 --create -t int
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-ac-sleep -s 0 --create -t int
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/blank-on-ac -s 0 --create -t int
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-battery-off -s 10 --create -t int
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-battery-sleep -s 10 --create -t int
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/blank-on-battery -s 10 --create -t int
ok "XFCE Power Manager konfiguriert"
else
warn "xfconf-query nicht gefunden — XFCE Energieeinstellungen übersprungen"
fi
# ── Autostart entfernen ─────────────────────────────────────────────────
AUTOSTART_FILE="$HOME/.config/autostart/macbook-setup-desktop.desktop"
if [[ -f "$AUTOSTART_FILE" ]]; then
rm "$AUTOSTART_FILE"
ok "Firstboot-Autostart entfernt"
fi
# ── Zusammenfassung ──────────────────────────────────────────────────────
echo ""
echo "════════════════════════════════════════════"
echo -e " ${GREEN}Desktop-Setup abgeschlossen!${NC}"
echo "════════════════════════════════════════════"
echo ""
warn "Noch manuell erledigen:"
echo " 1. WireGuard-Config einspielen:"
echo " sudo cp wg0.conf /etc/wireguard/ && sudo systemctl enable --now wg-quick@wg0"
echo " 2. Synology Drive Client installieren (.deb von synology.com)"
echo " 3. Thunderbird starten → Profil aus Synology Drive einbinden"
echo " 4. Brave starten → Synchronisation einrichten"