I am using a le potato running raspbian, to display pictures on a screen. These pictures are in a shared folder I can access from my windows pc. The input is where the pictures go, and output is scaled so they are actually fullscreen. I have some code to check if any changes are made in the input folder, so it will adjust the output folder.
My problem:
I need the slideshow to loop once, then close, revealing google chrome underneath. Wait for a set amount of time (10 minutes) and then play the slideshow again.
For some reason, the slideshow keeps playing even though I use --cycle-once.
I have tried to use a loop count, but this did not do anything. T tried to have the code delete the pictures in output after vieuwing them, and then after output is empty sleep and restart, but it didn't *see* when a picture was viewed.
Sadly im pretty new to linux and coding, and have used chatGPT for most of my work. I have been bashing my head against this for 3 days now, and hope someone can help me.
Current code:
#!/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
I have tested the following,
When I run JUST the following code, it STILL keeps looping endlessly, so it's feh itself that's causing the problem somehow:
feh --quiet --fullscreen --cycle-once --slideshow-delay 3 /home/power/Public/screen/output/ &
Asked by Michael van der Beek
(1 rep)
Jul 18, 2023, 03:07 PM
Last activity: Jul 20, 2023, 12:56 PM
Last activity: Jul 20, 2023, 12:56 PM