WIP: get_volume() for pulseaudio sink
This commit is contained in:
parent
9f4f3b9293
commit
d25449a526
@ -33,6 +33,13 @@ async def open_subprocess(cmd: str):
|
|||||||
return p.returncode, stdout, stderr
|
return p.returncode, stdout, stderr
|
||||||
|
|
||||||
|
|
||||||
|
def get_volume():
|
||||||
|
r = run(["pactl", "list"], text=True, capture_output=True)
|
||||||
|
for x in r.stdout.split("Sink #0")[1].split("Base Volume:")[0].split(' '):
|
||||||
|
if '%' in x:
|
||||||
|
return int(x.replace('%', ''))
|
||||||
|
|
||||||
|
|
||||||
def log(message: str):
|
def log(message: str):
|
||||||
with open(os.path.expandvars("$HOME/navi.log"), 'a') as f:
|
with open(os.path.expandvars("$HOME/navi.log"), 'a') as f:
|
||||||
f.write(f"[{dt.now().strftime('%m/%d/%y-%H.%M.%S')}] {message}\n")
|
f.write(f"[{dt.now().strftime('%m/%d/%y-%H.%M.%S')}] {message}\n")
|
||||||
@ -80,6 +87,7 @@ def main():
|
|||||||
print("modeset2 by fyb")
|
print("modeset2 by fyb")
|
||||||
print(f"local machine time: {get_hour()}")
|
print(f"local machine time: {get_hour()}")
|
||||||
print(f"current mode is: {get_mode()}")
|
print(f"current mode is: {get_mode()}")
|
||||||
|
print(f"current sink volume: {get_volume()}")
|
||||||
print("""Available options:
|
print("""Available options:
|
||||||
1. Login
|
1. Login
|
||||||
2. Lock
|
2. Lock
|
||||||
|
Loading…
x
Reference in New Issue
Block a user