cli: allow relative volume adjustment using {+,-}<n>{,%}
This commit is contained in:
parent
2b8ecf124d
commit
ca78aa9e22
|
@ -160,10 +160,19 @@ def status(
|
||||||
|
|
||||||
@cli.command(help="Set the playback volume")
|
@cli.command(help="Set the playback volume")
|
||||||
def set_volume(
|
def set_volume(
|
||||||
volume: int,
|
volume: str,
|
||||||
api_base: str = DEFAULT_API_BASE,
|
api_base: str = DEFAULT_API_BASE,
|
||||||
):
|
):
|
||||||
api.set_endpoint(api_base)
|
api.set_endpoint(api_base)
|
||||||
|
|
||||||
|
volume = volume.removesuffix("%")
|
||||||
|
|
||||||
|
if volume.startswith("+") or volume.startswith("-"):
|
||||||
|
current_volume = api.get_volume()
|
||||||
|
new_volume = max(0, min(100, current_volume + int(volume)))
|
||||||
|
else:
|
||||||
|
new_volume = int(volume)
|
||||||
|
|
||||||
rich.print(api.set_volume(volume), file=sys.stderr)
|
rich.print(api.set_volume(volume), file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue