view 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 source

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}")