Files
martin 50e3b46cc9 fix: GUI-Dialogauswahl und Konsolen-Fallback in darktable_wrapper
- darktable_wrapper.sh: DIALOG_BIN-Prüfung für fehlende GUI-Tools
- darktable_common.sh: Verbesserte Fehlerbehandlung bei Dialog-Auswahl

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 15:55:32 +02:00

84 lines
2.5 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=darktable_common.sh
source "$SCRIPT_DIR/darktable_common.sh"
log_step "Darktable Wrapper gestartet (PID $$)"
check_dependency darktable
check_dependency ssh openssh-client
check_dependency notify-send libnotify-bin
log "Alle Abhängigkeiten vorhanden."
load_config
validate_config
log "Konfiguration geladen: Server=$SERVER_USER@$SERVER_IP:$SERVER_SSH_PORT"
export DISPLAY="${DISPLAY:-:0}"
export DARKTABLE_SYNC_MODE=gui
log "Prüfen ob Darktable bereits läuft..."
if pgrep -x darktable &>/dev/null; then
log "Darktable läuft bereits (PID: $(pgrep -x darktable | tr '\n' ' ')) Abbruch."
notify-send "Darktable" \
"Darktable läuft bereits. Bitte zuerst schließen." -u critical
exit 1
fi
log "Darktable läuft nicht."
ACTIVE_MARKER_SET=false
cleanup() {
if [ "$ACTIVE_MARKER_SET" = true ]; then
ssh_server "rm -f '$SERVER_DB_DIR/darktable.active'" 2>/dev/null || true
fi
}
trap cleanup EXIT INT TERM
log "Serververbindung prüfen ($SERVER_USER@$SERVER_IP Port $SERVER_SSH_PORT)..."
if ! server_reachable; then
log "Server nicht erreichbar."
if ! ask_user "Darktable Sync" \
"Server nicht erreichbar.\nDarktable ohne Synchronisation starten?"; then
log "Abbruch durch Benutzer Server nicht erreichbar."
exit 0
fi
log "Starte Darktable ohne Sync (Server offline)..."
else
log "Server erreichbar."
log_step "Pre-Sync"
"$SYNC_BIN"
log "Pre-Sync abgeschlossen."
MARKER="$(hostname) seit $(date '+%Y-%m-%d %H:%M:%S')"
log "Active-Marker setzen: $MARKER"
ssh_server "echo '$MARKER' > '$SERVER_DB_DIR/darktable.active'" || true
ACTIVE_MARKER_SET=true
fi
log_step "Darktable starten"
"$DARKTABLE_BIN" "$@" || true
log "Darktable beendet."
if [ "$ACTIVE_MARKER_SET" = true ]; then
log "Active-Marker entfernen..."
ssh_server "rm -f '$SERVER_DB_DIR/darktable.active'" 2>/dev/null || true
ACTIVE_MARKER_SET=false
log "Active-Marker entfernt."
fi
log "Serververbindung für Post-Sync prüfen..."
if server_reachable; then
log_step "Post-Sync"
"$SYNC_BIN"
log "Post-Sync abgeschlossen."
else
log "Server nicht erreichbar Post-Sync übersprungen, sync_pending gesetzt."
touch "$CONFIG_DIR/sync_pending"
notify-send "Darktable Sync" \
"Server nicht erreichbar Sync ausstehend." -t 5000
fi
log_step "Darktable Wrapper beendet"