]> kaliko git repositories - mpd-goodies.git/blobdiff - mfade
* fixes some typo in mfade
[mpd-goodies.git] / mfade
diff --git a/mfade b/mfade
index 3ed1756f6f4bfac5b128319bda25d8b199fce5be..813ab5f16104e6858c416cee43bb02985072e5d7 100755 (executable)
--- a/mfade
+++ b/mfade
@@ -36,12 +36,12 @@ USAGE = """Usage:
 mfade [time [min|max]]
 
    * time in seconds
-   * min|max in percentag
+   * min|max in percentage of volume
 
 when MPD is:
-- not palying: fade in from 0% to max over time
+- not playing: fade in from 0% to max over time
                default 10 minutes / 50%
--    playing:  fade out from current volume to min over time
+-     playing: fade out from current volume to min over time
                default 10 minutes / 1/10 of current vol
 
 Manual or any external volume change will abort the script.
@@ -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)