]> kaliko git repositories - mpd-goodies.git/commitdiff
* mfade: no longer stops playing when aborting after external volume changes
authorkaliko <kaliko@azylum.org>
Sun, 20 Dec 2009 13:30:48 +0000 (13:30 +0000)
committerkaliko <kaliko@azylum.org>
Sun, 20 Dec 2009 13:30:48 +0000 (13:30 +0000)
 * mfade: properly logs out to stderr/stdout

mfade

diff --git a/mfade b/mfade
index 3ed1756f6f4bfac5b128319bda25d8b199fce5be..c55e11ff62e07d6f09048f9bd0385b0c715a628c 100755 (executable)
--- 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)