Link to home
Start Free TrialLog in
Avatar of Tom_Hickerson
Tom_HickersonFlag for United States of America

asked on

Auto Start FEH on raspbian

I am attempting to start FEH with several command line switches when Raspbian boots on my raspberry pi.  I tried putting it in the RC.local, but I am not having any luck because I am not sure of the syntax to use.  

Can someone tell me what to add to the rc.local file to run feh?

Here is what I type in to start it from a terminal window
feh -Z -F -Y -q -z -r -D 6 /media/USB
Avatar of zwei
zwei
Flag of Sweden image

Don't consider this an answer, just some stuff I would try. Is /media/USB mounted at this time (i.e did you mount in rc.local or just fstab?) And did you try it without any arguments?
feh /media/USB

Open in new window

Avatar of Tom_Hickerson

ASKER

No, I have no idea... This is all new to me and I don't know what to look for or what to do.  

I was trying to run vncserver at boot and I just put it in the rc.local and I never could get it to work.  I finally found a link that said it needed something like su -c "vncsever" but I tried that on the feh, and it didn't work.  

Any help appreciated.
Avatar of Gerwin Jansen
First, put your feh command in a script, like this:

 /home/YOUR_USERNAME/start_feh.sh

(make script executable: chmod 755  /home/YOUR_USERNAME/start_feh.sh )

Add this line to your /etc/rc.local file:

 /home/YOUR_USERNAME/start_feh.sh

and reboot your pi

You sure /media/USB contains your images?
How do you mount your USB device btw?
Thanks for the info in your first response.  I will try it when I get home.  

I had found some lines to type in to a terminal to mount the usb flash drive.  I didn't add anything to scripts.  I don't remember what the lines where.  

Whatever I did seems to work.  I can reboot and go to a terminal and type

feh -Z -F -Y -q -z -r -D 6 /media/USB

and feh starts showing pictures.

Is there something I need to put in the start_feh script for the usb drive mouting?

Thanks!
No problem, meanwhile I tested a bit and got I working. You don't need to put the line in the /etc/rc.local file but create a desktop file in the autostart directory instead (since you're booting into a graphical environment).

From a console (once your pi is booted):

mkdir ~/.config/autostart
touch ~/.config/autostart/start_feh.desktop

Edit the desktop file and put this in the file:
(vi ~/.config/autostart/start_feh.desktop)

[Desktop Entry]
Name=feh_slideshow
Exec=/home/pi/start_feh.sh
Type=application

In my case, the USB device was not mounted automatically, I had to create an additional entry in /etc/fstab. Try the above first, if it doesn't work for you let me know.

You will see the RPI desktop as it boots up, shortly after that, the slideshow starts.
What's the purpose of the touch command?  It looks like it changes the timestamp of the file.  Why is that needed?

Thank you so much.
touch updates a timestamp of a file, when there is no file, it creates the file you point to, you could leave it out, and just create the file using vi
I got my USB device to auto mount this way: find the UUID like this:

#ls -l /dev/disk/by-uuid/

Look for a line like this:

lrwxrwxrwx 1 root root 10 Jan  1  1970 <your UUID> -> ../../sda1

Create a mount point, for example:

#mkdir /mnt/USB
#chmod 775 /mnt/USB

Add mount point to fstab file:

#vi /etc/fstab

Add this line:

UUID=<your UUID>  /mnt/USB        vfat    defaults          0       0

Save the fstab file and reboot, your USB drive will be mounted to /mnt/USB for use by feh
Ok I got to try this stuff last night and I couldn't get it to start feh.

I did put the feh command in the file start_feh.sh, and did the chmod.  FYI my username is pi


I didn't add the auto mount you described because even after a reboot I can type feh /media/USB/ and it works so I don't think I need to do anything here.  Correct me if I am wrong.  I suppose I could copy some pictures onto the pi and see if it works then.  

I did create the file ~/.config/autostart/start_feh.desktop


[Desktop Entry]
Name=feh_slideshow
Exec=/home/pi/start_feh.sh
Type=application

I couldn't use vi because it wouldn't let me type in the editor.  I used nano instead

How can I test these scripts without just rebooting and see if they run.  

I tried typing in start_feh.sh but it just game me an error.
>> I didn't add the auto mount you described because even after a reboot I can type feh /media/USB/
Ok, then you don't need the auto mount part.

>>I tried typing in start_feh.sh but it just game me an error.
What was the error? Can you post that?

I'm using the pi username as well.
I didn't write it down.   It was an error to me that sounded like the file wasn't there.  

should I be able to type start_feh.sh into a terminal window and execute the script?
>>should I be able to type start_feh.sh into a terminal window and execute the script?
Yes, sure!
Ok.  I will have to try again tonight and write down the error message.

Thanks
Ok I tried it.  I got to the directory of the file and the file is there. start_feh.sh.  The file is green in color if that means anything.

Then I type in
start_feh.sh

I get this error message bash: start_feh.sh command not found
I did some playing at it looks like a path issue.  If I type in
/home/pi/start_feh.sh   it works


But the launch script does not work.  

Can I test it somehow?
Let me check later today. Green means the file is executable, this is OK.

./start_feh.sh should work as well.
ASKER CERTIFIED SOLUTION
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'll check  tonight.  Thanks for your continued patience with me :)
No problem :) - just having fun with RPI ...
Ok.  Everything is now a match for what you have, but it doesn't work when I reboot.

So here is what works.  I can reboot and type
/home/pi/start_feh.sh

and the slideshow starts.  

However if I reboot I get nothing.  
I tried adding /home/pi/start_feh.sh  in the rc.local and that didn't work.

The only thing I am doing differently is I don't have a keyboard and mouse connected to my pi so  I am using VNC to login to the pi.  It doen't control the same desktop as the one on the HDMI output.  I don't know if that could be an issue or not.

Is there a way I can test the start_feh.desktop file?
Am I suppose to do a chmod 755 on the .desktop file?
You don't have to modify the .desktop file, it works for me. I'm using an hdmi display, no remote  desktop. You should try hdmi as well, I'm thinking feh just doesn't work over a remote screen  ut I would have to test that.
I have the pi connected to HDMI, I was just doing all the keyboard and mouse work on a remote session.  

What command do you type in to make the .desktop file run?
>> What command do you type in to make the .desktop file run?
Nothing, just wait, it starts automatically.

Which distribution did you install on your Rasberry? I used Raspbian.
Is there a way to simulate the desktop file running?  That way I can make sure its being executed at boot, or find out if it doesn't work.  

I am pretty sure Raspbian.
>> Is there a way to simulate the desktop file running?
Yes, change the /home/pi/start_feh.sh like this:

echo `date` >> /home/pi/feh_start.log
/usr/bin/feh -Z -F -Y -q -z -r -D 6 /mnt/USB

Reboot your PI and check the start.log file - if it still doesn't work, post some screenshots of your setup like I did.
Gerwin,

I put the echo in there and verified that the desktop script was starting the start_feh script.  I then changed feh to point to some pictures stored locally and it started working.  The issue was the feh script was trying to load before the usb drive was mounted.  I added a sleep 30 to the start_feh script and then everything started working like I wanted it to.

Thanks for all your help!
Thanks for spending all the time helping me figure this out!
You're welcome ;-)