Created
February 24, 2013 00:25
-
-
Save Satshabad/5022019 to your computer and use it in GitHub Desktop.
Small script to mute your volume for a small amount of time and then unmuting. Useful for beating Spotify ads.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import subprocess | |
import re | |
start_time = int(time.time()) | |
cmd = ['amixer', 'get', 'Master'] | |
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
x = proc.communicate() | |
vol = int(re.findall(r'\[(\d?\d)\%\]', x[0])[0]) | |
cmd = ['amixer', 'set', 'Master', '0'] | |
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
time.sleep(15) | |
cmd = ['amixer', 'set', 'Master', str(vol)+'%', 'unmute'] | |
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works with amixer (only tested on ubuntu/mint)