Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 1 | #!${{pkgs.python3}}/bin/python3 |
| 2 | |
| 3 | import sys |
| 4 | import os |
| 5 | import subprocess |
| 6 | |
| 7 | args = sys.argv |
| 8 | |
| 9 | device_argument = "--default-source" if "-i" in args else "" |
| 10 | |
| 11 | control_argument = "" |
| 12 | control_argument += "-i" if "-u" in args else "" |
| 13 | control_argument += "-d" if "-d" in args else "" |
| 14 | control_argument += "-t" if "-m" in args else " 5" |
| 15 | |
| 16 | os.system( |
| 17 | f"${{pkgs.pamixer}}/bin/pamixer {device_argument} {control_argument} --set-limit 150" |
| 18 | ) |
| 19 | mute_char = ( |
| 20 | "!" |
| 21 | if subprocess.getoutput(f"${{pkgs.pamixer}}/bin/pamixer {device_argument} --get-mute") |
| 22 | == "true" |
| 23 | else "" |
| 24 | ) |
| 25 | volume = subprocess.getoutput(f"${{pkgs.pamixer}}/bin/pamixer {device_argument} --get-volume") |
| 26 | |
| 27 | socket_path = f"{os.environ['XDG_RUNTIME_DIR']}/xob.sock" |
| 28 | |
| 29 | with open(socket_path, "w") as socket: |
| 30 | socket.write(f"{volume}{mute_char}\n") |