LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-20-2023, 12:45 AM   #1
Michael35
LQ Newbie
 
Registered: Jul 2023
Posts: 3

Rep: Reputation: 0
feh on linux keeps looping despite of --cycle-once [SOLVED]


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=""

### 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 [[ -
"$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. If anyone knows what the problem might be, please tell me.

PHP Code:
feh --quiet --fullscreen --cycle-once --slideshow-delay 3 /home/pi/Public/screen/output/ & 

Last edited by Michael35; 07-20-2023 at 03:03 AM. Reason: SOLVED
 
Old 07-20-2023, 01:04 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,927

Rep: Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320
Hello, and welcome here, at LQ

The latest feh has no such option (-cycle-once), but: --on-last-slide
What OS, and feh do you have?
Would be nice to use code tags.
 
1 members found this post helpful.
Old 07-20-2023, 02:45 AM   #3
Michael35
LQ Newbie
 
Registered: Jul 2023
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
Hello, and welcome here, at LQ

The latest feh has no such option (-cycle-once), but: --on-last-slide
What OS, and feh do you have?
Would be nice to use code tags.
Hi! thank you for your reply. I will look into this! I had found this page, wich came close to what chatGPT was telling me: https://linux.die.net/man/1/feh
In there it also mentioned --cycle-once, and doesn't mention --on-last-slide

For OS, I am using: Raspbian 11 Bullseye for Libre Computer Boards
2022-09-22-raspbian-bullseye-arm64+aml-s905x-cc.img.xz

And this is my first post here, I will try to edit my post and incude the tags <3
 
Old 07-20-2023, 03:02 AM   #4
Michael35
LQ Newbie
 
Registered: Jul 2023
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
Hello, and welcome here, at LQ

The latest feh has no such option (-cycle-once), but: --on-last-slide
What OS, and feh do you have?
Would be nice to use code tags.
IT WORKS! I am so happy you replied to my question!
Googleing the specific --on-last-slide function got to to another site where I also found the --auto-zoom and --reload function, wich almost negate all of the code I made. So I will finally be able to continue this project. Thank you so much!
 
Old 07-20-2023, 03:58 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,927

Rep: Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320
You are welcome.
you can just enter man feh to see the documentation of it (the version you have actually).
 
Old 07-21-2023, 03:45 PM   #6
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Note that chatGPT just parrots back what it has found online. There is no apparent checking for version, accuracy, or OS relevancy so one may receive an answer from 5 or more years past that chatGPT thinks is proper but could be wildly off in left field for ones system.

Even if it seems right one should check the man pages or other documentation for recommended commands to ensure everything is valid.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
HPLIP keeps looping at plug-in installation Dan Suson Linux - Software 10 04-02-2022 07:42 AM
Feh: using feh to rotate wallpapers Earl Parker II Linux - Desktop 2 08-30-2019 07:16 PM
[SOLVED] Force CRON to run a job once again, despite the crontab settings ddsglq Linux - Newbie 4 12-06-2017 10:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration