/usr/sbin/lircd-setup is in lirc 0.10.0-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #! /usr/bin/python3
''' Parse the [modinit] section in lirc_options.conf and run it. '''
import configparser
import subprocess
import sys
_HELP = ''' Usage: lircd_setup [lirc_options.conf file] '''
_DEFAULT_FILE = "/etc/lirc/lirc_options.conf"
def run_command(parser, key):
try:
code = parser.get('modinit', key)
except configparser.NoOptionError:
return
else:
cmd = ['/bin/sh', '-c', code]
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError as err:
print("Cannot execute: " + ' '.join(cmd))
print(err)
def main():
''' Indeed: the main program. '''
if len(sys.argv) == 1:
path = _DEFAULT_FILE
elif len(sys.argv) == 2:
path = sys.argv[1]
else:
sys.stderr.write(_HELP + '\n')
sys.exit(1)
parser = configparser.SafeConfigParser()
try:
found = parser.read(path)
except configparser.Error:
sys.stderr.write("Cannot parse file " + path)
sys.exit(1)
if not parser.has_section("modinit"):
return
run_command(parser, 'code')
for ix in range(1, 11):
run_command(parser, 'code' + str(ix))
if __name__ == '__main__':
main()
# vim: set expandtab ts=4 sw=4:
|