Guest User

Untitled

a guest
Sep 10th, 2017
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. #!/usr/bin/python
  2. InitVol=30; EndVol=100;
  3. VolumeDelay=20.0; # seconds
  4.  
  5. import sys;
  6. import commands,os;
  7. import time;
  8.  
  9. def GetParam(N):
  10.   try:
  11.     return sys.argv[N];
  12.   except:
  13.     return "";
  14.    
  15. def SetChannelVol(Channel,Vol):
  16.   commands.getoutput("amixer -D default set %s playback %i%% unmute" % (Channel,Vol));
  17.  
  18. def SetVol(Vol):
  19.   SetChannelVol("Master",Vol);
  20.   SetChannelVol("Front",Vol);
  21.  
  22. def StopMusic():
  23.   commands.getoutput("killall -s 9 audacious; killall -s 9 mpg123");
  24.                                                                                                                                                                        
  25. Action=GetParam(1);
  26. MusicDir=GetParam(2);
  27.  
  28. if not Action in ("play","stop"):
  29.   MusicDir=Action;
  30.   Action="play";
  31. if len(MusicDir) == 0 : MusicDir="/download/Music";
  32.  
  33. StopMusic();
  34.  
  35. if Action=="play":
  36.   SetVol(0);
  37.   print 1;
  38.   os.system("find -L "+MusicDir+" -iname '*.mp3' | LD_LIBRARY_PATH=/usr/lib/mpg123 mpg123 -o alsa -a default  --shuffle -@ '-' &");
  39.   DelayStep=VolumeDelay/(EndVol-InitVol);
  40.   print(DelayStep);
  41.   for V in range(InitVol, EndVol):
  42.     SetVol(V);
  43.     time.sleep(DelayStep);
Advertisement
Add Comment
Please, Sign In to add comment