cli: fix relative volume adjustment #12

Merged
danio merged 1 commits from fix-new-cli-features into master 2024-06-02 02:38:18 +02:00
1 changed files with 2 additions and 1 deletions
Showing only changes of commit 047d09ffb1 - Show all commits

View File

@ -170,10 +170,11 @@ def set_volume(
if volume.startswith("+") or volume.startswith("-"): if volume.startswith("+") or volume.startswith("-"):
current_volume = api.get_volume() current_volume = api.get_volume()
new_volume = max(0, min(100, current_volume + int(volume))) new_volume = max(0, min(100, current_volume + int(volume)))
new_volume = int(new_volume)
Review

all inputs to max are int, this line should be a noop?

all inputs to max are int, this line should be a noop?
Review

api.get_volume() returns a float, api.set_volume() requires an int

current-volume + int(volume) is a float

could just fix one of them instead of this though

api.get_volume() returns a float, api.set_volume() requires an int current-volume + int(volume) is a float could just fix one of them instead of this though
else: else:
new_volume = int(volume) new_volume = int(volume)
rich.print(api.set_volume(volume), file=sys.stderr) rich.print(api.set_volume(new_volume), file=sys.stderr)
if __name__ == "__main__": if __name__ == "__main__":