From: kaliko Date: Sun, 20 Dec 2009 13:30:48 +0000 (+0000) Subject: * mfade: no longer stops playing when aborting after external volume changes X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=f0a32720d2cde97b6e1a3a2eafc48b8c88649fca;p=mpd-goodies.git * mfade: no longer stops playing when aborting after external volume changes * mfade: properly logs out to stderr/stdout --- diff --git a/mfade b/mfade index 3ed1756..c55e11f 100755 --- a/mfade +++ b/mfade @@ -88,15 +88,13 @@ class Sleep(object): if self.volum > self.mpd_vol: sys.stderr.write('Error: specified min volume (%d%%) > to current volume (%d%%)' % (self.volum, self.mpd_vol)) sys.exit(1) - sys.stdout.write('fading down from %d%% to %d%% over %smin' % (self.mpd_vol, - self.volum, self.tempo)) - self.fade() - self.cli.stop() + print >> sys.stdout, 'fading down from %d%% to %d%% over %smin' % (self.mpd_vol, self.volum, self.tempo) + if self.fade(): + self.cli.stop() if self.mpd_state in ['stop', 'pause']: if not self.volum: self.volum = int(50) - sys.stdout.write('fading up from 0%% to %d%% over %smin' % (self.volum, - self.tempo)) + print >> sys.stdout, 'fading up from 0%% to %d%% over %smin' % (self.volum, self.tempo) self.cli.setvol(0) self.mpd_vol = 0 self.cli.play() @@ -111,13 +109,13 @@ class Sleep(object): vol = self.mpd_vol while 42: if int(vol) != int(self.cli.status().get('volume')): - sys.stdout.write('Warning: external volume change, aborting!') - break + sys.stderr.write('Warning: external volume change, aborting!\n') + return False vol += step self.cli.setvol(int(vol)) if abs(vol - self.volum) < 1: self.cli.setvol(self.volum) - break + return True sleep(1)