summaryrefslogtreecommitdiffstats
path: root/README.rst
blob: 27a629be82f009ba25d249f4680060465777f31c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
LIRC Python Package
===================

.. image:: https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8-blue
   :alt: Python Version
.. image:: https://img.shields.io/pypi/v/lirc
   :target: https://pypi.org/project/lirc/
   :alt: Project Version
.. image:: https://readthedocs.org/projects/lirc/badge/?version=latest
  :target: https://lirc.readthedocs.io/en/latest/?badge=latest
  :alt: Documentation Status
.. image:: https://github.com/eugenetriguba/lirc/workflows/python%20package%20ci/badge.svg?branch=master
  :target: https://github.com/eugenetriguba/lirc/actions/
  :alt: Build Status
.. image:: https://codecov.io/gh/eugenetriguba/lirc/graph/badge.svg
  :target: https://codecov.io/gh/eugenetriguba/lirc
  :alt: Code Coverage
.. image:: https://img.shields.io/pypi/l/lirc.svg
   :target: https://pypi.python.org/pypi/lirc/
   :alt: License

This is a python package that allows you to interact with the daemon in the
`Linux Infrared Remote Control <https://lirc.org>`_ package. Interacting with
the daemon allows you to be able to send IR signals from computer.

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

Installation
------------

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

.. code-block:: bash

  $ 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 <./installation.html>`_ portion
of the documentation.

Using the Lirc Package
----------------------

.. code-block:: python

  from lirc import Lirc

  lirc = Lirc()
  response = lirc.version()

  print(response.command)
  >>> 'VERSION'
  print(response.success)
  >>> True
  print(response.data)
  >>> ['0.10.1']

To get started with the package, we import ``Lirc`` and can
initialize it with the defaults by passing it no arguments.

This will assume a socket path of ``/var/run/lirc/lircd``.
Furthermore, this will also then assume a socket connection
using ``AF_UNIX`` and ``SOCK_STREAM``. These are both the defaults
that should work on a Linux system. There are ports of LIRC
to Windows and macOS but using the package there is far less
common. However, both of these are configurable through options
passed to ``Lirc`` to allow it to be used on those operating systems
as well.

After sending any command to the LIRC daemon, this package will create
a ``LircResponse`` for us that it returns. That response contains the
command we sent to LIRC, whether it was successful, and any data that
was returned back to us.

Further documentation and a full API specification is available at
https://lirc.readthedocs.org