feh on linux keeps looping despite of --cycle-once [SOLVED]
by Michael35 from LinuxQuestions.org on (#6D4AM)
SOLVED
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:
PHP Code:#!/usr/bin/bash
input_folder="/home/pi/Public/screen/input/"
output_folder="/home/pi/Public/screen/output/"
slideshow_pid=""
###Functiontoupscaleandcopyimagesfromtheinputfoldertotheoutputfolder
upscale_and_copy(){
localfile_path="$1"
localfile_name=$(basename"$file_path")
localoutput_path="$output_folder/$file_name"
convert"$file_path"-resize1920x1080^"$output_path"
}
###Functiontoremoveimagesfromtheoutputfolder
remove_from_output_folder(){
localfile_path="$1"
localfile_name=$(basename"$file_path")
localoutput_path="$output_folder/$file_name"
rm"$output_path"
}
###Functiontorestarttheslideshow
restart_slideshow(){
if[[-n"$slideshow_pid"]];then
kill"$slideshow_pid"
fi
###Functionthatplaystheactualslideshow
feh--quiet--fullscreen--cycle-once--slideshow-delay3"$output_folder"&
slideshow_pid=$!
}
###Upscaleandcopyexistingimagesfrominputtooutputfolder
forfilein"$input_folder"/*;do
upscale_and_copy"$file"
done
###Displaytheimagesfromtheoutputfolderinaslideshow
restart_slideshow
###Monitorinputfolderforchangesandupdatetheoutputfolderaccordingly
inotifywait-m-r-ecreate-edelete-emove-emodify"$input_folder"|
whileread-rdirectoryeventfilename;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. If anyone knows what the problem might be, please tell me.
PHP Code:feh--quiet--fullscreen--cycle-once--slideshow-delay3/home/pi/Public/screen/output/&
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:
PHP Code:#!/usr/bin/bash
input_folder="/home/pi/Public/screen/input/"
output_folder="/home/pi/Public/screen/output/"
slideshow_pid=""
###Functiontoupscaleandcopyimagesfromtheinputfoldertotheoutputfolder
upscale_and_copy(){
localfile_path="$1"
localfile_name=$(basename"$file_path")
localoutput_path="$output_folder/$file_name"
convert"$file_path"-resize1920x1080^"$output_path"
}
###Functiontoremoveimagesfromtheoutputfolder
remove_from_output_folder(){
localfile_path="$1"
localfile_name=$(basename"$file_path")
localoutput_path="$output_folder/$file_name"
rm"$output_path"
}
###Functiontorestarttheslideshow
restart_slideshow(){
if[[-n"$slideshow_pid"]];then
kill"$slideshow_pid"
fi
###Functionthatplaystheactualslideshow
feh--quiet--fullscreen--cycle-once--slideshow-delay3"$output_folder"&
slideshow_pid=$!
}
###Upscaleandcopyexistingimagesfrominputtooutputfolder
forfilein"$input_folder"/*;do
upscale_and_copy"$file"
done
###Displaytheimagesfromtheoutputfolderinaslideshow
restart_slideshow
###Monitorinputfolderforchangesandupdatetheoutputfolderaccordingly
inotifywait-m-r-ecreate-edelete-emove-emodify"$input_folder"|
whileread-rdirectoryeventfilename;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. If anyone knows what the problem might be, please tell me.
PHP Code:feh--quiet--fullscreen--cycle-once--slideshow-delay3/home/pi/Public/screen/output/&