Tolto il file openpdf.sh

This commit is contained in:
tommal
2025-11-30 14:50:59 +01:00
parent ddaf9329a1
commit 6388fc9e46
2 changed files with 0 additions and 69 deletions

View File

@@ -156,10 +156,6 @@ RUN chmod 644 /usr/local/share/applications/firefox-pdf.desktop && \
RUN gosu abc xdg-mime default firefox-esr.desktop application/pdf || true RUN gosu abc xdg-mime default firefox-esr.desktop application/pdf || true
RUN gosu abc xdg-mime default firefox-pdf.desktop application/pdf || true RUN gosu abc xdg-mime default firefox-pdf.desktop application/pdf || true
# Copy both the PDF watcher script AND the autostart script
COPY defaults/openpdf.sh /usr/local/bin/openpdf.sh
RUN chmod +x /usr/local/bin/openpdf.sh && chown abc:abc /usr/local/bin/openpdf.sh
# Copy the autostart script to /defaults/ (LinuxServer base image uses this location) # Copy the autostart script to /defaults/ (LinuxServer base image uses this location)
COPY defaults/autostart /defaults/autostart COPY defaults/autostart /defaults/autostart
RUN chmod +x /defaults/autostart RUN chmod +x /defaults/autostart

View File

@@ -1,65 +0,0 @@
#!/usr/bin/env bash
# Watch multiple directories
WATCH_DIRS=("/tmp" "/config/Fiscality/workspace")
export DISPLAY=${DISPLAY:-:1}
export XAUTHORITY=${XAUTHORITY:-/home/abc/.Xauthority}
LAST_SCAN_STATE_FILE="/tmp/.filewatcher_state"
LOG_FILE="/tmp/filewatcher.log"
# Allow abc user access to X
xhost +SI:localuser:abc >/dev/null 2>&1 || true
# Load previous seen files
declare -A seen
if [ -f "$LAST_SCAN_STATE_FILE" ]; then
while IFS= read -r f; do
[ -n "$f" ] && seen["$f"]=1
done < "$LAST_SCAN_STATE_FILE"
fi
persist_seen() {
: > "$LAST_SCAN_STATE_FILE"
for f in "${!seen[@]}"; do
printf '%s\n' "$f" >> "$LAST_SCAN_STATE_FILE"
done
}
echo "$(date): File watcher started, watching: ${WATCH_DIRS[*]}" >> "$LOG_FILE"
while true; do
# Iterate through all watched directories
for WATCH_DIR in "${WATCH_DIRS[@]}"; do
# Skip if directory doesn't exist yet
if [ ! -d "$WATCH_DIR" ]; then
echo "$(date): Directory $WATCH_DIR does not exist yet" >> "$LOG_FILE"
continue
fi
# Iterate over every entry in the directory
for file in "$WATCH_DIR"/*; do
[ -f "$file" ] || continue # only regular files
# skip our own state file if inside the watched dir
[ "$file" = "$LAST_SCAN_STATE_FILE" ] && continue
if [ -z "${seen["$file"]}" ]; then
# new file found
echo "$(date): New file detected: $file" >> "$LOG_FILE"
seen["$file"]=1
# Open with the default app (xdg-open) as user abc
if command -v gosu >/dev/null 2>&1; then
gosu abc env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" \
nohup xdg-open -- "$file" >/dev/null 2>&1 &
echo "$(date): Opened $file with xdg-open (gosu)" >> "$LOG_FILE"
else
# fallback
su -s /bin/bash abc -c "env DISPLAY='$DISPLAY' XAUTHORITY='$XAUTHORITY' nohup xdg-open -- '$file' >/dev/null 2>&1" || true
echo "$(date): Opened $file with xdg-open (su)" >> "$LOG_FILE"
fi
fi
done
done
persist_seen
sleep 2
done