diff volume_osx.py @ 1:04c8a1b3976b

volume r/w on linux+osx
author drewp@bigasterisk.com
date Fri, 03 Mar 2023 21:24:53 -0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/volume_osx.py	Fri Mar 03 21:24:53 2023 -0800
@@ -0,0 +1,11 @@
+from osascript import osascript
+
+
+async def get_volume():
+    out = osascript('output volume of (get volume settings)')
+    return int(out[1]) / 100
+
+
+async def set_volume(v: float):
+    i = round(v * 100)
+    osascript(f"set volume output volume {i}")