miniHOWTO: start anyRemote at boot time and create a multimedia computer

This HOWTO supposses that You have configured anRemote before, and that it is running well together with You phone. To configure anyRemote, please look here and forward. This HOWTO describes use of anyRemote in AT-mode with this configuration file: multimedia_bt.cfgThis configuration file is prepared for my Sagem my501c phone, please modify it to suit Your phone.


Why to bother with all of this?

Well, imagine that You come home, You have Your computer switched on (or You switch it on, and go brush Your teeth), the computer automatically connects to Your mobile phone and lets You play Your favorite music, watch Your favorite videos or photos. All of this using only Your phone without even looking for a keyboard or a mouse. When You need to use Your computer as a computer, You can sit down, login with GDM (or whatever) and work as You are used to.

Sound interesting? Well, read on.. I will try to give You a hint how to do it. I did this for my own use, so take my words rather as inspiration than a throughout manual. I suppose You have good a knowledge of linux, so I will not describe every single step as for BFUs.

How do we do it then?

1. Start anyremote at boot time:

I will describe three ways how to do it, but they all have something in common. I dont think it is a good idea to run anyremote as root, I decided to run it as a regular user. To make it more clean, I created a user anyremote to take care of the stuff. I created the user as a regular desktop user with its home directory and all other stuff. We may use the home dir to place configuration files into it later.

I use this startup script /usr/local/bin/anyremote_boot to start anyremote.

For a reason unknown to me, anyremote was crushing when started without su -c.

We also need to edit /etc/sudoers file. I was not able to start a new X session via xinit if it wasnt started by root. (see section 3. What to use to watch videos and photos for details). Here is corresponding section of sudoers file:

anyremote ALL = NOPASSWD: /usr/local/bin/multimedia_Xorg, /usr/local/bin/sonata_Xorg, /sbin/halt

# User anyremote can run at all machines /usr/local/bin/tma as any user
anyremote ALL = (ALL) NOPASSWD: /usr/local/bin/tma

I will make clear the rest in sections 3. What to use to watch videos and photos for details:  and  4. Final touches:

1. using rungetty

(look for it in Your distro), and modifying /etc/inittab or /etc/event.d/tty* (depending on what distro are You using). In my case on Ubuntu Hardy 8.04 I decided to start anyremote on console 6. I edited /etc/event.d/tty6 as follows:
Using rungetty is my prefered way for two reasons. One is that it gives me information on tty6 when I need it, and the second is the nice respawn stuff.

2. using an init script

This script can be put into /etc/init.d/ (on Ubuntu) and then linked into appropriate runlevels. You can name it for example.

# INIT script to start anyremote with its configuration file to control a computer via mobile phone
# by Tomas Kaluza (elpraga at
# I made this script for me to be able to control remotelly the music on my comp
# upon entrar the room without even touching the computer...
# ... it is FAAAR from perfect as I dont know almost anything about scripting :-(
# it was cleaned by Juan Jesus Ojeda Crossier
# Thanks for help!!

DAEMON=$(which anyremote_boot)

test -x $DAEMON || exit 0

. /lib/lsb/init-functions

case "$1" in
log_begin_msg "Connecting to mobile phone via anyremote..."
start_daemon $DAEMON -a -log -f
log_end_msg $?
log_begin_msg "Disabling connection to mobile phone via anyremote..."
killall anyremote
log_end_msg $?
$0 stop
$0 start

exit 0

3. modifying /etc/rc.local

Ubuntu Hardy 8.04 can use rc.local file to save local modifications. I have modified it in this way

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

# added by Tomas Kaluza
# we shall autostart anyremote to convert our comp to a mutimedia center
# anyremote needs to be started via su
# if not started via su crasches

su -c "/usr/bin/anyremote -a -log -f /home/anyremote/.anyRemote/AT-mode/multimedia_bt.cfg" anyremote &

exit 0

I hope is is clear enough, that to start anyremote at boot time You should use only one option from the ones mentioned above :-D.

2. What to use to listen to music:

I have the best experience using mpd. It allows me to create several playlists, easily switch between them via commandline (and thus use it in a configuration file of anyremote), adjust the volume, it is stable and easy to configure, etc.. To actually rule mpd via anyremote I use mpc the commandline frontend of mpd (for details see the anyRemote configuration file multimedia_bt.cfg).

In order to be able to choose from more music without going to the computer, I am using several predefined playlists that I can switch via my mobile. My favorite tool to fill and manage the playlists is sonata. An excellent frontend for mpd, very easy to use, intuitive, cool. Since the version 1.5.1, sonata  incorporates a possibility of saving new selections into existing playlists on one click. For our purpose terrific!

3. What to use to watch videos and photos:

To watch videos and photos I am using MythTV. In order to be able to use it even when one or more users are logged in, I start a separate X session. I have only two users on my computer at the moment, so I start the X session at :5.0.

Note that the session needs to be started with a window manager as well. If not, You are not able to control mplayer when watching movies, because it does not receive keyboard focus. I have selected fluxbox to use, becuse it it very light and allows me to configure shortcuts very easily. It allows me to use separate configuration when starting MythTV, and I can set a simple shortcut to exit fluxbox (and X) which does interfere with my configuration for daily use.

I start it via /usr/local/bin/multimedia_Xorg. It needs to be started as root, othervise xinit does not start X, that is why it is added into /etc/sudoers file.


# note that I am starting fluxbox_mythtv script as user tomas
# because I have mythtv cofigured best under that user.
# Please use the apropriate user for Your mythtv configuration
# just to make sure, we set the DISPLAY variable
# Tomas Kaluza

export DISLAY

exec xinit /bin/su -c /usr/local/bin/fluxbox_mythtv tomas -- /usr/bin/Xorg :5
And here is the file /usr/local/bin/fluxbox_mythtv:
# We shall make sure that we are using the propper display:
export DISPLAY

# We are using fluxbox with a particular configuration file
# thus we can reserve a key conbination 55 to exit fluxbox withour any fear
# that it will surprise us when writing text
# we also add following line in ~/.fluxbox/init_multimedia
# session.screen0.rootCommand: ~/.fluxbox/autostart_multimedia
# and the file autostart_multimedia says:
# ------------
# #!/bin/bash
# mythfrontend
# -----------
# Thus we start mythtvfrontend when fluxbox starts. Please note, that mythtv must be
# properly configured before.
# and we also use a specific key file for this fluxbox in init_multimedia...
# session.keyFile: ~/.fluxbox/keys_multimedia
# and in keys_multimedia we add this line
# 5 5 :Quit
# .. and thus we can quit from fluxbox (and thus mythtv) and also X by pressing
# 55 on the phone keypad

# Please note, that in my case I am starting Xorg (in /usr/local/multimedia_Xorg)
# and fluxbox as user tomas with appropriate configuration files.
# You should change the location of the configuration file and the user to Your needs
# Tomas Kaluza

exec /usr/bin/fluxbox -rc /home/tomas/.fluxbox/init_multimedia

4. Final touches:

Because I like to listen to music at night in my bed, I found it useful to be able to switch off the monitor with my phone. I do it via /usr/local/bin/tma file: Because the commands run by anyRemote are executed by a user anyremote, /usr/local/bin/tma needs to be in /etc/sudoers as well. It switches off the monitor both when I am logged in a regular session (if I am logged as first user - most of the times) and my especial phone session (every time).

Well, and because sonata is really my favourite, I added this to be able to select songs into playlists without logging in. (/usr/local/bin/sonata_Xorg) I believe, it is not necessary to cut and paste fluxbox_sonata, You can get it very easily by editing fluxbox_mythtv file.

I hope someone will find this tip useful as much as I found useful anyRemote...

Tomáš Kaluža

About · Download · Documentation · FrontEnds · Contacts ·