Guest User

Untitled

a guest
Nov 6th, 2023
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1.  
  2. import subprocess
  3. from pathlib import Path
  4. import sys
  5.  
  6. assert(len(sys.argv) == 2)
  7. assert(sys.argv[1] in ["normal", "low"])
  8.  
  9. index = 1 if sys.argv[1] == "normal" else 2
  10.  
  11. values = [
  12.     ["RX1 Digital Volume", "88", "62"],
  13.     ["RX2 Digital Volume", "88", "62"],
  14.     ["EAR PA Gain", "POS_6_DB", "POS_1P5_DB"],
  15. ]
  16.  
  17.  
  18. tinymix_path = bytes(Path.home() / "tinyalsa/utils/tinymix")
  19.  
  20. script = []
  21. for row in values:
  22.     script.append(
  23.         b"%s set \"%s\" \"%s\"\n" % (
  24.             tinymix_path,
  25.             row[0].encode("utf-8"),
  26.             row[index].encode("utf-8")
  27.         )
  28.     )
  29. script = b"".join(script)
  30.  
  31. su = subprocess.Popen(["su"], stdin = subprocess.PIPE, stderr = subprocess.PIPE, stdout = subprocess.PIPE)
  32. print(su.communicate(script, timeout = 20))
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment