macbook-setup/setup-desktop.sh
Rene aa24f89511 Brave auf apt, Kitty, FaceTime-Webcam, WireGuard wg-quick, SSH-Setup, HiDPI-Verbesserungen
- Brave Browser: von Flatpak auf apt mit offiziellem Repo umgestellt
- Kitty Terminal: Installation (apt) + Konfiguration in setup-desktop.sh
- FaceTime HD Webcam: Firmware + DKMS-Treiber (bcwc_pcie)
- WireGuard: von NetworkManager auf wg-quick umgestellt, DNS fuer m13
- SSH-Key-Generierung + automatische HTTPS→SSH Umstellung der Repos
- Thunderbird: von apt auf Snap (wegen .deb-Bug)
- XFCE HiDPI: Noto Sans 10pt, Panel 28px, fuer beide MBPs vereinheitlicht
- Tastatur: ctrl:swap_lwin_lctl fuer Mac-like Cmd+C/V
- Standard-Apps: Brave (Browser), Thunderbird (Mail)
- CLAUDE.md: Doku aktualisiert

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-31 12:43:24 +02:00

312 lines
12 KiB
Bash
Executable file

#!/bin/bash
# macbook-setup/setup-desktop.sh
# Desktop-Setup: oh-my-zsh, Zsh-Tooling, Claude Code, PrusaSlicer, Dotfiles, XFCE
# Braucht eine laufende Desktop-Session (XFCE) — NICHT in chroot ausführen!
# Verwendung: bash setup-desktop.sh
# Wird automatisch beim ersten Login gestartet (via Autostart)
export LANG=en_US.UTF-8
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}[OK] $*${NC}"; }
warn() { echo -e "${YELLOW}[!!] $*${NC}"; }
fail() { echo -e "${RED}[FAIL] $*${NC}"; }
# ── Root-Check ───────────────────────────────────────────────────────────
[[ $EUID -eq 0 ]] && { fail "Nicht als root ausführen!"; exit 1; }
echo ""
echo "============================================"
echo " setup-desktop.sh startet"
echo "============================================"
# ── 1. oh-my-zsh ────────────────────────────────────────────────────────
echo -e "\n=== 1/8 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. Zsh-Plugins & Powerlevel10k ──────────────────────────────────────
echo -e "\n=== 2/8 Zsh-Plugins & Powerlevel10k ==="
# zsh-syntax-highlighting (Submodule im Dotfiles-Repo ist leer)
ZSH_SHL_DIR="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting"
if [[ ! -d "$ZSH_SHL_DIR/.git" ]]; then
rm -rf "$ZSH_SHL_DIR"
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_SHL_DIR"
fi
ok "zsh-syntax-highlighting"
# Powerlevel10k (Submodule im Dotfiles-Repo ist leer)
P10K_DIR="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
if [[ ! -d "$P10K_DIR/.git" ]]; then
rm -rf "$P10K_DIR"
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$P10K_DIR"
fi
ok "Powerlevel10k"
# ── 3. MesloLGS NF Font (Powerlevel10k-Icons) ───────────────────────────
echo -e "\n=== 3/8 MesloLGS NF Font ==="
FONT_DIR="$HOME/.local/share/fonts"
mkdir -p "$FONT_DIR"
FONT_BASE="https://github.com/romkatv/powerlevel10k-media/raw/master"
for font in "MesloLGS NF Regular.ttf" "MesloLGS NF Bold.ttf" \
"MesloLGS NF Italic.ttf" "MesloLGS NF Bold Italic.ttf"; do
if [[ ! -f "$FONT_DIR/$font" ]]; then
curl -fsSL -o "$FONT_DIR/$font" "$FONT_BASE/${font// /%20}"
fi
done
fc-cache -f "$FONT_DIR" 2>/dev/null || true
ok "MesloLGS NF Fonts installiert"
# ── 4. npm global + Claude Code ─────────────────────────────────────────
echo -e "\n=== 4/8 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"
# ── 5. Flatpak-Apps (PrusaSlicer) ──────────────────────────────────────
echo -e "\n=== 5/10 Flatpak-Apps ==="
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)"
# ── 6. PlatformIO (pipx) ────────────────────────────────────────────────
echo -e "\n=== 6/10 PlatformIO ==="
if ! command -v pio &>/dev/null; then
pipx install platformio
pipx ensurepath
fi
ok "PlatformIO installiert (pipx)"
# ── 7. Dot-Files ────────────────────────────────────────────────────────
echo -e "\n=== 7/10 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 (platformio.zsh etc.)
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
ok "Dot-Files: oh-my-zsh custom"
fi
# heic-scripts nach ~/bin
mkdir -p ~/bin
if [[ -d "$DOTFILES_DIR/heic-scripts" ]]; then
for script in "$DOTFILES_DIR/heic-scripts"/*; do
[[ -f "$script" ]] && chmod +x "$script" && ln -sf "$script" ~/bin/
done
ok "Dot-Files: heic-scripts → ~/bin"
fi
# git-check-all.sh + git-update-all.sh nach ~/
if [[ -d "$DOTFILES_DIR/bin" ]]; then
for script in "$DOTFILES_DIR/bin"/*; do
[[ -f "$script" ]] && chmod +x "$script" && ln -sf "$script" ~/
done
ok "Dot-Files: git-check-all.sh, git-update-all.sh, git-sync-all.sh → ~/"
fi
# .zshrc (Symlink aus dotfiles-rene)
if [[ -f "$DOTFILES_DIR/zsh/install-zsh-dotfiles.sh" ]]; then
bash "$DOTFILES_DIR/zsh/install-zsh-dotfiles.sh"
ok "Dot-Files: .zshrc"
fi
# .p10k.zsh (vom Mac kopieren, falls im Repo vorhanden, sonst Wizard beim ersten Start)
if [[ -f "$DOTFILES_DIR/.p10k.zsh" ]]; then
cp "$DOTFILES_DIR/.p10k.zsh" ~/.p10k.zsh
ok "Dot-Files: .p10k.zsh"
else
warn ".p10k.zsh nicht im Dotfiles-Repo — beim ersten zsh-Start 'p10k configure' ausfuehren"
fi
# ── 8. Kitty Terminal ──────────────────────────────────────────────────
echo -e "\n=== 8/10 Kitty Terminal ==="
KITTY_CONF_DIR="$HOME/.config/kitty"
mkdir -p "$KITTY_CONF_DIR"
cat > "$KITTY_CONF_DIR/kitty.conf" <<'KITTYEOF'
# Font
font_family MesloLGS NF
font_size 18.0
# Fenster
initial_window_width 120c
initial_window_height 35c
# Scrollback
scrollback_lines 10000
# Kein Glockenspiel
enable_audio_bell no
# Copy/Paste mit Ctrl+C/V (= Cmd auf Mac-Keyboard nach Swap)
map ctrl+c copy_or_interrupt
map ctrl+v paste_from_clipboard
# Tab-Verwaltung
map ctrl+t new_tab
map ctrl+w close_tab
map ctrl+shift+left previous_tab
map ctrl+shift+right next_tab
# Scrolling
map ctrl+shift+up scroll_line_up
map ctrl+shift+down scroll_line_down
map ctrl+shift+page_up scroll_page_up
map ctrl+shift+page_down scroll_page_down
# Keine Scrollbar
scrollback_indicator_color none
KITTYEOF
ok "Kitty Terminal konfiguriert"
# Kitty als Standard-Terminal
sudo update-alternatives --set x-terminal-emulator /usr/bin/kitty 2>/dev/null || true
ok "Kitty als Standard-Terminal"
# ── 9. SSH-Key + Git auf SSH umstellen ────────────────────────────────
echo -e "\n=== 9/10 SSH-Key + Git ==="
SSH_KEY="$HOME/.ssh/id_ed25519"
if [[ ! -f "$SSH_KEY" ]]; then
ssh-keygen -t ed25519 -C "rene@$(hostname)" -f "$SSH_KEY" -N ""
ok "SSH-Key erstellt"
echo ""
warn "SSH Public Key in Forgejo hinterlegen:"
echo " https://git.motocamp.de/user/settings/keys"
echo ""
cat "${SSH_KEY}.pub"
echo ""
else
ok "SSH-Key vorhanden"
fi
# Forgejo SSH Host-Key akzeptieren
ssh-keyscan -p 2222 dsm.motocamp.de >> ~/.ssh/known_hosts 2>/dev/null
ok "Forgejo Host-Key akzeptiert"
# Git Remotes auf SSH umstellen
GIT_BASE="$HOME/git-projekte"
for repo in "$GIT_BASE"/*/; do
[[ -d "$repo/.git" ]] || continue
old_url=$(git -C "$repo" remote get-url origin 2>/dev/null)
if [[ "$old_url" == https://git.motocamp.de/rene/* ]]; then
name=$(basename "$old_url" .git)
git -C "$repo" remote set-url origin "ssh://git@dsm.motocamp.de:2222/rene/${name}.git"
ok "SSH: $(basename "$repo")"
fi
done
# Git Credential-Store (Fallback falls SSH-Key noch nicht in Forgejo)
git config --global credential.helper store
# ── 10. XFCE-Einstellungen ──────────────────────────────────────────────
echo -e "\n=== 10/10 XFCE-Einstellungen ==="
# Keyboard: XFCE soll /etc/default/keyboard respektieren (nicht eigenes Layout erzwingen)
if command -v xfconf-query &>/dev/null; then
xfconf-query -c keyboard-layout -p /Default/XkbDisable -n -t bool -s true 2>/dev/null || true
ok "XFCE Keyboard: System-Layout wird verwendet"
fi
# 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/blank-on-battery -s 5 --create -t int
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-battery-sleep -s 6 --create -t int
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-battery-off -s 7 --create -t int
ok "XFCE Power Manager konfiguriert"
else
warn "xfconf-query nicht gefunden — XFCE Energieeinstellungen übersprungen"
fi
# XFCE Terminal: MesloLGS NF als Schriftart setzen
XFCE_TERM_RC="$HOME/.config/xfce4/terminal/terminalrc"
if [[ -d "$HOME/.config/xfce4" ]]; then
mkdir -p "$(dirname "$XFCE_TERM_RC")"
if [[ -f "$XFCE_TERM_RC" ]]; then
sed -i 's/^FontName=.*/FontName=MesloLGS NF 11/' "$XFCE_TERM_RC" 2>/dev/null || true
else
cat > "$XFCE_TERM_RC" <<'TERMEOF'
[Configuration]
FontName=MesloLGS NF 11
MiscAlwaysShowTabs=FALSE
MiscBell=FALSE
MiscDefaultGeometry=120x35
ScrollingBar=TERMINAL_SCROLLBAR_NONE
TERMEOF
fi
ok "XFCE Terminal: MesloLGS NF Schriftart"
fi
# WezTerm: Konfiguration einrichten
WEZTERM_CFG="$HOME/.wezterm.lua"
if [[ ! -f "$WEZTERM_CFG" ]]; then
curl -fsSL "$FORGEJO/rene/macbook-setup/raw/branch/main/wezterm.lua" \
-o "$WEZTERM_CFG" \
&& ok "WezTerm: ~/.wezterm.lua eingerichtet" \
|| warn "WezTerm: Konfiguration uebersprungen"
else
ok "WezTerm: ~/.wezterm.lua bereits vorhanden"
fi
# WezTerm: XFCE als Standard-Terminal eintragen (helpers.rc)
HELPERS_RC="$HOME/.config/xfce4/helpers.rc"
mkdir -p "$(dirname "$HELPERS_RC")"
if grep -q "^TerminalEmulator=" "$HELPERS_RC" 2>/dev/null; then
sed -i 's/^TerminalEmulator=.*/TerminalEmulator=wezterm/' "$HELPERS_RC"
else
echo "TerminalEmulator=wezterm" >> "$HELPERS_RC"
fi
ok "WezTerm: XFCE Standard-Terminal gesetzt"
# Standard-Apps: Brave als Browser, Thunderbird als Mail
xdg-settings set default-web-browser brave-browser.desktop 2>/dev/null || true
xdg-mime default thunderbird.desktop x-scheme-handler/mailto 2>/dev/null || true
xdg-mime default thunderbird.desktop message/rfc822 2>/dev/null || true
ok "Standard-Apps: Brave (Browser), Thunderbird (Mail)"
# ── 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. SSH Public Key in Forgejo hinterlegen (falls noch nicht geschehen)"
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"
echo " 5. Falls p10k-Icons fehlen: Terminal-Schriftart auf 'MesloLGS NF' setzen"