Advertisement
MedesJegve

Untitled

Dec 17th, 2024 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.50 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Mappabeallitas (ahol a media fajlok vannak)
  4. MEDIA_DIR="/home/dd/Desktop/kepek/"
  5. DEFAULT_DURATION=3 # Alapertelmezett kep megjelenesi ido (mp)
  6. PLAYLIST_FILE="/tmp/mpv_playlist.m3u"
  7.  
  8. # mpv opciók
  9. MPV_OPTS="--fs --no-border --no-window-dragging --ontop --force-window=yes --osd-level=0 --loop"
  10.  
  11. # Leallitashoz: ESC eseten a script kilep
  12. trap "killall mpv; exit" SIGINT SIGTERM
  13.  
  14. # Dinamikus kepernyo felbontas lekerdezese
  15. SCREEN_WIDTH=$(xdpyinfo | awk '/dimensions:/ {print $2}' | cut -d"x" -f1)
  16. SCREEN_HEIGHT=$(xdpyinfo | awk '/dimensions:/ {print $2}' | cut -d"x" -f2)
  17. echo "Detected screen resolution: ${SCREEN_WIDTH}x${SCREEN_HEIGHT}"
  18.  
  19. # Lejátszási lista létrehozása
  20. echo "Generating playlist..."
  21. > "$PLAYLIST_FILE"
  22.  
  23. for FILE in "$MEDIA_DIR"/*; do
  24.     if [[ ! -f "$FILE" ]]; then
  25.         continue
  26.     fi
  27.  
  28.     EXT="${FILE##*.}"
  29.     FILENAME="$(basename -- "$FILE")"
  30.  
  31.     if [[ "$EXT" =~ ^(png|jpg|jpeg|gif)$ ]]; then
  32.         # Kep eseten fix idotartam
  33.         DURATION=$(echo "$FILENAME" | grep -oE "^[0-9]+" || echo "$DEFAULT_DURATION")
  34.         echo "Adding image: $FILE (Duration: $DURATION)"
  35.         echo "file '$FILE'" >> "$PLAYLIST_FILE"
  36.         echo "duration $DURATION" >> "$PLAYLIST_FILE"
  37.     elif [[ "$EXT" =~ ^(mp4|avi|mkv|mov)$ ]]; then
  38.         echo "Adding video: $FILE"
  39.         echo "file '$FILE'" >> "$PLAYLIST_FILE"
  40.     fi
  41. done
  42.  
  43. echo "Playlist generated: $PLAYLIST_FILE"
  44.  
  45. # mpv elinditasa a lejátszási listával
  46. mpv $MPV_OPTS --playlist="$PLAYLIST_FILE"
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement