Solved

Auto Start FEH on raspbian

Posted on 2014-03-08
29
2,547 Views
Last Modified: 2016-08-13
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
0
Comment
Question by:Tom_Hickerson
  • 14
  • 14
29 Comments
 
LVL 7

Expert Comment

by:zwei
ID: 39915244
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

0
 
LVL 1

Author Comment

by:Tom_Hickerson
ID: 39915259
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.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39917684
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?
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39917731
How do you mount your USB device btw?
0
 
LVL 1

Author Comment

by:Tom_Hickerson
ID: 39917766
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!
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39917980
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.
0
 
LVL 1

Author Comment

by:Tom_Hickerson
ID: 39918175
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.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39918486
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
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39918810
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
0
 
LVL 1

Author Comment

by:Tom_Hickerson
ID: 39920402
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.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39920867
>> 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.
0
 
LVL 1

Author Comment

by:Tom_Hickerson
ID: 39920905
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?
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39920927
>>should I be able to type start_feh.sh into a terminal window and execute the script?
Yes, sure!
0
 
LVL 1

Author Comment

by:Tom_Hickerson
ID: 39920983
Ok.  I will have to try again tonight and write down the error message.

Thanks
0
 
LVL 1

Author Comment

by:Tom_Hickerson
ID: 39922355
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
0
 
LVL 1

Author Comment

by:Tom_Hickerson
ID: 39922540
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?
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39922976
Let me check later today. Green means the file is executable, this is OK.

./start_feh.sh should work as well.
0
 
LVL 37

Accepted Solution

by:
Gerwin Jansen earned 500 total points
ID: 39924081
Ok, this is what I have:
start feh scriptstart feh desktop
Note that it starts the pi desktop first and then after a few seconds, the slideshow is started.

Is your 'feh' in /usr/bin as well? If not, you may have to change the .sh file to match.
0
 
LVL 1

Author Comment

by:Tom_Hickerson
ID: 39924150
I'll check  tonight.  Thanks for your continued patience with me :)
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39924277
No problem :) - just having fun with RPI ...
0
 
LVL 1

Author Comment

by:Tom_Hickerson
ID: 39925468
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?
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39925778
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.
0
 
LVL 1

Author Comment

by:Tom_Hickerson
ID: 39926388
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?
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39926434
>> 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.
0
 
LVL 1

Author Comment

by:Tom_Hickerson
ID: 39926469
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.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39927693
>> 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.
0
 
LVL 1

Author Comment

by:Tom_Hickerson
ID: 39934161
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!
0
 
LVL 1

Author Closing Comment

by:Tom_Hickerson
ID: 39934172
Thanks for spending all the time helping me figure this out!
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 39934327
You're welcome ;-)
0

Join & Write a Comment

Suggested Solutions

Flask is a microframework for Python based on Werkzeug and Jinja 2. This requires you to have a good understanding of Python 2.7. Lets install Flask! To install Flask you can use a python repository for libraries tool called pip. Download this f…
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now