Skip to content

Instantly share code, notes, and snippets.

@Satshabad
Created February 24, 2013 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Satshabad/5022019 to your computer and use it in GitHub Desktop.
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.
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)
@Satshabad
Copy link
Author

works with amixer (only tested on ubuntu/mint)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment