Friday, February 29, 2008

Auto-startup of LIRC and Elisa

The next thing I wanted to do was have all of this startup by itself when I turn on my computer. That meant making the media-user auto-login, getting LIRC to start up and then getting Elisa to start up... all automatically.

First I made it so my media-user logs in automatically at startup. I believe you can access this screen in the System menu somewhere, but the location escapes me.

So I did it this way, open a terminal and type:

sudo gdmsetup

This will bring up a window with login preferences. Select the security tab, check "Enable automatic Login" and select the media-user.

Now your media-user will auto-login when the system boots. You can always change users once you're logged in if you would like, but I just use my remote connection instead and leave the media-user logged in all the time.

The next step is to get LIRC to start up automatically. Because the command to start LIRC requires root access (sudo), you need to give yourself permission to execute the command without a password.

To do this, type the following in the terminal:

export EDITOR=gedit && sudo visudo

Change the DEFAULTs line to be:

'Defaults !lecture,tty_tickets,!fqdn,env_keep+="DISPLAY HOME"

At the very end of the file, add the following line (replacing username with your username)

username ALL = NOPASSWD: /etc/init.d/lirc start

Save and Exit.

Now go to system -> preferences -> sessions and add a new startup program. Name it LIRC or something and give it a description if you'd like. For the command use:

sudo /etc/init.d/lirc start

Now the LIRC utility will start (enabling your remote control)

In order for elisa to start automatically, you have to also add it to the session -> startup programs. However, if you just type elisa in there, it will startup before your lirc gets a chance to start up, and the remote wont work.

There may be a better way to do this, but this way works and its easy.

I wrote a simple bash script 'elisa-start' in my media-user's home directory.

vi ~/elisa-start

Add the following in the file:

#/bin/bash/
sleep 15 && elisa

This script, when executed, will wait about 15 seconds, and then execute Elisa. I don't recommend going much faster than 15 or elisa boots before LIRC initializes.

To modify the permissions on the file so everyone can access / execute the file, type:

sudo chmod 777 /home/username/elisa-start

Now go back to system -> preferences -> sessions and add another new program. Call it elisa and add a description if you'd like. For the command use (replacing username with your media-user's name):

/home/username/elisa-start

That should do it. You can try restarting X (ctrl - alt - backspace) to test if the LIRC + Elisa startup works correctly, or you can restart the computer to make sure the user auto-logs in and the LIRC and Elisa start-ups work.



Thats it! You're done! Have fun!

1 comment:

Unknown said...

Hello!
Thanks for the info I Couldn't figure it out!, but thanks to you worked perfectly.
Now, if you exit elisa, you cannot restart it from the remote, so I added, to the elisa startup script:
sleep 10 && irexec -d /home/USERNAME/.lircrc

the .lircrc file has:
begin
prog = irexec
button = POWER
config =~/scripts/elisa &
end

/scritps/elisa has this:

#!/bin/bash
# requires: wmctrl

if [ $(wmctrl -l | grep Elisa | wc -l) -gt 0 ]; then
windowId=$(wmctrl -l | grep Elisa | awk '{print $1}')
wmctrl -i -a $windowId
wmctrl -i -r $windowId -b add,fullscreen
wmctrl -i -a $windowId
else
elisa &
fi

change that file to executable, and that's it.
the only thing that I couldn't figure it out was how to start it automatically and you've done it!, lifesaver! thank you!