linux mania

অগাষ্ট 5, 2006

more tips on using LIRC

যার অধীনে আছে: Linux — pipasharto @ 11:08 am

Applications and LIRC Support

There are three kinds of applications:

  1. Those which could and actually have been built with LIRC support. These act as LIRC clients when there is a running LIRC daemon.
  2. Those which do support LIRC, but have not been compiled with the LIRC support enabled.
  3. Those which do not support LIRC at all.

Generally, most multimedia applications, video and audio players, TV viewers and FM tuner applications, support LIRC. Also, many applications provide a method (separate utility or options) to send commands to a running instance of the application. This is particularly useful for programs that belong to the 2nd and 3rd categories. LIRC provides an utility, called irexec (LIRC client), which can be used to execute any command we want. This way, those applications can be controlled with the remote control through LIRC.

In order to use our remote control with a certain application, we have to create a configuration file that contains the mappings between the remote control’s buttons and the commands that will be executed when each button is pressed.

This file can be:

  • named .lircrc and placed in the user’s home directory.
  • named lircrc (without the period in front of the name) and placed in the /etc/ directory for system-wide configuration.

Information about this file’s format can be found in the relevant section of the LIRC Documentation.

Quick Tests

Here are some sample .lircrc files, so that you can test your installation. Make sure you have loaded the proper LIRC module and you have started the LIRC daemon. Save one of them as .lircrc and place it in your home directory.

Special Note: In the following sample config files, substitute the remote control name with the name you have used for your own remote control and the button name with a name of any of your own remote control’s buttons.

The first two samples will work with Xine and MPlayer respectively. These two players are usually built with LIRC support and, when launched, they act as LIRC clients.

Load Xine and press the specified button on your remote control. It should toggle between full-screen and window-mode.

# .lircrc - XINE sample test
begin
    prog = xine
    remote = KWTV878RF
    button = ZOOM
    config = ToggleFullscreen
    repeat = 0
end

Use the following config with MPlayer.

# .lircrc - MPLAYER sample test
begin
    prog = mplayer
    remote = KWTV878RF
    button = ZOOM
    config = vo_fullscreen
    repeat = 0
end

For applications that are not LIRC clients themselves, but which provide a method to send commands to a running instance of the application, the configuration is a bit different. The LIRC client irexec is used in these cases. When you press a button on the remote control, irexec executes the specified command. This requires that irexec is running. Start it as a user:

# irexec

Save the following as .lircrc and launch TVtime. The specified button on the remote control should toggle between full-screen and window-mode.

# .lircrc - TVtime sample test
begin
    prog = irexec
    remote = KWTV878RF
    button = ZOOM
    config = tvtime-command TOGGLE_FULLSCREEN
    repeat = 0
end

To start irexec and have it run in the background, start it as shown below:

# irexec &

To kill it:

# killall irexec

Some hints for more complicated configurations

Here are some hints for those of you who need complicated setups.

Toggle Buttons

You can create toggle buttons, for example you can set the same button to Play or Pause a video stream, by setting two config = command directives. They will be executed in turns. For example:

# Toggle button example
begin
    prog = irexec
    remote = remoteA
    button = buttonA
    config = play_command
    config = pause_command
    repeat = 0
end

Using this configuration, when buttonA is pressed for the first time, the play_command is executed. The second time buttonA is pressed, the pause_command is executed.

Modes

Let’s assume that you want to control many applications with your remote control. Some of them are LIRC clients and some are controlled through irexec. You can define various modes (groups of button to command mappings), one for each application.

First of all, read the .lircrc format page from the LIRC Documentation very carefully.

Keep in mind the following rule:

Each time you start a LIRC client and there is a mode within your configuration with a name equal to the application’s name, then this mode is automatically entered.

This means that if there is a mode named mplayer inside .lircrc and you start the mplayer program, which is a LIRC client, then the mplayer mode is automatically entered and only the button mappings that exist within this mode are functional.

Save the following as ~/.lircrc, substitute the remote control name and button names with your own, and start irexec:

# Example with modes

# MAIN BEGIN (irexec mode) - Application Selection Mode
# ---------------

begin irexec

begin
        prog   = irexec
        remote = KWTV878RF
        button = 1
        # Start TVtime
        config = tvtime --window &
        # Enter tvtime mode
        mode = tvtime
    end

begin
        prog   = irexec
        remote = KWTV878RF
        button = 2
        # Start Totem player and play DVD
        config = totem dvd:/ &
        # Enter totem mode
        mode = totem
    end

begin
        prog   = irexec
        remote = KWTV878RF
        button = 3
        # Start Xine and play DVD
        config = xine dvd:/ --hide-gui &
        # Enter xine mode
        mode = xine
    end

end irexec

# ---------------
# MAIN END (irexec mode end)

# APP MODES BEGIN
# ---------------

# tvtime mode
begin tvtime
    begin
        prog = irexec
        button = POWER
        config = tvtime-command QUIT
        # Enter irexec mode
        mode = irexec
    end
    begin
        prog = irexec
        button = ZOOM
        config = tvtime-command TOGGLE_FULLSCREEN
    end
end tvtime

# totem mode
begin totem
    begin
        prog = irexec
        button = POWER
        config = totem --quit
        # Enter irexec mode
        mode = irexec
    end
    begin
        prog = irexec
        button = ZOOM
        config = totem --fullscreen
    end
end totem

# xine mode
begin xine
    begin
        prog = xine
        button = POWER
        config = Quit
        # Enter irexec mode
        mode = irexec
    end
    begin
        prog = xine
        button = ZOOM
        config = ToggleFullscreen
    end
end xine

# ---------------
# APP MODES END

I hope this example is clear enough. What is going on here is that when irexec (LIRC client) is executed, then the irexec mode is entered. When you press button “1″, then TVtime is launched and the tvtime mode is entered. When you press the “POWER” button, TVtime quits and the irexec mode is entered etc. etc.

Furthermore, even if you do not start irexec, when you launch any LIRC enabled application, like Xine, MPlayer, Gnomeradio etc, then the appropriate mode will be entered automatically and you will be able to control this application remotely.

As you have probably already read in the LIRC Documentation, you can modularize this configuration by keeping each application mode in a separate file. Just don’t forget to include those separate files by adding a line like the following in ~/.lircrc. For example:

include ~/.lirc/tvtime.lircrc

Final Notes

Maybe you will need some time to familiarize yourself with the .lircrc format and probably more time reading the LIRC documentation, but you will be satisfied with the result.

For information about what commands are available for each application, please refer to the application’s documentation, project web site or support forum.

Also, if you need more information or support for LIRC, please ask your questions in relevant web forums. I have written all I know in this guide, so I am afraid I cannot help you more.

LIRC can do more things, for example it can be used to transmit IR signals or to connect to other LIRC servers accross the network. These have not been covered, not only because I consider such info as “too much” for a new user, but also because I have not been able to devote any time to experiment with these features.

This guide was written while using a Fedora 4 system.

Further Reading

You should read:

  1. The LIRC Manual (Documentation)

getting LIRC to work in fedora core 4

যার অধীনে আছে: Linux — pipasharto @ 9:36 am

Hey,

I have set up lirc in my box. heres a little touch what i have done.

1. download lirc from www.lirc.org

2. run setup.sh
choose your driver ( i built my own ir reciever and attached that to com port 1, it is the default in the configuration script, some thing like driver:serial irq:4 io:0×3f8)

3. choose save and run configure

remember:

u must have kernel code installed in /usr/src and before compiling lirc, do as root: make oldconfig && make dep

4. make
5. make install

now your lirc is installed. :)

6. check $ls -l /dev/li*

it will look like:

lr-xr-xr-x 1 root root 5 Jan 27 09:00 /dev/lirc -> ttyS0
srw-rw-rw- 1 root root 0 Jan 27 15:01 /dev/lircd=
prw-r–r– 1 root root 0 Jan 27 09:00 /dev/lircm|

As you can see, there’s a link from /dev/lirc to ttyS0, a.k.a. “COM1″

Some IR receivers (including some homebrew units) use a character device as their data interface as opposed to a link to a serial port. If the make install step has created a character device for you, don’t replace it with a link to a COM port.

So, if the link or character device was not created (but should have been), ensure that you ran the make install step as root. If it still doesn’t work, re-read the lirc documentation to determine whether your IR receiver is a character device or should be a link to a serial port and to create the link/character device manually. My IR device is connected to ttyS0. If it were connected to “COM2″, then use ttyS1, etc.

$ su
# cd /dev
# ln -sf ttyS0 lirc
# exit
$

note: The above example assumes that your receiver uses the standard serial driver. Some receivers do not. Check the lirc documentation, but it may be necessary to replace the link created above with a character pipe:

# mknod /dev/lirc c 61 0

See the lirc documentation for additional information. The lirc installation should create this for you, so manually creating it indicates that your lirc installation may have other issues.

7. Now you should adjust the file permissions of /dev/lircd (this is the Unix domain socket that clients use to connect to lircd) so others than root can connect to lircd.

chmod 666 /dev/lircd

8. If your hardware requires a kernel module you should make sure that the kernel will find the correct module if a program tries to access /dev/lirc. This can be done by inserting the following line to your /etc/modprobe.conf):

alias char-major-61 lirc_serial

9. you can set the IRQ and I/O base the serial port drivers shall use by adding the following line to /etc/modprobe.conf:

options lirc_serial irq=4 io=0×3e8

This will override the default values you have selected during setup. The configure script will tell you which kernel module you need. (if u select com1 during setup, but wants to change it later)

10. now run $mode2, and press any button of your remote, u will see some raw codes, space pulse :) , its done.

Note: if that doesnt work, run $modprobe lirc_serial, if it says that device busy then do the following

#setserial /dev/ttyS0 uart none

Then you have to load the kernel module:
#modprobe lirc_serial

After that, load the deamon:
#lircd

And test the reception of commands:
#irw

Press some buttons on your remote, it must appear on the screen.

i assume u have the correct remote configuration in /etc/lircd.conf. if u dont, use irrecord to have one.

now everything will be fine.
enjoy.

shahrear

জুলাই 28, 2006

Installing fedora 4 on your x86 : some Tips

যার অধীনে আছে: Linux — pipasharto @ 7:05 am

Installing linux is very easy now a days, but after installing we may face a lot of problems. Here i solved some problems for normal users.

I use fedora distros, use the link : http://stanton-finley.net/fedora_core_4_installation_notes.html

to configure ur linux after installing. means enabling mp3 support, java, flash, etc..

Problems and Solutions:

1)XMMS and Rhythmbox sometimes say that check output plugin when u open them and click on a song, second time clicking on the same song works just fine.

sol: install alsa-oss and select oss as output plugin in both xmms->pref and gstreamer-config (if u have

alsa mixer installed for ur sound card)

2)in fedora 4, java plugin dont work, theres lot of solutions over net, but nothing will work on a default fedora 4, bcoz of the ugly selinux. i recommend u have a tar.gz version of firefox, and run it from a shell

and see what error it gives if u try to run a applet. rpm versions turn off the verbose mood.

sol: update selinux-policy-targeted. all will be fine. (some other problem will automatically fix as a bonus, best thing is to disable selinux and use only firewall for personal use )
3)to install amule or some other, u need to update ur libstdc++, never try a rpm solution, u will have to install a total of 10 other packages to update that.

sol: use yum to update.

4)new users have a lot of problems using the samba server. here i put a short step by step guide for fedora 4 .

sol:

1)install three packages : samba, samba-common, samba-client. u need to enable some port (netbios ports) if u have installed firewall. do this:

/sbin/iptables -I INPUT -i eth0 -p udp -m multiport –dports 137,138 -j ACCEPT
/sbin/iptables -I INPUT -i eth0 -p tcp -m multiport –dports 139,445 -j ACCEPT
/etc/init.d/iptables save

also, go to selinux setting and allow smb, that is disable selinux protection on smbd(samba daemon)

2)use Desktop->system setting->server->samba to add share

3)now we need samba user, here is the critical part if u dont want to have any of the messages like

NT_STATUS_LOGON_FAILURE

who is samba user: any unix user

so to add samba user, add a unix user first

#useradd

#passwd

now remember u will use this username to access samba server, but not this password, u have to setup samba password for every samba user, so..

#smbpasswd -a unixuser

now we have a samba user

4) try something like this smbclient -L LOCALHOST -U%

u will see:

Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.14a-2]

Sharename Type Comment
——— —- ——-
anyfilmhind Disk
IPC$ IPC IPC Service (Shahrear’s Samba Server)
ADMIN$ IPC IPC Service (Shahrear’s Samba Server)
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.14a-2]

Server Comment
——— ——-
DOMINATE Tansirul’s Computer
I-R-I-S
KRIPTON
LOCALHOST Shahrear’s Samba Server
SADIK
SAMYCON farid
SHABU
ZAKARIA

Workgroup Master
——— ——-
HOME ARIF-COMPUTER1
WORKGROUP LOCALHOST
something like this.

5) to access a share, say anyfilmhind do this

#smbclient //<netbiosname>//anyfilmhind -U<unix user on this machine>

password:<samba pass for that unix user>

smb:> :) done

Hope this will help.

shahrear

Blog at WordPress.com.