Part of a proper frontend system is having it automatically login as the mythtv user and loading mythfrontend. There are a variety of methods to do this. Method 1 covers using the systems initialization scripts, Method 2 uses the system's Graphical login managers like xdm/gdm/kdm allows for auto-login.

Note: The specific directories of files and programs listed below may be different for your distribution. Make sure to verify the location of these files for your system.

Method 1

The first method involves using the system's initialization scripts to automagically log in as the mythtv user (or whichever user you wish to run the MythTV frontend as) without using a graphical log in manager, and have mythfrontend launch. The user can then choose whether to use a GUI or to run "window-less".

System Boot Initialization

The standard command line login is considered a "virtual" terminal and uses a program called getty to provide the login prompt. We will replace the standard getty with an alternative, mingetty, which allows for an autologin feature. Depending on your chosen distribution one of the following setups will work for you, (may need to be slightly amended for your distribution).

mingetty vs openvt

The first method has the option of using mingetty or openvt. We will show the method for mingetty below as it requires a few extra steps. Further below we will briefly explain what needs to be modified to use openvt.

openvt has the advantage that if your distribution has a graphical boot sequence like Ubuntu, Red Hat, Mandriva, etc, you will not see any text before MythTV starts. It thus can look slightly more professional. This method also does not require the modification to the .bash_profile script.

The exact number of virtual, ttyX, terminals will vary. Here the user will either replace, or add to the list the mingetty command. The user can also at this point decide if they wish to run fewer virtual terminals. This can save valuable memory for those running on low memory systems, but the amount is small; or they can eliminate them for "aesthetic" reasons. It is not recommended to only have the one MythTV terminal as a minimum of one standard should be kept in case of emergency.

As such, one of the lines will need to look similar to,

/etc/inittab

7:12345:respawn:/sbin/mingetty --autologin=mythtv tty7

The first portion of the line, is the id for that entry. It is generally accepted that a line with a single number for the id is to designate the launch of a virtual terminal. Adding a letter, A, B, or C will cause the line to be considered OnDemand. This is left to the user to google and decide whether it is how they would like their system set up. For the sake of this exercise in use with MythTV we will omit the letter.

This line, upon reboot, will cause a virtual terminal 7 to be created and the user mythtv will automatically, with no password prompt, be logged in.

You may also need to add the following to your '/etc/login.defs' file to allow a no password login,

/etc/login.defs

NO_PASSWORD_CONSOLE tty7

event.d / init.d for ttyX

Some distributions use a system that stores scripts in their /etc/event.d or /etc/init.d directory to handle daemon initialization. Here the user will see ttyX files that correspond to their virtual terminal number.

Here the user can decide to add to the virtual terminals and create a new one, or replace an existing one, and of course able to limit the number of virtual terminals as described above, again, keeping at least one standard terminal in case of emergency.

The standard ttyX file will look like,

/etc/event.d/tty6

# tty6 - getty
#
# This service maintains a getty on tty6 from the point the system is
# started until it is shut down again.
start on runlevel 2
start on runlevel 3
stop on runlevel 0
stop on runlevel 1
stop on runlevel 4
stop on runlevel 5
stop on runlevel 6
respawn
exec /sbin/getty 38400 tty6

The new ttyX file will thus need to look like

/etc/event.d/tty2

# tty2 - mingetty for MythTV
#
# This service maintains a mingetty on tty7 from the point the system is
# started until it is shut down again.
start on runlevel 2
stop on runlevel 0
stop on runlevel 1
stop on runlevel 3
stop on runlevel 4
stop on runlevel 5
stop on runlevel 6
respawn
exec /sbin/mingetty --autologin=mythtv tty2

This line, like above, upon reboot, will cause a virtual terminal 6 to be created and the user mythtv will automatically, with no password prompt, be logged in.

As well, like above, you may also need to add the following to your '/etc/login.defs' file to allow a no password login,

/etc/login.defs

NO_PASSWORD_CONSOLE tty2

UpStart

UpStart is one of the newer initialization systems written by Canonical for use in their Ubuntu distribution, and it's sub distributions Mythbunut, Kubuntu, etc. UpStart does not use the inittab file for login terminals. UpStart, like the init system uses scripts to launch daemons, etc. The user will find ttyX.conf files in their /etc/init directory where UpStart stores these files.

Here the user can decide to add to the virtual terminals and create a new one, or replace an existing one, and of course able to limit the number of virtual terminals as described above, again, keeping at least one standard terminal in case of emergency.

The standard ttyX.conf file will look like,

/etc/init/tty6.conf

# tty6 - getty
#
# This service maintains a getty on tty6 from the point the system is
# started until it is shut down again.
start on runlevel [23]
stop on runlevel [!23]
respawn
exec /sbin/getty -8 38400 tty6

The specifics, like the runlevel, may be different depending on your specific distribution. We will assume that you have the correct runlevels if you choose a terminal script that launches upon standard boot, as the template.

Thus, to use mingetty to login your mythtv user your ttyX.conf should look similar to,

/etc/init/tty6.conf

# tty6 - getty
#
# This service maintains a getty on tty6 from the point the system is
# started until it is shut down again.
start on runlevel [23]
stop on runlevel [!23]
respawn
exec /sbin/mingetty --autologin=mythtv tty6

This line, like above, upon reboot, will cause a virtual terminal 6 to be created and the user mythtv will automatically, with no password prompt, be logged in.

As well, like above, you may also need to add the following to your '/etc/login.defs' file to allow a no password login,

/etc/login.defs

NO_PASSWORD_CONSOLE tty7

Systemd (eg, Fedora15+)

Systemd is yet another system init service. See this page for a detailed list of what you need to do to set up auto-login for systemd. Generally you probably want to follow the instructions but use tty7 or possibly tty1 depending on your system.

You'll also need to turn off prefdm so it doesn't launch, which seems difficult since it's in the default target list in the system directories in /lib that you shouldn't modify. So replacing the prefdm.service with a local definition in /etc/systemd/system may be a solution:

# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
[Unit]
Description=Display Manager
After=syslog.target livesys-late.service rc-local.service systemd-user-sessions.service
[Service]
ExecStart=/bin/true
RestartSec=0

The mythtv User

Once the user you wish to run mythfrontend as is set to automatically log in, we must prepare the users environment to actually log in and launch mythfrontend.

login shell

Some Myth-centric distributions create a mythtv user with no login shell. As such you will need to assign the user a login shell. This can be done through your distributions user editor, or via the command line as the root user (via su, sudo, etc),

usermod -s /bin/bash mythtv

.bash_profile

Once your user is automatically logged in the bash shell will look at certain files in the users home directory to modify how the shell works. We will use this to launch X via the .bash_profile file,

In that home directory, create/edit a .bash_profile file like this,

.bash_profile

if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty7 ]; then
startx
fi

this will start X only if running on virtual terminal 7, so if you telnet or ssh into the box it will not react strange. Replace tty7 with the tty you chose to use above. This will also restart X when X crashes/shutsdown due to a mythfrontend crash.

.xinitrc

When X starts it looks to the users home directory for the .xinitrc file.

fvwm

fvwm is a popular lightweight window manager. To use fvwm, edit your .xinitrc like,

# This is a sample .ratpoisonrc file
#
# Set the prefix key to that of screen's default
escape C-a
# put something informative on the screen while we load stuff
exec xloadimage -onroot -quiet -center /home/mythtv/.mythtv/mythtvstart.jpg
# Gets rid of that ugly crosshairs default cursor and set the background to black
exec xsetroot -cursor_name left_ptr
# Use the name of the program rather than the title in the window list
defwinname name
### fire up an xterm with ctrl-A x
bind x exec xterm -j -fn '*-courier-*-r-*-14-*'
# Since running a 720x576 definition the ratpoison screens are too big for the
# display so we reduce the size of them with defpadding to make them fit
#defpadding 25 25 25 25
keystate_numlock = enable

Note: The mythtvstart.jpg file is just something knocked up with the GIMP, the user can choose whichever image they wish to use.Editors Note: Can someone who runs fvwm explain what this is all doing?

Note: the 2 above tells openvt which virtual terminal number to use, so adjust it appropriately as per above

As well, like above, you may also need to add the following to your '/etc/login.defs' file to allow a no password login,

/etc/login.defs

NO_PASSWORD_CONSOLE tty2

The user should test the command above, /usr/bin/startx >& /dev/null, to verify that the the mythtv user is authorized to start the X server.
If not, modify your /etc/X11/Xwrapper.conf file to include:

allowed_users=anybody

This command will start X as the mythtv user, and much like above, will restart X automatically if MythTV or X crash. This option has the advantage that if your distribution has a graphical boot sequence like Ubuntu, Red Hat, Mandriva, etc, you will not see any text before MythTV starts. It thus can look slightly more professional. This method also does not require the modification to the .bash_profile script.

The user must still edit the .xinitrc file according to the directions above.

Distribution Specific

If a distribution requires some special modification to the above place instructions on those changes here.

Method 2

The final method is to use the standard graphical login managers such as GDM and KDM to automatically log the user in and to use the graphical window manager to launch mythfrontend. Because this method can be very distribution specific this section is broken up as such.

Generic autostart using freedesktop.org standard.

There is no standard way to auto-login a user. However, once logged in there is a standard way to launch applications defined by freedesktop.org using a desktop file in $XDG_CONFIG_DIRS/autostart. Nowadays, this works in most distributions and desktops. Also, there are standard GUI tools to maintain this file. The mechanics:

KDE Autostart

For the user which will be set to log in automatically, create a link in the users .kde/Autostart/ directory that points either to a script that will launch mythfrontend or to mythfrontend directly itself.

GDM Auto Login

GDM is the graphical login manager created for use with the Gnome windowing system.

GDM configuration

To set GDM to automatically login your mythtv user, edit your GDM configuration file, which can be found in one of various locations depending on your distribution,
/etc/gdm/custom.conf/etc/gdm/gdm.conf-custom

adding or modifying the following lines,

gdm config file

[daemon]
AutomaticLoginEnable=true
AutomaticLogin=mythtv

If you'd like to be able to login as a different user before GDM logs in your mythtv user, replace the AutomaticLogin lines in your GDM configuration with TimedLogin lines. This example will wait 10 seconds before logging in the mythtv user,

gdm config file

[daemon]
TimedLoginEnable=true
TimedLogin=mythtv
TimedLoginDelay=10

Gnome Autostart

Next, create and edit .gnomerc in the user's home folder,

.gnomerc

sleep 10 && mythfrontend > /tmp/mythfrontend.log 2>&1 &

This file needs to have specific permissions, to change them run

chmod 755 .gnomerc

from the users home directory.

NoDM auto-login

The display manager called nodm is designed exactly for embedded systems with authenticationless GUIs. It's packaged in Debian, and presumably in other distros too.

Here's my /etc/default/nodm from a Debian-based frontend:

/etc/default/nodm

# nodm configuration
# Set NODM_ENABLED to something different than 'false' to enable nodm
NODM_ENABLED=true
# User to autologin for
NODM_USER=mythtv
# First vt to try when looking for free VTs
NODM_FIRST_VT=7
# X session
NODM_XSESSION=/etc/X11/Xsession
# Options for the X server
NODM_X_OPTIONS='-nolisten tcp'
# If an X session will run for less than this time in seconds, nodm will wait an
# increasing bit of time before restarting the session.
NODM_MIN_SESSION_TIME=60

You'll need to set up the mythtv user for xsession in the usual way; here's my ~mythtv/.xsessionrc and ~mythtv/.xsession (adapt to your tastes):

Note: the autologin might remember the last session you logged in as and start that one, so if this happens you might want to login once into the custom xsession, then reboot and see if the autologin will log you into the right session.

Fedora 16

There have been conflicting reports that F16 no longer supports the /etc/gdm/custom.conf stuff above. A fresh build of Fedora 16 using the following /etc/gdm/custom.conf worked flawlessly with auto-login. Your mileage may vary.

If the above does not work as expected, Fedora 16 auto-login can be adjusted from the GUI. Invoke the System Settings | User Accounts tool from a gnome session. Using this tool, mark the mythtv user as auto-login (it's just a click). Within this GUI, F16 requires the password to be empty for auto-login to work.

Auto Login and Graphical Login

If you want to be able to easily change between auto-login and normal gdm/kdm/xdm login you can restrict the autologin to a specific runlevel and the graphical login to another.

openSUSE 10.2

If you want to be able to easily change between auto-login and normal xdm login you can restrict the autologin to eg. runlevel 3, so the auto-start line is /etc/inittab looks like this: