Skip to main content

Python Version Project Version Documentation Status builds.sr.ht status Contributing License Platform Support

This is a python package that allows you to interact with the daemon in the Linux Infrared Remote Control package. By interacting with this daemon, it allows you to programmatically send IR signals from a computer.

This package is for emitting IR signals, but it does not support listening to IR codes. If you’d like to monitor the IR signals you recieve on Linux, which has built-in support in the kernel for recieving IR signals, you can try using python-evdev. They have a tutorial on reading the events.

More information on the lircd daemon, socket interface, reply packet format, etc. can be found at https://www.lirc.org/html/lircd.html

Maintainance Status

This project is maintained, but it is not actively developed. It is feature complete for my purposes.

Installation

This package is hosted on PyPI and can be installed through pip.

$ pip install lirc

However since this is a wrapper around the LIRC daemon, it is expected that LIRC is installed and setup on the given system as well.

More information on that can be found in the installation portion of the full documentation.

Quick Start

Using the Client

import lirc

client = lirc.Client()

print(client.version())
>>> '0.10.1'

To use this package, we instantiate a Client. By initializing it with no arguments, the Client will attempt to connect to the lirc daemon with the default connection parameters for your operating system.

These defaults depend on your operating system and can be looked up in the full documentation if you need different parameters.

However, if you’ve instantiated the Client without any arguments, you don’t get any errors, and you recieve a response from the version() command, you are connected to the daemon. Most people should not need to change the default parameters.

Customizing the Client

As previously stated, we can customize these defaults if needed.

import socket
import lirc

client = lirc.Client(
  connection=lirc.LircdConnection(
    address="/var/run/lirc/lircd",
    socket=socket.socket(socket.AF_UNIX, socket.SOCK_STREAM),
    timeout = 5.0
  )
)

For the client in the example above, we set it up using the defaults for a Linux machine. While this example illustrates what is customizable, it is not a practical example since you could call Client() with no arguments if you’re on Linux and achieve the same outcome.

See Overriding LIRC Defaults on Initialization for more information.

Sending IR

import lirc

client = lirc.Client()
client.send_once("my-remote-name", "KEY_POWER")

# Go to channel "33"
client.send_once("my-remote-name", "KEY_3", repeat_count=1)

With sending IR, we can use the send_once method and optionally, send multiple by using the repeat_count keyword argument.

Handling Errors

import lirc

client = lirc.Client()

try:
    client.send_once('some-remote', 'key_power')
except lirc.exceptions.LircdCommandFailureError as error:
    print('Unable to send the power key!')
    print(error)  # Error has more info on what lircd sent back.

If the command was not successful, a LircdCommandFailureError exception will be thrown.

Further Documentation

More information on how to setup the system installed LIRC, how to use this python library, and a full API specification can be found at https://lirc.readthedocs.io/

Metadata

Release files for lirc 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lirc 3.1.0
File Size Uploaded
lirc-3.1.0.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lirc 3.1.0
File Interpreter ABI Platform
lirc-3.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.2 kB

Release files / lirc-3.1.0.tar.gz

Download URL lirc-3.1.0.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5e2084a2f3ce3372816bbe64f42d2cf7a0753ab91a4b7e72853dbc676239477b
BLAKE2b-256 checksum
How to use checksums
d0bfc7d94375616851bf1823ff33b15f52e0deea01545a5317844129d540f7fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.3","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / lirc-3.1.0-py3-none-any.whl

Download URL lirc-3.1.0-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e486201116f998ce8ae26936a8f64c600a1cd33a85a9e20bfe43051a67a73c79
BLAKE2b-256 checksum
How to use checksums
0b3e8c47a1f6fc3cad47549a0d3b2bec1ca0e50b217ff19ec5d14b270be0c9a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.3","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

3.1.0 This release

2 release files

3.0.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page