From fcebc7a9c8a240de4920fd1fc29781c8d4930897 Mon Sep 17 00:00:00 2001 From: Bastien Nocera <hadess@hadess.net> Date: Thu, 10 Sep 2009 15:54:49 +0100 Subject: [PATCH 1/2] Fedora support --- gnome_lirc_properties/backend.py | 49 ++++++++++---------- gnome_lirc_properties/config.py.in | 2 +- .../ui/RemoteControlProperties.py | 4 +- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/gnome_lirc_properties/backend.py b/gnome_lirc_properties/backend.py index 2475b21..56244f3 100644 --- a/gnome_lirc_properties/backend.py +++ b/gnome_lirc_properties/backend.py @@ -497,8 +497,8 @@ class BackendService(PolicyKitService): # The "REMOTE_" prefix is made optional, since it only was introduced # with lirc 0.8.3~pre1-0ubuntu4 of Hardy Heron. - __re_remote_directive = re.compile(r'^\s*(?:REMOTE_)?(DRIVER|DEVICE|MODULES|' + - r'LIRCD_ARGS|LIRCD_CONF|VENDOR|MODEL)=') + __re_remote_directive = re.compile(r'^\s*(LIRC_DRIVER|LIRC_DEVICE|MODULES|' + + r'LIRCD_OPTIONS|LIRCD_CONF|VENDOR|MODEL)=') __re_start_lircd = re.compile(r'^\s*START_LIRCD=') def __init__(self, connection=None, path='/'): @@ -602,22 +602,23 @@ class BackendService(PolicyKitService): print >> output, ('%s"%s"' % (match.group(0), ShellQuote.shellquote(value))) continue - # Deal with the START_LIRCD line: - - match = self.__re_start_lircd.match(line) + output.write(line) - if match: - # pychecker says "Using a conditional statement with a constant value (true)", - # which is ridicilous, considering Python 2.4 doesn't have conditional statements - # yet (PEP 308, aka. 'true_value if condition else false_value') and the expression - # below ('condition and true_value or false_value') is the recommended aquivalent. - value = (start_lircd is None) and 'true' or start_lircd - start_lircd = None + # Check whether we need to enable or disable lircd - print >> output, (match.group(0) + ShellQuote.shellquote(value)) - continue + # pychecker says "Using a conditional statement with a constant value (true)", + # which is ridicilous, considering Python 2.4 doesn't have conditional statements + # yet (PEP 308, aka. 'true_value if condition else false_value') and the expression + # below ('condition and true_value or false_value') is the recommended aquivalent. + value = (start_lircd is None) and 'true' or start_lircd + start_lircd = None - output.write(line) + if 'true' == value: + args = '/sbin/chkconfig', 'lirc', 'on' + os.spawnv(os.P_WAIT, args[0], args) + else: + args = '/sbin/chkconfig', 'lirc', 'off' + os.spawnv(os.P_WAIT, args[0], args) # Write out any values that were not already in the file, # and therefore just replaced: @@ -625,17 +626,13 @@ class BackendService(PolicyKitService): if remote_values: print >> output, '\n# Remote settings required by gnome-lirc-properties' for key, value in remote_values.items(): - print >> output, ('REMOTE_%s="%s"' % (key, ShellQuote.shellquote(value))) + print >> output, ('%s="%s"' % (key, ShellQuote.shellquote(value))) if receiver_values: print >> output, '\n# Receiver settings required by gnome-lirc-properties' for key, value in receiver_values.items(): print >> output, ('RECEIVER_%s="%s"' % (key, ShellQuote.shellquote(value))) - if start_lircd is not None: - print >> output, '\n# Daemon settings required by gnome-lirc-properties' - print >> output, ('START_LIRCD=%s' % start_lircd) - # Replace old file with new contents: os.unlink(oldfile) @@ -656,10 +653,10 @@ class BackendService(PolicyKitService): self._check_permission(sender) remote_values = { - 'DRIVER': driver, - 'DEVICE': device, + 'LIRC_DRIVER': driver, + 'LIRC_DEVICE': device, 'MODULES': modules, - 'LIRCD_ARGS': '', + 'LIRCD_OPTIONS': '', 'LIRCD_CONF': '', } @@ -782,10 +779,12 @@ class BackendService(PolicyKitService): raise AccessDeniedException if 'enable' == action: - self._write_hardware_configuration(start_lircd=True) + args = '/sbin/chkconfig', 'lirc', 'on' + os.spawnv(os.P_WAIT, args[0], args) elif 'disable' == action: - self._write_hardware_configuration(start_lircd=False) + args = '/sbin/chkconfig', 'lirc', 'off' + os.spawnv(os.P_WAIT, args[0], args) else: args = '/etc/init.d/lirc', action diff --git a/gnome_lirc_properties/config.py.in b/gnome_lirc_properties/config.py.in index eeeda1c..0fd3f69 100644 --- a/gnome_lirc_properties/config.py.in +++ b/gnome_lirc_properties/config.py.in @@ -13,7 +13,7 @@ PACKAGE_DIR = path.join('@prefix@', 'share', '@PACKAGE@') LIRC_CONFDIR = '@with_lirc_confdir@' LIRCD_SOCKET = '@with_lircd_socket@' -LIRC_HARDWARE_CONF = path.join(LIRC_CONFDIR, 'hardware.conf') +LIRC_HARDWARE_CONF = path.join('@sysconfdir@', 'sysconfig', 'lirc') LIRC_REMOTE_CONF = path.join(LIRC_CONFDIR, 'lircd.conf.gnome') LIRC_DAEMON_CONF = path.join(LIRC_CONFDIR, 'lircd.conf') diff --git a/gnome_lirc_properties/ui/RemoteControlProperties.py b/gnome_lirc_properties/ui/RemoteControlProperties.py index e65af35..f6e3fd4 100644 --- a/gnome_lirc_properties/ui/RemoteControlProperties.py +++ b/gnome_lirc_properties/ui/RemoteControlProperties.py @@ -296,13 +296,13 @@ class RemoteControlProperties(object): # # NOTE: Ubuntu's lirc script doesn't distinguish between remote and # receiver settings in "hardware.conf", whereas we have to. For that - # reason the device node's name is stored in REMOTE_DEVICE, instead + # reason the device node's name is stored in LIRC_DEVICE, instead # of RECEIVER_DEVICE. # self.selected_receiver = ( settings.get('RECEIVER_VENDOR'), settings.get('RECEIVER_MODEL'), - settings.get('REMOTE_DEVICE'), + settings.get('LIRC_DEVICE'), ) # Try to select configured remote vendor: -- 1.6.2.5