Mon 2 Jun 2003
I hacked a script together to get Mythtv to auto start and autologin with FVWM2, the startup services from the Mythtv documents and the FVWM2 config.
I was not happy with the KDE autologin and wanted to use a light weight windows manager. I found an article in the archives here but I could not get the openvt to auto login on Mandrake 9.1. I did some googling and found an article at LawLUG that almost worked. I put the two together and got this.
Using your favorite text editor create a file named autologinmythtv.c and type in this short C program:
int main() {
execlp( “login”, “login”, “-f”, “mythtv”, 0);
}
* I uses mythtv as the user on my system *
The execlp system call invokes the command “login -f mythtv” and replaces the current processing context with this invocation. The man page for login describes the action of the -f argument. Compile this tiny C program using the GNU C-compiler:
$ gcc -o autologinmythtv autologinmythtv.c
Gain root privileges (using su) and copy the executable to /usr/local/bin:
# cp autologinmythtv /usr/local/bin/
Next edit your /etc/inittab and change
1:2345:respawn:/sbin/mingetty tty1
to
1:2345:respawn:/sbin/agetty -n -l /usr/local/bin/autologinmyth 38400 tty1
Here is the script to add to the user mythtv .bash_profile
/home/mythtv/.bash_profile
if [ -z “$DISPLAY” ] && [ $(tty) == /dev/vc/1 ]
then
while [ 1 ]; do
startx
sleep 5
done
fi
This basically checks to make sure it is ok to start X by checking you are local and on the first virtual console.
This allows us to still log in on other terminals and remote in without X getting in the way. Next we create and endless loop that starts X and mythfrontend with the FVWM config files xinitrc and fvwmrc. Then if myth crashes or you need to reset, just ALT-CTRL-Backspace and X will restart after 5 seconds. This way my Wife does not have to login and mess on the command line to get MythTV going when I am not around.
Hope this helps someone out there.
Cheers…
One Response to “Autostarting and respawning Mythtv”
Leave a Reply
You must be logged in to post a comment.

December 4th, 2003 at 11:24 pm
Hi, I used these instructions and it’s working for me after a few changes. The function:
execlp( “login”, “login”, “-f”, “mythtv”, 0);
didn’t look right based on the man page for execlp, so I changed it to not have two “login” params, and then it would ask me for a password, so I figure it was cause my login like the -f parameter. I’m on Gentoo, btw. I emerged tinylogin and changed the call to execlp like this:
execlp( “tinylogin”, “login”, “-f”, “mythtv”, 0);
Figured I’d post what worked for me in case others might need to do the same.