--cycle-onceにもかかわらず、Linuxのfehは繰り返され続けます。

--cycle-onceにもかかわらず、Linuxのfehは繰り返され続けます。

私はraspbianを実行し、画面に画像を表示するためにlepotatoを使用しています。写真は、Windowsコンピュータからアクセスできる共有フォルダにあります。入力は画像があり、出力は実際にフルスクリーンになるようにサイズ変更されます。入力フォルダに変更があるかどうかを確認するコードがあるため、出力フォルダが調整されます。

私の問題:スライドショーを一度繰り返してから閉じて、下にGoogle Chromeを表示する必要があります。設定した時間(10分)待ってからスライドショーをもう一度再生してください。

何らかの理由で--cycle-onceを使用してもスライドショーが再生され続けます。ループ計算を試してみましたが、役に立ちませんでした。 Tは、コードから出力から写真を確認して写真を削除し、出力が空の場合はスリープモードに切り替えて再起動しようとしましたが、そうではありません。バラより写真を見るとき。

残念ながら、私は最初にLinuxとコーディングに触れ、ほとんどの作業にchatGPTを使用しています。私は3日間この問題を抱えていて、誰かが私を助けることができることを願っていました。

現在のコード:

#!/usr/bin/bash

input_folder="/home/power/Public/screen/input/"
output_folder="/home/power/Public/screen/output/"
slideshow_pid=""

### Function to upscale and copy images from the input folder to the output folder
upscale_and_copy() {
  local file_path="$1"
  local file_name=$(basename "$file_path")
  local output_path="$output_folder/$file_name"
  
  convert "$file_path" -resize 1920x1080^ "$output_path"
}

### Function to remove images from the output folder
remove_from_output_folder() {
  local file_path="$1"
  local file_name=$(basename "$file_path")
  local output_path="$output_folder/$file_name"
  
  rm "$output_path"
}

### Function to restart the slideshow
restart_slideshow() {
  if [[ -n "$slideshow_pid" ]]; then
    kill "$slideshow_pid"
  fi

### Function that plays the actual slideshow

  feh --quiet --fullscreen --cycle-once --slideshow-delay 3 "$output_folder" &
  slideshow_pid=$!
}

### Upscale and copy existing images from input to output folder
for file in "$input_folder"/*; do
  upscale_and_copy "$file"
done

### Display the images from the output folder in a slideshow
restart_slideshow

### Monitor input folder for changes and update the output folder accordingly
inotifywait -m -r -e create -e delete -e move -e modify "$input_folder" |
while read -r directory event filename; do
  if [[ $event == "CREATE" || $event == "MODIFY" || $event == "MOVED_TO" ]]; then
    upscale_and_copy "$input_folder/$filename"
    restart_slideshow
  elif [[ $event == "DELETE" || $event == "MOVED_FROM" ]]; then
    remove_from_output_folder "$input_folder/$filename"
    restart_slideshow
  fi
done

私は次のテストをしましたが、次のコードを実行しても繰り返されるので、feh自体が問題を引き起こしているようです。

feh --quiet --fullscreen --cycle-once --slideshow-delay 3 /home/power/Public/screen/output/ &

ベストアンサー1

私は自分で解決策を見つけました。

--cycle-once最新バージョンはサポートされなくなりましたfeh。今使用する必要があります--on-last-slide

おすすめ記事