Just finished up a 0.1 version of a LIRC (Linux Infrared Control) plugin for the Exaile media player. Now you can use your remote with Exaile efficiently. The plugin is in the public repository and is called Lircaile.
I haven’t touched Python much as of yet, but I’m pleased with it: it appears to be a consistent language. Well, here’s my 0.1 effort. I desperately wanted to have some fun with introspection, but I have the feeling the nested exception logic is a bit… unusual.
# A LIRC plugin for Exaile. Depends on pylirc from http://sourceforge.net/projects/pylirc/ # Copyright (C) 2009 Wicher Minnaard, http://smorgasbord.gavagai.nl / wicher@gavagai.eu # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. from xl import playlist, player, event import pylirc, logging LIRCAILE = None def enable(exaile): if (exaile.loading): event.add_callback(_enable, 'exaile_loaded') else: _enable(None, exaile, None) def _enable(eventname, exaile, nothing): global LIRCAILE LIRCAILE = Lircaile(exaile) def disable(exaile): pylirc.exit() class Lircaile(object): def polLirc(self): """Pops all queued signals off of the LIRC queue and hands them to handleCode() for further processing.""" gopoll = True while(gopoll): code = (pylirc.nextcode()) if (code): comval = code[0].split() if (len(comval) == 1): self.handleCode(comval[0]) else: self.handleCode(comval[0], comval[1]) else: # We're done, the queue is empty. gopoll = False return True def __init__(self, exaile): self.exaile = exaile self.logger = logging.getLogger(__name__) socket = pylirc.init('lircaile') event.EventTimer(0.05, self.polLirc) def handleCode(self, command, *arg): """Takes LIRC signals and uses introspection to try to find appropriate exaile functions to call based on the name of the signal. """ if (command == 'chvol'): self.exaile.player.set_volume(self.exaile.player.get_volume() + float(arg[0])) else: func = None # Look for a matching playlist function try: func = getattr(self.exaile.queue, command) except AttributeError: # No? Then look for a matching player function try: func = getattr(self.exaile.player, command) except AttributeError: # No? Then we're out of options self.logger.warning('No function to handle "'+ command +'" LIRC event') if callable(func): func()
Tags: en_GB, exaile, lirc, lircaile, remote —


[...] de audio simple y similar a amarok pero escrito en GTK, gracias a un plugin que encontré en una entrada de este blog, podemos configurarlo de manera sencilla para que funcione con lirc, simplemente descargamos el [...]