Linux - HOW-TO make XBMC for Linux auto start on Ubuntu

  Thread Rating:
  • 5 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
MrCerulean Offline
Junior Member
Posts: 4
Joined: Oct 2008
Reputation: 0
Thumbs Up  HOW-TO make XBMC for Linux auto start on Ubuntu
Post: #1
I built a media centre PC specifically to run XBMC on Linux. I'm using the PPA's on Hardy Heron (8.04). Since this box is only going to run XBMC, I thought I'd get it to power up, log in and fire up XBMC automatically.

Keep in mind that these steps are for Ubuntu. Other distro's may differ.

Login as the user who installed XBMC. I find it easier to do all this from my laptop, ssh'd in to the XBMC box.

Using your favourite editor, create a file in your home directory called .xinitrc that contains the following:
Code:
#!/bin/bash
exec /usr/bin/xbmc --standalone

Make .xinitrc executable:
Code:
chmod +x .xinitrc

Edit your .bashrc and add the following as the last line:
Code:
startx

Install rcconf:
Code:
sudo apt-get install rcconf

Run rcconf and turn off gdm:
Code:
sudo rcconf

Install mingetty:
Code:
sudo apt-get install mingetty

Edit /etc/events.d/tty1:
Code:
sudo vi /etc/events.d/tty1

Change the line:
Code:
exec /sbin/getty 38400 tty1
to read:
Code:
exec /sbin/mingetty --autologin uname tty1
where uname is the user who installed XBMC.

Reboot to test.

With this setup, you're not loading gdm or gnome. You're not loading a window manager. The load will be lighter and the boot process will be faster.

Please let me know if there are any questions! Thanks to AlTheKiller for some pointers.
(This post was last modified: 2013-01-11 14:58 by zag.)
find quote
malloc Offline
Team-XBMC Developer
Posts: 1,062
Joined: May 2004
Reputation: 0
Post: #2
great howto. this would be great in the wiki. ask pike for ninja status if you'd like to contribute it and you need write access.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
find quote
althekiller Offline
Team-XBMC Developer
Posts: 4,926
Joined: May 2004
Reputation: 12
Post: #3
Looks good. I would however edit .bash_login instead of .bashrc and/or wrap launching startx with an "if x`pidof X` = ''x" ; then startx; fi" (or similar) to stop launching multiple instances if you open an xterm or login another tty.
find quote
QuietTime Offline
Junior Member
Posts: 15
Joined: Mar 2008
Reputation: 0
Post: #4
Forgive me for being a linux noob, but where should the first file you create (.xinitrc) be located?
find quote
MrCerulean Offline
Junior Member
Posts: 4
Joined: Oct 2008
Reputation: 0
Post: #5
The .xinitrc file should be in your home directory. I'll clarify that...
find quote
proctor Offline
Senior Member
Posts: 113
Joined: Aug 2008
Reputation: 0
Post: #6
Anyone know what to check to find out why I lose my sound when I set XBMC to autostart? The sound works if i go back to gdm.
find quote
MrCerulean Offline
Junior Member
Posts: 4
Joined: Oct 2008
Reputation: 0
Post: #7
Try renaming your .xinitrc to off.xinitrc (mv .xinitrc off.xinitrc). Reboot the system. You should wind up in a terminal logged in as your XBMC user. Run alsamixer and see if all the sound points are turned on.

To restore XBMC startup, mv off.xinitrc .xinitrc and reboot again.
find quote
covert Offline
Junior Member
Posts: 25
Joined: Mar 2004
Reputation: 0
Post: #8
My Ubuntu auto logs me in (mythbuntu). This is the default file that starts MythTV. Easy to change it to start XBMC..

~/.config/autostart/mythtv.desktop
Code:
[Desktop Entry]
Name=MythTV Frontend
Comment=A frontend for all content on a mythtv-backend
GenericName=MythTV Viewer
Exec=mythfrontend --service
Type=Application
Encoding=UTF-8
Icon=/usr/share/mythtv/themes/blue/myth_tv_logo.png
Categories=GNOME;Application;AudioVideo;Audio;Video
X-AppInstall-Package=mythtv
find quote
Chaos_666 Offline
Senior Member
Posts: 147
Joined: Sep 2008
Reputation: 11
Location: Germany
Post: #9
Hi there
Great Howto, thats exactly how i solved this problem, before there was this howto.

But what happens if you press the Off Button on the remote or shuts it down via menu?
Here it quits xbmc but stays in X?!

Anyone knows a solution for that?

THX
Chaos
find quote
proctor Offline
Senior Member
Posts: 113
Joined: Aug 2008
Reputation: 0
Post: #10
MrCerulean Wrote:Try renaming your .xinitrc to off.xinitrc (mv .xinitrc off.xinitrc). Reboot the system. You should wind up in a terminal logged in as your XBMC user. Run alsamixer and see if all the sound points are turned on.

To restore XBMC startup, mv off.xinitrc .xinitrc and reboot again.

Thanks, I booted to terminal and found out that my user 'xbmc' was not a member of the 'audio' group.

I did: sudo adduser xbmc audio

Restarted and everything works as advertised.
find quote
MrCerulean Offline
Junior Member
Posts: 4
Joined: Oct 2008
Reputation: 0
Post: #11
Covert: Yes, but the point to the howto is starting XBMC without gdm or a window manager or a desktop environment--in other words, the minimum required X setup.
find quote
QuietTime Offline
Junior Member
Posts: 15
Joined: Mar 2008
Reputation: 0
Post: #12
Thanks for the clarification. I've been hoping someone would post an easy way to do this. Works like a charm!
find quote
covert Offline
Junior Member
Posts: 25
Joined: Mar 2004
Reputation: 0
Post: #13
MrCerulean. I only scanned over our post and completely missed the fact it does not use a manager. Are you able to edit the title for clarification ?
find quote
covert Offline
Junior Member
Posts: 25
Joined: Mar 2004
Reputation: 0
Thumbs Up  [LINUX] HOW TO auto start XBMC for Linux on Ubuntu Desktop
Post: #14
Who is this for: If you run Ubuntu that boots into Xorg and you want xbmc to auto start every time. This should work for most Ubuntu desktop installs. This is the most basics of howto's and should be new user friendly.

Note: If you auto login then you will not need to do anything but turn the system on. Very WAF.

Step 1. Get into a terminal. Either by ssh (log in as needed) or selecting Application->Accessories->Terminal from the menu.

Step 2. Change to your home directory.
Code:
cd ~

Step 3. Now change to the auto start directory for this user.
Code:
cd .config/autostart
Output should look like this
user@computer:~/.config/autostart$

Step 4. Launch a text editor to edit xbmc.desktop
Code:
nano xbmc.desktop

Steop 5. Copy and paste the following into the xbmc.desktop file and save.
Change the Exec command as needed. ~ means your home directory. So ~/.xbmc is the same as /home/yourusername/.xbmc
Code:
[Desktop Entry]
Encoding=UTF-8
Version=Beta2
Type=Application
Name=Launch XBMC on startup
Comment=XBMC will run every time this user logs in.
Exec=~/.xbmc/xbmc.bin
StartupNotify=false
Terminal=false
Hidden=false

Note: shift-ins for paste

Done.
find quote
tomsun Offline
Junior Member
Posts: 10
Joined: Aug 2008
Reputation: 0
Post: #15
Or just go to session, and make a new entry. Browse to the binary. And it will start when you login or have autologin

--
/t
find quote
Post Reply