fix: timing flash + couleur idle LED + diagnostic auto-brightness
This commit is contained in:
@@ -32,6 +32,8 @@ filename="${1:-}"
|
||||
media_type="${2:-}"
|
||||
action_config_name="${3:-}"
|
||||
copies="${4:-1}"
|
||||
# Liste CSV d'imprimantes à exclure du load-balancing (optionnel, passé par JH-Photomaton)
|
||||
skip_printers="${5:-}"
|
||||
|
||||
# --- Noms des imprimantes CUPS (WiFi) ---
|
||||
PRINTER_1="Selphy_Blanche_WiFi"
|
||||
@@ -90,24 +92,44 @@ fi
|
||||
printer_1_status=$(lpstat -p "$PRINTER_1" 2>/dev/null || echo "not found")
|
||||
printer_2_status=$(lpstat -p "$PRINTER_2" 2>/dev/null || echo "not found")
|
||||
|
||||
# Verifie si une imprimante est dans la liste skip_printers (CSV)
|
||||
is_skipped() { [[ ",$skip_printers," == *",$1,"* ]]; }
|
||||
|
||||
# Une imprimante est utilisable si CUPS la connait ET qu'elle n'est pas exclue
|
||||
p1_ok=false
|
||||
p2_ok=false
|
||||
[[ "$printer_1_status" != "not found" ]] && ! is_skipped "$PRINTER_1" && p1_ok=true
|
||||
[[ "$printer_2_status" != "not found" ]] && ! is_skipped "$PRINTER_2" && p2_ok=true
|
||||
|
||||
SELECTED_PRINTER=""
|
||||
|
||||
if [[ "$printer_1_status" == *"idle"* ]]; then
|
||||
if $p1_ok && [[ "$printer_1_status" == *"idle"* ]]; then
|
||||
SELECTED_PRINTER="$PRINTER_1"
|
||||
log_info "Imprimante selectionnee: $PRINTER_1 (idle)"
|
||||
elif [[ "$printer_2_status" == *"idle"* ]]; then
|
||||
elif $p2_ok && [[ "$printer_2_status" == *"idle"* ]]; then
|
||||
SELECTED_PRINTER="$PRINTER_2"
|
||||
log_info "Imprimante selectionnee: $PRINTER_2 (idle)"
|
||||
else
|
||||
elif $p1_ok && $p2_ok; then
|
||||
# Les deux sont accessibles mais aucune n'est idle — load balance sur les jobs
|
||||
jobs_1=$(lpstat -o "$PRINTER_1" 2>/dev/null | wc -l)
|
||||
jobs_2=$(lpstat -o "$PRINTER_2" 2>/dev/null | wc -l)
|
||||
|
||||
if [ "$jobs_1" -le "$jobs_2" ] 2>/dev/null; then
|
||||
SELECTED_PRINTER="$PRINTER_1"
|
||||
else
|
||||
SELECTED_PRINTER="$PRINTER_2"
|
||||
fi
|
||||
log_info "Aucune imprimante idle, file sur: $SELECTED_PRINTER (P1=$jobs_1 jobs, P2=$jobs_2 jobs)"
|
||||
log_info "Load balancing: $SELECTED_PRINTER (P1=$jobs_1 jobs, P2=$jobs_2 jobs)"
|
||||
elif $p1_ok; then
|
||||
SELECTED_PRINTER="$PRINTER_1"
|
||||
log_info "Seule imprimante disponible: $PRINTER_1 (P2 inaccessible ou exclue)"
|
||||
elif $p2_ok; then
|
||||
SELECTED_PRINTER="$PRINTER_2"
|
||||
log_info "Seule imprimante disponible: $PRINTER_2 (P1 inaccessible ou exclue)"
|
||||
else
|
||||
log_error "Aucune imprimante accessible dans CUPS"
|
||||
echo "PRINT_ERROR::no_printer_available"
|
||||
[ -f "$filename_print" ] && rm -f "$filename_print" 2>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Impression ---
|
||||
|
||||
Reference in New Issue
Block a user