Difference between revisions of "Frontend Auto Login"

From MythTV Official Wiki
Jump to: navigation, search
(fvwm)
(48 intermediate revisions by 18 users not shown)
Line 1: Line 1:
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. KDM allows for auto-login, but doesn't handle mythfrontend crashes well. The best method is  to use inittab to login the user straight into mythfrontend.  
+
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.
  
== Setup ==
+
''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.''
First you will need to make sure you have mingetty installed. Next, make sure you have a dedicated user to run the mythfrontend with a home directory.
 
  
== inittab ==
+
= Method 1 =
Add the following line to your '/etc/inittab' file,
+
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.
 +
 
 +
=== inittab ===
 +
'''inittab''' is one of the older initialization systems for SysV.
 +
 
 +
Initiall your inittab will look like,
 
{{Code box|/etc/inittab|
 
{{Code box|/etc/inittab|
 
<pre>
 
<pre>
c7:12345:respawn:/sbin/mingetty --autologin=mythtv tty7
+
# inittab for linux
 +
id:1:initdefault:
 +
rc::bootwait:/etc/rc
 +
1:1:respawn:/etc/getty 9600 tty1
 +
2:1:respawn:/etc/getty 9600 tty2
 +
3:1:respawn:/etc/getty 9600 tty3
 +
4:1:respawn:/etc/getty 9600 tty4
 +
</pre>
 +
}}
 +
 
 +
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,
 +
{{Code box|/etc/inittab|
 +
<pre>
 +
7:12345:respawn:/sbin/mingetty --autologin=mythtv tty7
 +
</pre>
 +
}}
 +
 
 +
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,
 +
{{Code box|/etc/login.defs|
 +
<pre>
 +
NO_PASSWORD_CONSOLE tty7
 +
</pre>
 +
}}
 +
 
 +
=== 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,
 +
{{Code box|/etc/event.d/tty6|
 +
<pre>
 +
# 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
 +
</pre>
 +
}}
 +
 
 +
The new ttyX file will thus need to look like
 +
{{Code box|/etc/event.d/tty2|
 +
<pre>
 +
# 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
 +
</pre>
 +
}}
 +
 
 +
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,
 +
{{Code box|/etc/login.defs|
 +
<pre>
 +
NO_PASSWORD_CONSOLE tty2
 
</pre>
 
</pre>
 
}}
 
}}
This is what will login the mythtv user.
 
  
== Option 1 ==
+
=== UpStart ===
Now we will setup the mythtv user,
+
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,
 +
{{Code box|/etc/init/tty6.conf|
 +
<pre>
 +
# 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
 +
</pre>
 +
}}
 +
 
 +
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,
 +
{{Code box|/etc/init/tty6.conf|
 +
<pre>
 +
# 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
 +
</pre>
 +
}}
 +
 
 +
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,
 +
{{Code box|/etc/login.defs|
 +
<pre>
 +
NO_PASSWORD_CONSOLE tty7
 +
</pre>
 +
}}
 +
 
 +
=== Systemd (eg, Fedora15+) ===
 +
 
 +
Systemd is yet another system init service.  See [http://fedoraproject.org/wiki/Systemd#How_do_I_set_automatic_login_on_a_virtual_console_terminal.3F 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 ===
 
=== .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,
 
In that home directory, create/edit a .bash_profile file like this,
 
{{Code box|.bash_profile|
 
{{Code box|.bash_profile|
 
<pre>
 
<pre>
 
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty7 ]; then
 
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty7 ]; then
while [ 1 == 1 ]
+
    startx
    do
 
          startx
 
          sleep 10
 
    done
 
 
fi
 
fi
 
</pre>
 
</pre>
 
}}
 
}}
this will start X only if running on virtual terminal 7, so if you telnet or ssh
+
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.
into the box it will not react strange. It will also restart X if the frontend
 
crashes.
 
  
 
=== .xinitrc ===
 
=== .xinitrc ===
There are two options for .xinitrc, one will load a window manager, the other will not.
+
When X starts it looks to the users home directory for the ''.xinitrc'' file.
 
 
==== No Window Manager ====
 
For no windowmanager, create/edit the user's .xinitrc and add,
 
{{Code box|.xinitrc|
 
<pre>
 
xset -dpms s off
 
xsetroot -solid black
 
mythfrontend -l /home/mythtv/mythfrontend.log
 
#mythtv-setup
 
#xterm
 
</pre>
 
}}
 
This will turn off dpms, turn the X default background color black and log to /home/mythtv/mythfrontend.log, this can be changed. Also included is an easy way to access mythtv-setup or xterm, just uncomment the appropriate line and comment out the mythfrontend line.
 
 
 
''You should note that running mythfrontend without a window manager is not a supported configuration.  You may run into focus problems when trying to press buttons, enter text and generally use the system.''
 
  
 
==== fvwm ====
 
==== fvwm ====
To use fvwm, edit your .xinitrc like,
+
fvwm is a popular lightweight window manager. To use fvwm, edit your ''.xinitrc'' like,
 
{{Code box|.xinitrc|
 
{{Code box|.xinitrc|
 
<pre>
 
<pre>
 
xset -dpms s off
 
xset -dpms s off
 
xsetroot -solid black
 
xsetroot -solid black
x11vnc -many -q -bg -rfbauth .vnc/passwd
 
 
fvwm2 &
 
fvwm2 &
 
mythfrontend -l /home/mythtv/mythfrontend.log 2>&1
 
mythfrontend -l /home/mythtv/mythfrontend.log 2>&1
Line 65: Line 213:
 
}}
 
}}
  
Next edit your .fvwm2rc,
+
Next edit your ''.fvwm2rc'',
 
{{Code box|.fvwm2rc|
 
{{Code box|.fvwm2rc|
 
<pre>
 
<pre>
 
#Set Windows Styles
 
#Set Windows Styles
Style "*" RandomPlacement, DumbPlacement
+
Style "*" CascadePlacement
 
Style myth* NoTitle, NoHandles, Sticky, WindowListSkip, SloppyFocus, GrabFocus,  
 
Style myth* NoTitle, NoHandles, Sticky, WindowListSkip, SloppyFocus, GrabFocus,  
 
BorderWidth 0, HilightFore Black, HilightBack #c06077, Color Black/#60a0c0
 
BorderWidth 0, HilightFore Black, HilightBack #c06077, Color Black/#60a0c0
Line 87: Line 235:
 
</pre>
 
</pre>
 
}}
 
}}
 +
 +
{{Code box|.fvwm2rc|
 +
<pre>
 +
Style &lt;Window Title&gt; &lt;Style Settings&gt;
 +
</pre>
 +
}}
 +
 +
The Window Title can be any valid window title, with * as a multiple character wildcard. Quotation marks must be used around titles that include spaces. ("Myth*" would match "Myth TV" as well as "MythA" but not "mythtv" or "MyMyth")
 +
 +
* CascadePlacement style (formerly RandomPlacement and DumbPlacement styles) places new windows in a cascading fashion.
 +
* NoTitle, NoHandles, BorderWidth 0, HilightFore Black, HilightBack #c06077, and Color Black/#60a0c0 all work together to remove window decorations (title bar, window edges, etc.).
 +
* WindowListSkip removes windows from the WindowList (most window managers access this list by pressing alt-tab).
 +
* Sticky forces windows to remain visible on screen.
 +
* SloppyFocus and GrabFocus work to cause windows to take focus when the mouse passes over them.
 +
* StaysOnTop forces the window to the top layer (default top layer is layer number 6).
 +
 +
For more information, visit [http://www.fvwm.org/documentation/manpages/ the FVWM Man Pages] or directly [http://www.fvwm.org/documentation/manpages/stable/fvwm.php FVWM version 2.6.5].
  
 
==== ratpoison ====
 
==== ratpoison ====
Another popular window manager is ratpoison. This version of the .xinitrc file also allows you to use vnc to connect to your frontend (as the fvwm example above) and rotates the log files at each restart of the frontend.
+
Another popular lightweight window manager is ratpoison. To use ratpoison, edit your ''.xinitrc'' like,
 +
 
 
{{Code box|.xinitrc|
 
{{Code box|.xinitrc|
 
<pre>
 
<pre>
Line 95: Line 261:
 
xsetroot -solid black
 
xsetroot -solid black
 
ratpoison &
 
ratpoison &
x11vnc -many -q -bg -rfbauth .vnc/passwd
 
 
mythfrontend > /home/mythtv/mythfrontend.log 2>&1
 
mythfrontend > /home/mythtv/mythfrontend.log 2>&1
for i in 5 4 3 2 1 ; do
 
  if [ -f mythfrontend.log.$i ]; then
 
    mv -f mythfrontend.log.$i  mythfrontend.log.$(($i + 1))
 
  fi
 
done
 
mv mythfrontend.log  mythfrontend.log.1
 
 
</pre>
 
</pre>
 
}}
 
}}
  
And the associated .ratpoisonrc file. Note that the mythtvstart.jpg file is just something knocked up with the GIMP.
+
And the associated .ratpoisonrc file,
 +
 
 
{{Code box|.ratpoisonrc|
 
{{Code box|.ratpoisonrc|
 
<pre>
 
<pre>
Line 134: Line 294:
 
}}
 
}}
  
== Option 2 ==
+
''Note: The mythtvstart.jpg file is just something knocked up with the GIMP, the user can choose whichever image they wish to use.''
If the above instructions don't give you results you like, there is another option to autologin.  You can use inittab to login as the mythtv user and launch X all at once, without having to create a .bash_profile script.
+
''Editors Note: Can someone who runs fvwm explain what this is all doing?''
  
Find the following line in your /etc/inittab file:|
+
==== openvt====
6:2345:respawn:/sbin/getty 38400 tty6
+
Where above you see the use of ''mingetty',
And comment it out by adding the "#" symbol in front of it:
+
  /sbin/mingetty --autologin=mythtv tty6
  #6:2345:respawn:/sbin/getty 38400 tty6
+
the user can use ''openvt'' by using,
Then add this line directly under the line you just commented out:
+
  /bin/openvt -fwc 2 -- /bin/su - mythtv -c /usr/bin/startx >& /dev/null
  6:2345:respawn:/usr/bin/openvt -fwc 2 -- /bin/su - mythtv -c /usr/bin/startx >& /dev/null
 
  
Note: you should test the command 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:
+
''Note: the 2 above tells openvt which virtual terminal number to use, so adjust it appropriately. This is described further below.''
 +
 
 +
You may also need to add the following to your '/etc/login.defs' file to allow a no password login,
 +
{{Code box|/etc/login.defs|
 +
<pre>
 +
NO_PASSWORD_CONSOLE tty2
 +
</pre>
 +
}}
 +
 
 +
The command, ''/usr/bin/startx >& /dev/null'', should be tested 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
 
  allowed_users=anybody
  
This command starts X as the mythtv user, and will restart X automatically if MythTV crashes.  This option has the advantage that if your distribution has a graphical boot sequence like Ubuntu, Red Hat, Mandriva, etc, then you won't see any text before Myth starts.  It looks a little more professional.  This also means that you don't have to create a .bash_profile script.  Edit your .xinitrc file according to the directions above and you are done.
+
==== Optional ====
 +
The user can choose to add some extra functionality to their ''.xinitrc'', some popular options are,
  
Some may prefer this method of logging in and starting X to the method above because X prefers to use tty 7 and the method above may cause problems.
+
===== VNC =====
 +
Adding the following before mythfrontend will allow the user to connect to the machine via VNC. Proper setup of VNC is left to the user to manage.
 +
x11vnc -many -q -bg -rfbauth .vnc/passwd
  
=== Note on inittab option 2  and runlevels ===
+
===== log rotation =====
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:
+
Ideally the user will use the lograte daemon, ''logrotated'', to rotate their log files. If this method does not please the user another option is to add the following before launching mythfrontend,
  6:3:respawn:/usr/bin/openvt -fwc 2 -- /bin/su - mythtv -c /usr/bin/startx >& /dev/null
+
{{Code box|.xinitrc|
 +
<pre>
 +
for i in 5 4 3 2 1 ; do
 +
  if [ -f mythfrontend.log.$i ]; then
 +
    mv -f mythfrontend.log.$i  mythfrontend.log.$(($i + 1))
 +
  fi
 +
done
 +
</pre>
 +
}}
 +
 
 +
== openvt ==
 +
Where above we used mingetty, this method uses openvt, and as such, where above you see
 +
/sbin/mingetty --autologin=mythtv tty6
 +
this method will use
 +
  /bin/openvt -fwc 2 -- /bin/su - mythtv -c /usr/bin/startx >& /dev/null
 +
 
 +
''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,
 +
{{Code box|/etc/login.defs|
 +
<pre>
 +
NO_PASSWORD_CONSOLE tty2
 +
</pre>
 +
}}
  
The default runlevel specification in inittab can then be set to 3 for auto-login or 5 for X-login.
+
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.
  id:3:initdefault:            # auto-login to MythTv
+
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:
 +
 
 +
Create a desktop file, something like
 +
{{Code box|mythtv desktop file|
 +
<pre>
 +
[Desktop Entry]
 +
Encoding=UTF-8
 +
Name=mythTV frontend
 +
Comment=Record, playback and watch TV.
 +
Icon=mythfrontend.png
 +
Exec=sh -c "pasuspender mythfrontend; pkill xfce4-session"
 +
Terminal=false
 +
Type=Application
 +
X-Desktop-File-Install-Version=0.16
 +
Categories=AudioVideo;Application;X-Fedora-Extra;
 +
</pre>
 +
}}
 +
 
 +
Install the file in ~/.config/autostart. If you are using lirc, you might consider creating similar file(s) to autostart irexec and/or lircmd.
 +
 
 +
== KDM Auto Login ==
 +
KDM is the graphical login manager created for use with the KDE windowing system.
 +
 
 +
=== KDM configuration ===
 +
To set KDM to automatically login your mythtv user, edit your KDM configuration file, ''/etc/kde3/kdm/kdmrc'' or ''/usr/share/config/kdm/kdmrc'', to modify or include the following lines,
 +
 
 +
{{Code box|kdmrc|
 +
<pre>
 +
[X-:0-Core]
 +
AutoLoginDelay=10
 +
AutoLoginEnable=true
 +
AutoLoginAgain=true
 +
AutoLoginUser=mythtv
 +
</pre>
 +
}}
 +
 
 +
''AutoLoginDelay'' and ''AutoLoginAgain'' are optional, but recommended if you are allowing other users to log in normally.
 +
 
 +
=== 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.  When exiting mythfrontend, the user will be left at the normal KDE desktop.
 +
 
 +
Instead, if you wish to skip the KDE desktop and window manager entirely, create ''~/.xprofile'' and ''~/.xsession'' files in the user's home directory. This method, combined with ''AutoLoginAgain=true'', will restart MythTV automatically upon crashes:
 +
 
 +
{{Code box|.xprofile|
 +
<pre>
 +
# Tell kdm to use the custom session in ~/.xsession
 +
session=custom
 +
</pre>
 +
}}
 +
 
 +
{{Code box|.xsession|
 +
<pre>
 +
#! /bin/bash
 +
# Start minimal window manager in background
 +
evilwm &
 +
# ratpoison &
 +
# startfluxbox &
 +
# starte16 &
 +
# Start mythfrontend as the controlling instance
 +
mythfrontend
 +
</pre>
 +
}}
  
If you have booted in auto-login mode and want to change to X-login mode you can just change run level with the init command:
+
Make sure ''~/.xsession'' is executable!
/sbin/init 5
 
or back to mythtv mode with:
 
/sbin/init 3
 
  
=== Note on Ubuntu Edgy (6.10) ===
+
== GDM Auto Login ==
 +
GDM is the graphical login manager created for use with the Gnome windowing system.
  
[[Image:Important.png]] As of Ubuntu Edgy, inittab is no longer an option for an automatic login setup. However, you can use Gnome to automatically login and run mythfrontend. Note that this option requires Gnome and X.
+
=== 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''
  
First, edit your /etc/gdm/gdm.conf-custom file:
+
adding or modifying the following lines,
{{Code box|/etc/gdm/gdm.conf-custom|
+
{{Code box|gdm config file|
 
<pre>
 
<pre>
 
[daemon]
 
[daemon]
Line 176: Line 448:
 
}}
 
}}
  
Next, create and edit .gnomerc in the user's home folder:
+
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,
  
touch /home/mythtv/.gnomerc
+
{{Code box|gdm config file|
 +
<pre>
 +
[daemon]
 +
TimedLoginEnable=true
 +
TimedLogin=mythtv
 +
TimedLoginDelay=10
 +
</pre>
 +
}}
 +
 
 +
=== Gnome Autostart ===
 +
Next, create and edit ''.gnomerc'' in the user's home folder,
 +
{{Code box|.gnomerc|
 +
<pre>
 +
sleep 10 && mythfrontend > /tmp/mythfrontend.log 2>&1 &
 +
</pre>
 +
}}
 +
 
 +
This file needs to have specific permissions, to change them run
 
  chmod 755 .gnomerc
 
  chmod 755 .gnomerc
  
Now edit this file and add the following line:
+
from the users home directory.
  
sleep 10 && mythfrontend > /tmp/mythfrontend.log 2>&1 &
 
  
=== Note on Ubuntu Gutsy (7.10) through Hardy Heron (8.04) ===
+
== NoDM auto-login ==
[[Image:Important.png]] This method has been verified on all newer releases of (K/Myth)Ubuntu up to Hardy Heron LTS. This method is similar to the inittab method above and requires mingetty and a .bash_profile and .xinitrc file in the mythtv users' home directory.
+
The display manager called [http://enricozini.org/sw/nodm/ nodm] is designed exactly for embedded systems with authenticationless GUIs.  It's packaged [http://packages.debian.org/nodm in Debian], and presumably in other distros too.
  
First copy /etc/event.d/tty6 to /etc/event.d/tty7 change it from:
+
Here's my /etc/default/nodm from a Debian-based frontend:
  
{{Code box|/etc/event.d/tty7|
+
{{Code box|/etc/default/nodm|
 
<pre>
 
<pre>
# tty6 - getty
+
# nodm configuration
#
+
 
# This service maintains a getty on tty6 from the point the system is
+
# Set NODM_ENABLED to something different than 'false' to enable nodm
# started until it is shut down again.
+
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
 +
</pre>
 +
}}
 +
 
 +
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):
 +
{{Code box|~mythtv/.xsessionrc|
 +
<pre>
 +
# -*- shell-script -*-
 +
# Sourced as:
 +
#  /bin/sh
 +
#    /etc/X11/Xsession
 +
#     /etc/X11/Xsession.d/40x11-common_xsessionrc
  
start on runlevel 2
+
# Timezone
start on runlevel 3
+
TZ=Europe/London; export TZ
  
stop on runlevel 0
+
# Tell Qt to anti-alias text
stop on runlevel 1
+
QT_XFT=1; export QT_XFT
stop on runlevel 4
 
stop on runlevel 5
 
stop on runlevel 6
 
  
respawn
+
# Don't start ssh-agent
exec /sbin/getty 38400 tty6
+
SSHAGENT=
 
</pre>
 
</pre>
 
}}
 
}}
  
to
+
{{Code box|~mythtv/.xsession|
{{Code box|/etc/event.d/tty7|
 
 
<pre>
 
<pre>
# tty7 - mingetty for MythTV
+
# -*- shell-script -*-
#
+
# Sourced as:
# This service maintains a mingetty on tty7 from the point the system is
+
# /bin/sh
# started until it is shut down again.
+
#   /etc/X11/Xsession
 +
#      /etc/X11/Xsession.d/99x11-common_start
 +
 
 +
xsetroot -solid blue
 +
 
 +
(
 +
    xset -dpms s off
 +
    sleep 3                    # Give frontend some CPU
 +
 
 +
    # Keyboard
 +
    setxkbmap \
 +
        -types "complete" \
 +
        -compat "complete+ledscroll(group_lock)" \
 +
        -symbols "pc+us(dvorak)+group(shifts_toggle)+ctrl(nocaps)+inet(logiex110)" \
 +
        -geometry "pc(pc105)"
  
start on runlevel 2
+
    exec fvwm
 +
) &
  
stop on runlevel 0
+
(
stop on runlevel 1
+
    sleep 5                    # Give frontend some CPU
stop on runlevel 3
+
    killall -u $USER irexec
stop on runlevel 4
+
    exec irexec
stop on runlevel 5
+
) &
stop on runlevel 6
 
  
respawn
+
exec mythfrontend
exec /sbin/mingetty --autologin=mythtv tty7
 
 
</pre>
 
</pre>
 
}}
 
}}
  
This will only run on the Ubuntu Gutsy default runlevel of 2 allowing the user to switch to runlevel 3 to disable MythTV but still maintain a GUI setup
+
Set up your preferred window manager as described in [[#The mythtv User]] above.
  
== Option 3 ==
+
== Distribution Specific Notes ==
 +
=== Ubuntu 12.04 LTS ===
 +
Ubuntu 12.04 uses LightDM by default.
  
Configure a Login Manager to login automatically as a default user. Then configure your desktop (KDE or GNOME) to autostart a program like mythfrontend.  To deal with mythfrontend crashes, I would suggest that you run a wrapper around mythfrontend like
+
Create a new file /usr/share/xsessions/custom.desktop with:
  
while true; do mythfrontend; sleep 5s; done
+
<pre>
 +
[Desktop Entry]
 +
Name=Xsession
 +
Exec=/etc/X11/Xsession
 +
</pre>
  
=== KDM Auto Login ===
+
You should now have a new session option during login, Xsession will load the user's ~/.xsession file
For the default user, create a link in ~/.kde/Autostart that points either to the script listed above (or some other script that starts the front end) or merely to mythfrontend itself.  The system will now log in automatically, and immediately start the frontend.
 
  
=== Frontend Auto Login with Fedora Core 5 and GNOME / GDM ===
+
edit /etc/lightdm/lightdm.conf
  
To set GDM to auto-login your mythtv user, edit your GDM configuration:
+
<pre>
 +
[SeatDefaults]
 +
autologin-guest=false
 +
autologin-user=username
 +
autologin-user-timeout=0
 +
autologin-session=lightdm-autologin
 +
user-session=Xsession
 +
greeter-session=unity-greeter
 +
</pre>
  
  vi /etc/gdm/custom.conf
+
For mythbuntu change the last two lines to:
  
Add the following lines to the [daemon] section:
+
<pre>
 +
greeter-session=lightdm-gtk-greeter
 +
user-session=mythbuntu
 +
</pre>
 +
 
 +
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.
 +
 
 +
Create a .xsession in your homedir:
  
 
<pre>
 
<pre>
[daemon]
+
xset -dpms s off
AutomaticLoginEnable=true
+
xsetroot -sold black
AutomaticLogin=mythtv
+
/usr/bin/mythfrontend &
 +
exec /usr/bin/blackbox
 
</pre>
 
</pre>
  
Then, set the $HOME/.xsession file for your mythtv user to start mythwelcome:
+
chmod +x .xsession
 +
 
 +
=== Fedora Core 5 - GDM ===
 +
Older GDM requires the use of the users .xsession file.
  
  vi ~mythtv/.xsession
+
Set the ''~/.xsession'' file for your mythtv user to start mythwelcome.
  
An example, which will start the Metacity window manager, an xterm (which you can start with F12 from mythwelcome) and finally, mythwelcome itself.
+
An example ''~/.xsession'' file , which will start the Metacity window manager, an xterm (which you can start with F12 from mythwelcome) and finally, mythwelcome itself is shown here:
  
 
[[Image:Important.png]] '''Note:''' If mythwelcome dies for some reason, GDM will restart it.
 
[[Image:Important.png]] '''Note:''' If mythwelcome dies for some reason, GDM will restart it.
Line 277: Line 625:
 
   chmod 755 ~mythtv/.xsession
 
   chmod 755 ~mythtv/.xsession
  
If you'd like to be able to login as a different user before GDM logs in your mythtv user,
+
=== Fedora Core ===
replace the AutomaticLogin lines in your GDM configuration with TimedLogin lines.
+
 
 +
Fedora Core 6 uses a script to let you choose which login manager to use.  If no default is given it uses xdm.  You can set the default by creating a file called ''/etc/sysconfig/desktop'' and adding
 +
DISPLAYMANAGER="KDE"
 +
or
 +
DISPLAYMANAGER="GNOME"
 +
 
 +
==== KDE ====
 +
Once this file is there then you can set the auto login from within KDE like so:
 +
# Click on the K menu.
 +
# In the K menu, click on Control Center.
 +
# When the control center screen appers there is a list of options to pick. Select the System option.
 +
# The System menu will expand and give a list of sub menus - click on Login Manager.
 +
# When the login manager is displayed there are tabs that you can select Appearance/Font/Background/Sessions/Users/Convenience. Click on the Convenience tab.
 +
# Go to the Automatic Login box, you will see there is 2 check boxes and a drop down menu. Click Enable Auto-login. Select user from the drop down menu.
 +
# Click the Apply button down on the bottom right.
 +
# Close window. The automatic login process will take effect when you restart your computer.
 +
 
 +
==== GDM / Gnome ====
 +
You can specify the window manager of your choice and the programs executed on starting X Windows in your own ''~/.xsession'' file. In order to ensure your own ''~/.xsession'' is executed you need to
 +
# Click the Sessions menu at the bottom of the GDM automatic login screen
 +
# Select "User script"
  
This example will wait 10 seconds before logging in the mythtv user.
+
This will force the execution of ''~/.xsession'' file.
 +
''Note: You may have to click a username first in the login window in order to get the menu bar to display at the bottom of the GDM auto-login screen.''
 +
 
 +
==== LightDM ====
 +
Create a new file /usr/share/xsessions/custom.desktop with:
  
 +
<pre>
 +
[Desktop Entry]
 +
Name=Xsession
 +
Exec=/etc/X11/Xsession
 +
</pre>
 +
 +
You should now have a new session option during login, Xsession will load the user's ~/.xsession file
 +
 +
=== Fedora 9 ===
 +
 +
In /etc/gdm/custom.conf in the [daemon] section ensure you have the following lines present (subsitute "myth" for your mythtv user).
 
<pre>
 
<pre>
 
[daemon]
 
[daemon]
 
TimedLoginEnable=true
 
TimedLoginEnable=true
TimedLogin=mythtv
+
TimedLoginDelay=5
TimedLoginDelay=10
+
AutomaticLoginEnable=true
 +
AutomaticLogin=myth
 +
TimedLogin=myth
 +
RemoteGreeter=/usr/libexec/gdmgreeter
 
</pre>
 
</pre>
  
=== Frontend Auto Login with Kubuntu / KDM ===
+
=== Fedora 16 ===
  
To set KDM to auto-login your mythtv user, edit your KDM configuration:
+
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.
  
  sudo vi /etc/kde3/kdm/kdmrc
+
<pre>
 +
# GDM configuration storage
  
Go to (almost) the bottom of the file and edit the next lines:
+
[daemon]
 +
AutomaticLoginEnable=true
 +
AutomaticLogin=mythtv
 +
 
 +
[security]
 +
 
 +
[xdmcp]
 +
 
 +
[greeter]
 +
 
 +
[chooser]
 +
 
 +
[debug]
  
<pre>
 
[X-:0-Core]
 
AutoLoginDelay=0
 
AutoLoginEnable=true
 
AutoLoginUser=mythtv
 
 
</pre>
 
</pre>
  
=== Frontend Auto Login for Fedora and KDE ===
+
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.
  
Fedora Core 6 uses a script to let you choose which login manager to use.  If no default is given it uses xdm.  You can set the default by creating a file called /etc/sysconfig/desktop and adding DISPLAYMANAGER="KDE" or DISPLAYMANAGER="GNOME".  Once this file is there then you can set the auto login from within KDE like so:
+
= Auto Login and Graphical Login =
# Click on the K menu.
+
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.
# In the K menu, click on Control Center.
+
 
# When the control center screen appers there is a list of options to pick. Select the System option.
+
== openSUSE 10.2 ==
# The System menu will expand and give a list of sub menus - click on Login Manager.
+
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:
# When the login manager is displayed there are tabs that you can select Appearance/Font/Background/Sessions/Users/Convenience. Click on the Convenience tab.
 
# Go to the Automatic Login box, you will see there is 2 check boxes and a drop down menu. Click Enable Auto-login. Select user from the drop down menu.
 
# Click the Apply button down on the bottom right.
 
# Close window. The automatic login process will take effect when you restart your computer.
 
  
=== Frontend Auto Login for Fedora 9 ===
+
{{Code box|/etc/inittab|
 +
<pre>
 +
6:3:respawn:/usr/bin/openvt -fwc 2 -- /bin/su - mythtv -c /usr/bin/startx >& /dev/null
 +
</pre>
 +
}}
 +
The default runlevel specification in inittab can then be set to 3 for auto-login or 5 for X-login.
  
If Fedora 9 seems to ignore any changes to /etc/inittab try making the changes in /etc/event.d/ttyX.
+
{{Code box|/etc/inittab|
(Not sure what directs using /etc/inittab versus /etc/event.d)
 
 
<pre>
 
<pre>
exec /sbin/mingetty --autologin mythtv tty1
+
id:3:initdefault:            # auto-login to MythTv
 
</pre>
 
</pre>
=== Frontend Auto Login for openSUSE 10.2 ===
+
}}
 +
 
 +
If you have booted in auto-login mode and want to change to X-login mode you can just change run level with the init command:
 +
 
 +
/sbin/init 5
 +
 
 +
or back to mythtv mode with:
 +
 
 +
/sbin/init 3
 +
 
 
[[Image:Geeko_head48.png|25px]] see the [[Opensuse_10.2]] page
 
[[Image:Geeko_head48.png|25px]] see the [[Opensuse_10.2]] page
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]

Revision as of 20:53, 11 January 2013

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.

inittab

inittab is one of the older initialization systems for SysV.

Initiall your inittab will look like,

Script.png /etc/inittab

# inittab for linux
id:1:initdefault:
rc::bootwait:/etc/rc
1:1:respawn:/etc/getty 9600 tty1
2:1:respawn:/etc/getty 9600 tty2
3:1:respawn:/etc/getty 9600 tty3
4:1:respawn:/etc/getty 9600 tty4

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,

Script.png /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,

Script.png /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,

Script.png /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

Script.png /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,

Script.png /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,

Script.png /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,

Script.png /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,

Script.png /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,

Script.png .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,

Script.png .xinitrc

xset -dpms s off
xsetroot -solid black
fvwm2 &
mythfrontend -l /home/mythtv/mythfrontend.log 2>&1
#mythtv-setup
#xterm

Next edit your .fvwm2rc,

Script.png .fvwm2rc

#Set Windows Styles
Style "*" CascadePlacement
Style myth* NoTitle, NoHandles, Sticky, WindowListSkip, SloppyFocus, GrabFocus, 
BorderWidth 0, HilightFore Black, HilightBack #c06077, Color Black/#60a0c0
Style xmame* NoTitle, NoHandles, Sticky, WindowListSkip, SloppyFocus, GrabFocus, 
BorderWidth 0, StaysOnTop,BoundaryWidth 0, HilightFore Black, HilightBack #c06077, 
Color Black/#60a0c0
Style mplayer* NoTitle, NoHandles, Sticky, WindowListSkip, SloppyFocus, GrabFocus, 
BorderWidth 0, HilightFore Black, HilightBack #c06077, Color Black/#60a0c0
Style xine* NoTitle, NoHandles, Sticky, WindowListSkip, SloppyFocus, GrabFocus, 
BorderWidth 0, HilightFore Black, HilightBack #c06077, Color Black/#60a0c0

#set the desk top size in units of physical screen size
DeskTopSize 1X1

# Starts mythfrontend from the keyboard using F1
Key F1  R   A   exec /usr/local/bin/mythfrontend -v important,general -l /var/log/mythfrontend.log 2>&1


Script.png .fvwm2rc

Style <Window Title> <Style Settings>

The Window Title can be any valid window title, with * as a multiple character wildcard. Quotation marks must be used around titles that include spaces. ("Myth*" would match "Myth TV" as well as "MythA" but not "mythtv" or "MyMyth")

  • CascadePlacement style (formerly RandomPlacement and DumbPlacement styles) places new windows in a cascading fashion.
  • NoTitle, NoHandles, BorderWidth 0, HilightFore Black, HilightBack #c06077, and Color Black/#60a0c0 all work together to remove window decorations (title bar, window edges, etc.).
  • WindowListSkip removes windows from the WindowList (most window managers access this list by pressing alt-tab).
  • Sticky forces windows to remain visible on screen.
  • SloppyFocus and GrabFocus work to cause windows to take focus when the mouse passes over them.
  • StaysOnTop forces the window to the top layer (default top layer is layer number 6).

For more information, visit the FVWM Man Pages or directly FVWM version 2.6.5.

ratpoison

Another popular lightweight window manager is ratpoison. To use ratpoison, edit your .xinitrc like,


Script.png .xinitrc

xset -dpms s off
xsetroot -solid black
ratpoison &
mythfrontend > /home/mythtv/mythfrontend.log 2>&1

And the associated .ratpoisonrc file,


Script.png .ratpoisonrc

# 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?

openvt

Where above you see the use of mingetty',

/sbin/mingetty --autologin=mythtv tty6

the user can use openvt by using,

/bin/openvt -fwc 2 -- /bin/su - mythtv -c /usr/bin/startx >& /dev/null

Note: the 2 above tells openvt which virtual terminal number to use, so adjust it appropriately. This is described further below.

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

Script.png /etc/login.defs

NO_PASSWORD_CONSOLE tty2

The command, /usr/bin/startx >& /dev/null, should be tested 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

Optional

The user can choose to add some extra functionality to their .xinitrc, some popular options are,

VNC

Adding the following before mythfrontend will allow the user to connect to the machine via VNC. Proper setup of VNC is left to the user to manage.

x11vnc -many -q -bg -rfbauth .vnc/passwd
log rotation

Ideally the user will use the lograte daemon, logrotated, to rotate their log files. If this method does not please the user another option is to add the following before launching mythfrontend,

Script.png .xinitrc

for i in 5 4 3 2 1 ; do
  if [ -f mythfrontend.log.$i ]; then
    mv -f mythfrontend.log.$i  mythfrontend.log.$(($i + 1))
  fi
done

openvt

Where above we used mingetty, this method uses openvt, and as such, where above you see

/sbin/mingetty --autologin=mythtv tty6

this method will use

/bin/openvt -fwc 2 -- /bin/su - mythtv -c /usr/bin/startx >& /dev/null

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,

Script.png /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:

Create a desktop file, something like

Script.png mythtv desktop file

[Desktop Entry]
Encoding=UTF-8
Name=mythTV frontend
Comment=Record, playback and watch TV.
Icon=mythfrontend.png
Exec=sh -c "pasuspender mythfrontend; pkill xfce4-session"
Terminal=false
Type=Application
X-Desktop-File-Install-Version=0.16
Categories=AudioVideo;Application;X-Fedora-Extra;

Install the file in ~/.config/autostart. If you are using lirc, you might consider creating similar file(s) to autostart irexec and/or lircmd.

KDM Auto Login

KDM is the graphical login manager created for use with the KDE windowing system.

KDM configuration

To set KDM to automatically login your mythtv user, edit your KDM configuration file, /etc/kde3/kdm/kdmrc or /usr/share/config/kdm/kdmrc, to modify or include the following lines,


Script.png kdmrc

[X-:0-Core]
AutoLoginDelay=10
AutoLoginEnable=true
AutoLoginAgain=true
AutoLoginUser=mythtv

AutoLoginDelay and AutoLoginAgain are optional, but recommended if you are allowing other users to log in normally.

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. When exiting mythfrontend, the user will be left at the normal KDE desktop.

Instead, if you wish to skip the KDE desktop and window manager entirely, create ~/.xprofile and ~/.xsession files in the user's home directory. This method, combined with AutoLoginAgain=true, will restart MythTV automatically upon crashes:


Script.png .xprofile

# Tell kdm to use the custom session in ~/.xsession
session=custom


Script.png .xsession

#! /bin/bash
# Start minimal window manager in background
evilwm &
# ratpoison &
# startfluxbox &
# starte16 &
# Start mythfrontend as the controlling instance
mythfrontend

Make sure ~/.xsession is executable!

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,

Script.png 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,


Script.png gdm config file

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

Gnome Autostart

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

Script.png .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:


Script.png /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):

Script.png ~mythtv/.xsessionrc

# -*- shell-script -*-
# Sourced as:
#  /bin/sh
#    /etc/X11/Xsession
#      /etc/X11/Xsession.d/40x11-common_xsessionrc

# Timezone
TZ=Europe/London; export TZ

# Tell Qt to anti-alias text
QT_XFT=1; export QT_XFT

# Don't start ssh-agent
SSHAGENT=


Script.png ~mythtv/.xsession

# -*- shell-script -*-
# Sourced as:
#  /bin/sh
#    /etc/X11/Xsession
#      /etc/X11/Xsession.d/99x11-common_start

xsetroot -solid blue

(
    xset -dpms s off
    sleep 3                     # Give frontend some CPU

    # Keyboard
    setxkbmap \
        -types "complete" \
        -compat "complete+ledscroll(group_lock)" \
        -symbols "pc+us(dvorak)+group(shifts_toggle)+ctrl(nocaps)+inet(logiex110)" \
        -geometry "pc(pc105)"

    exec fvwm
) &

(
    sleep 5                     # Give frontend some CPU
    killall -u $USER irexec
    exec irexec
) &

exec mythfrontend

Set up your preferred window manager as described in #The mythtv User above.

Distribution Specific Notes

Ubuntu 12.04 LTS

Ubuntu 12.04 uses LightDM by default.

Create a new file /usr/share/xsessions/custom.desktop with:

[Desktop Entry]
Name=Xsession
Exec=/etc/X11/Xsession

You should now have a new session option during login, Xsession will load the user's ~/.xsession file

edit /etc/lightdm/lightdm.conf

[SeatDefaults]
autologin-guest=false
autologin-user=username
autologin-user-timeout=0
autologin-session=lightdm-autologin
user-session=Xsession
greeter-session=unity-greeter

For mythbuntu change the last two lines to:

greeter-session=lightdm-gtk-greeter
user-session=mythbuntu

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.

Create a .xsession in your homedir:

xset -dpms s off
xsetroot -sold black
/usr/bin/mythfrontend &
exec /usr/bin/blackbox

chmod +x .xsession

Fedora Core 5 - GDM

Older GDM requires the use of the users .xsession file.

Set the ~/.xsession file for your mythtv user to start mythwelcome.

An example ~/.xsession file , which will start the Metacity window manager, an xterm (which you can start with F12 from mythwelcome) and finally, mythwelcome itself is shown here:

Important.png Note: If mythwelcome dies for some reason, GDM will restart it.

Script.png ~mythtv/.xsession

#!/bin/bash
metacity &
xterm &
mythwelcome

Make sure to make it executeable:

 chmod 755 ~mythtv/.xsession

Fedora Core

Fedora Core 6 uses a script to let you choose which login manager to use. If no default is given it uses xdm. You can set the default by creating a file called /etc/sysconfig/desktop and adding

DISPLAYMANAGER="KDE"

or

DISPLAYMANAGER="GNOME"

KDE

Once this file is there then you can set the auto login from within KDE like so:

  1. Click on the K menu.
  2. In the K menu, click on Control Center.
  3. When the control center screen appers there is a list of options to pick. Select the System option.
  4. The System menu will expand and give a list of sub menus - click on Login Manager.
  5. When the login manager is displayed there are tabs that you can select Appearance/Font/Background/Sessions/Users/Convenience. Click on the Convenience tab.
  6. Go to the Automatic Login box, you will see there is 2 check boxes and a drop down menu. Click Enable Auto-login. Select user from the drop down menu.
  7. Click the Apply button down on the bottom right.
  8. Close window. The automatic login process will take effect when you restart your computer.

GDM / Gnome

You can specify the window manager of your choice and the programs executed on starting X Windows in your own ~/.xsession file. In order to ensure your own ~/.xsession is executed you need to

  1. Click the Sessions menu at the bottom of the GDM automatic login screen
  2. Select "User script"

This will force the execution of ~/.xsession file. Note: You may have to click a username first in the login window in order to get the menu bar to display at the bottom of the GDM auto-login screen.

LightDM

Create a new file /usr/share/xsessions/custom.desktop with:

[Desktop Entry]
Name=Xsession
Exec=/etc/X11/Xsession

You should now have a new session option during login, Xsession will load the user's ~/.xsession file

Fedora 9

In /etc/gdm/custom.conf in the [daemon] section ensure you have the following lines present (subsitute "myth" for your mythtv user).

[daemon]
TimedLoginEnable=true
TimedLoginDelay=5
AutomaticLoginEnable=true
AutomaticLogin=myth
TimedLogin=myth
RemoteGreeter=/usr/libexec/gdmgreeter

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.

# GDM configuration storage

[daemon]
AutomaticLoginEnable=true
AutomaticLogin=mythtv

[security]

[xdmcp]

[greeter]

[chooser]

[debug]

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:


Script.png /etc/inittab

6:3:respawn:/usr/bin/openvt -fwc 2 -- /bin/su - mythtv -c /usr/bin/startx >& /dev/null

The default runlevel specification in inittab can then be set to 3 for auto-login or 5 for X-login.


Script.png /etc/inittab

id:3:initdefault:             # auto-login to MythTv

If you have booted in auto-login mode and want to change to X-login mode you can just change run level with the init command:

/sbin/init 5

or back to mythtv mode with:

/sbin/init 3

Geeko head48.png see the Opensuse_10.2 page