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