Hi Dag! a few comments/questions regarding the termtitle plugin. On 29.05.05, Dag Wieers wrote: [...]
import events, plugin, config, sys, os, re
class config(config.configsection): songformat = config.configstring('%(artist)s - %(title)s') term = os.getenv('TERM')
Is term supposed to be config options? If yes and in case you want to specify a default, use term = config.configstring(os.getenv('TERM'))
termre = re.compile('(screen|xterm-*)')
Here applies the same, except that you have to compile the regexp in the plugin and not its config. Anyway, both options are currently not used...
class plugin(plugin.plugin): def start(self): self.channel.subscribe(events.playbackinfochanged, self.playbackinfochanged) self.previoussong = '' self.previouscross = False
def playbackinfochanged(self, event): if event.playbackinfo.song != self.previoussong: self.changetermtitle(event) self.previoussong = event.playbackinfo.song if event.playbackinfo.iscrossfading() != self.previouscross: self.changetermtitle(event) self.previouscross = event.playbackinfo.iscrossfading()
def changetermtitle(self, event): prefix = (event.playbackinfo.iscrossfading() and "-> " or "") song = event.playbackinfo.song.format(self.config.songformat, safe=True) sys.stdout.write('\033]0;' + prefix + song + '\007')
# vim:ts=4:sw=4