MODE2(1)
β¨ MODE2(1) β¨
okay bestie, gather round π this is mode2 from the lirc fam (version 0.10.2, if you were wondering), and it's literally the tool you use to peek at what the kernel is handing over for LIRC drivers. it's giving "let me see what my IR receiver is actually doing" and honestly? iconic.
πΈ NAME πΈ
mode2 β show kernel output available for LIRC drivers
π SYNOPSIS π
mode2 --driver <driver> [--device <device>] [other options]
mode2 --raw --device <device> [other options]
mode2 --driver <driver> --list-devices
π DESCRIPTION π
so the original reason this program exists? checking that your home-brew LIRC receiver hardware actually works, and staring at the IR waveform from your remote without having to drop cash on an expensive oscilloscope. no cap. over time though, mode2 grew up and became a whole generic tool for checking what kind of output the kernel is making available for lirc. glow-up fr fr β¨
mode2 will simply print pulse and space lengths to stdout for drivers supporting LIRC_MODE_MODE2. for drivers supporting LIRC_MODE_LIRCCODE β think TV-cards and the irman driver β it writes the decoded, integer values instead.
from version 0.9.4 onward, mode2 can also list the devices available for a given driver π¦. this needs enumeration support, which is present in most but not all drivers. (iykyk.)
when you give it the correct driver, mode2 should always work. without a driver, the --raw option should always work for /dev/lirc* devices. at the time of writing, usb devices also work in most cases β but the path to the usb device is tricky to get, so those are normally best accessed using a driver.
and psa: not all drivers require a device.
π OPTIONS π
-d --device=deviceβ read from the given device.-H --driver=driverβ use the given driver.-m --modeβ write pulse/space data as raw config files. does not affectLIRCCODEdrivers.-s --scope=timeβ turn on a 'scope-like display with time in us per char. does not affect lirccode drivers.-k --keep-rootβ don't drop root privileges after opening the device. go read RUNNING AS ROOT below, bestie.-l --list-devicesβ list all available devices for the given driver. needs support that isn't present in all drivers, so it might just not vibe.-g --gap=timeβ treat spaces longer than time as the gap. time is in microseconds.-r --rawβ access the device directly. this is primarely intended to be used with kernel rc drivers i .e., when accessing/dev/lirc*devices. using other devices might work, but is in general undefined π.-A --driver-options=key:value[|key:value...]β set the driver-specific option named key to the given value.-U --plugindir=directoryβ load drivers from directory. see DRIVER LOADING.-O, --options-file <path>β a file containing default values for all options. a relative path is interpreted from the current directory. see [FILES] below.-D --loglevel=levelβ decides how much logging info you get. level can be a symbolic syslog level:'error','warning','info','notice'or'debug'. lirc also defines three extra levels β'trace','trace1'and'trace2'β which give you even more messages ('trace2'brings the most). however, in the log these messages are marked as'debug'. the level can also be an integer in the range3(almost no messages) to10.-h --helpβ display the usage summary.-v --versionβ display the version.
π RUNNING AS ROOT π
in many cases mode2 needs to run as root to access devices that regular users can't touch. but on the other hand, running as root creates problems β log files owned by root, security concerns, etc. π the eternal struggle.
to cope with this, mode2 by default drops root privileges after opening the input device. this support is based on root permissions being accquired using sudo(1), e. g. like this:
$ sudo mode2 --raw /dev/lirc0
if you're not using sudo, you can get the same behaviour with the SUDO_USER environment variable, e. g.:
# SUDO_USER=$LOGNAME mode2 --raw /dev/lirc0
the --keep-root option makes mode2 keep root privileges for the complete run. use with intention, bestie.
π₯ EXAMPLES π₯
invoked with a MODE2 type driver, mode2 prints space/mark timings:
al@snorken $ ./mode2 --driver default --device /dev/lirc0
Using driver default on device /dev/lirc0
Trying device: /dev/lirc0
Using device: /dev/lirc0
pulse 2750
space 800
pulse 500
space 350
pulse 550
space 350
pulse 550
...
invoked with a LIRCCODE type driver, mode2 prints decoded values:
$ ./mode2 --driver atilibusb
Using driver atilibusb on device /dev/lirc0
Trying device: /dev/bus/usb/001/007
Using device: /dev/bus/usb/001/007
code: 0x14709b0000
code: 0x14709b0000
code: 0x14709b0000
code: 0x14709b0000
code: 0x14709b0000
...
invoked using mode2 --list-devices for the devinput driver with a single X10 RF usb device plugged in:
$ ./mode2 --list-devices --driver devinput
/dev/input/event12 [0bc7:0006] X10 WTI RF receiver vers: 1.10 serial: ?
/dev/input/by-id/usb-X10_WTI_RF_receiver-event-if00 -> ../event12
/dev/input/by-path/pci-0000:0b:00.0-usb-0:1:1.0-event -> ../event12
π¦ DRIVER LOADING π¦
drivers are loaded dynamically, and the search path used for this is determined by (falling priority):
- the
--plugindiroption. - the
'plugindir'entry in the[lircd]section of thelirc_options.conffile. - the environment variable
LIRC_PLUGINDIR. - a hardcoded default (
/usr/lib/x86_64-linux-gnu/lirc/plugins).
π ENVIRONMENT π
LIRC_LOGLEVELβ used as fallback when there is no--logleveloption present. syntax is the same as for--loglevel, see OPTIONS.
π FILES π
/etc/lirc/lirc_options.confβ the options file holding default values for command line options in the[mode2]section. for some values β including debug, plugindir, driver and device β mode2 falls back to the[lircd]section if it's not found in[mode2].
the location of this file can be changed using the -O/--options-file command-line option or using the environment variable LIRC_OPTIONS_PATH.
~/.cache/mode2.logβ debug log. setting theXDG_CACHE_HOMEenvironment variable relocates this file to$XDG_CACHE_HOME/mode2.log. the amount of logging respects theLIRC_LOGLEVELenvironment variable, defaulting to the debug value inlirc_options.conf.
β SEE ALSO β
the documentation for lirc is maintained as html pages. they are located under html/ in the documentation directory.
and that's the whole page, bestie π«Ά this was mode2, last changed back in Jan 2017, from the 0.10.2 era of lirc. go forth and vibe check your IR receivers πβ¨
π¦ where this page comes from
- debian trixie: lirc 0.10.2-0.10 Β· GPL-2.0-or-later
- ubuntu noble: lirc 0.10.2-0.8build1 Β· GPL-2.0-or-later
- ubuntu questing: lirc 0.10.2-0.10build1
- ubuntu resolute: lirc 0.10.2-0.10ubuntu1 Β· GPL-2.0-or-later
- ubuntu stonking: lirc 0.10.2-0.11 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms