I've had a heck of a time figuring out how to get a program (feh, in this instance) to autostart after my Raspberry Pi auto launches into LXDE. I did finally get it working - my only excuse is I must be tired...
Not that it matters, I'm using the new raspbian distro (downloaded today, 07/19/2012), completely udpated/upgrade (sudo apt-get update
and sudo apt-get -y upgrade
)
I used the configuration utility to easily tell it to autostart into the window environment (sudo raspi-config
) then find the option for booting directly with startx & enabled it.
Then I wrote a script to launch feh (I'll do a more comprehensive post on this later, likely), left it in my home directory and named it start_feh.sh
(imaginative), with appropriate chmod +x
Next (and I assume you're doing this all from a terminal/ssh), change to your home folder's configuration folder (cd ~/.config
), and make an autostart directory (mkdir autostart
).
cd to that folder (cd autostart
), then make a *.desktop file for your script (vi feh.desktop
) with the following 3 lines:
[Desktop Entry]
Type=Application
Exec=/home/pi/start_feh.sh
That's it -- all it took. So... long story short: On your Raspberry Pi, to start a program after it launches into LXDE, make a *.desktop file in /home/[user profile]/.config/autostart
Stayman Winesap Apple Crumble (Jumbo) Muffins
4 months ago
13 comments:
tried quite a bit to get screen not to blank, finally stumbled across this post:
http://www.raspberrypi.org/phpBB3/viewtopic.php?t=11115&p=129003
sudo vi /etc/lightdm/lightdm.conf
[SeatDefaults]
xserver-command=X -s 0 -dpms
Ben,
Thanks for the post on autostarting an application after X starts. I have been working on this for a week using the previous squeeze image. I loaded Raspian yesterday, and liked how much easier it was to configure most settings, but I could make my application run after I started X as before. I was very excited when I found your post as I am also trying to run feh after boot into X. But for some reason even when I copy what you have virtually exactly I cannot make it work.
Here is my setup:
pi@raspberrypi ~ $ ls .config/autostart/
feh.desktop
pi@raspberrypi ~ $ cat .config/autostart/feh.desktop
[Desktop Entry]
Type=Application
Exec=/home/pi/show_Kewl_Pix.sh
my show_Kewl_Pix.sh script is just:
feh -z -F -D 20.0 -Y /media/HP\ v125w/Kewl
The scipt runs fine if invoked from a LXterminal AFTER the system has booted into X. I am going crazy trying to figure out what is wrong...
Any ideas?
Thanks bunches,
Mike L.
@mikey - are .config/autostart, show_Kewl_pix.sh, and feh.desktop all owned by pi? Fix:
cd ~
sudo chown -R pi:pi .config/
sudo chown pi:pi show_Kewl_pix.sh
Is the script set to execute? Fix:
cd ~
chmod +x show_Kewl_pix.sh
The only other thing that occurs to me is removing the spaces in the media folder name, although if the script works anyway that probably doesn't matter. You can always create a symlink to it that doesn't have spaces in the name & update feh script accordingly.
Can you run the script by double-clicking the feh.desktop icon? If the icon doesn't show up, you may need additional items in the file & to make a copy of it the right place to show up.
http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
Also, did you perhaps create the .desktop file in Windows (e.g., are there wrong end-of-line characters in the file?)
Thank you so very much for publishing clear and concise instructions. This has enabled me to finish a project for Christmas.
I tried several other postings that I found, but yours actually works.
Thanks again
Bart
Thanks!
Exactly what I needed for my RaspberryPi digital frame
Work great with feh and also AirPi in the background
Hi Ben,
Thanks for your post. I've nearly got this to work, by following your instructions but there is one issue.
When I log in with the default username and password for pi the feh autorun script runs fine just after x loads.
However when I have an autologin script setup so I don't have to type these credentials at boot the feh autorun fails to work.
Any suggestions gratefully appreciated
Tim
HI Ben,
Thanks for the post. This nearly works for me!
I have the pi set to boot straight into the GUI. When I log in using the default pi credentials at boot the feh autostart script executes just after the desktop loads and displays my photos.
However I wanted to avoid having to type the log in credentials at boot so I implemented autologin. Now the pi autologs in and loads the desktop but the feh autostart script no longer runs.
I can't figure out why this should be,
Any suggestions ?
MAny thanks
Tim, the only things that occur to me are that either the user got changed somehow (i.e., autologin is using one username, but your autostart is in a different spot), or perhaps the system wrote over your .config/autostart files.
Now that autologin works, I'd start from scratch and check your file permissions.
I never leave comments.
Ever.
That said, you are a genius, good sir.
After 2 days of messing with cron, /etc/rc.local and every other suggestion under the sun, I had my script running at start-up in 2 minutes thanks to you!
Thanks for your post - used this information in a recent RPi project - built a Fish feeder, you can read about it in my BLOG
http://automation-experiments.blogspot.com/2014/08/fireball-gets-personal-robot.html
Thank you for your blog entry - I have been searching for a clear answer to this, without finding one, until I came accross your website.
Thank you!
Post a Comment