Skip to content

Commit

Permalink
cli, commands: Allow floating point arguments for volume
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte authored and lazka committed Dec 21, 2017
1 parent d1fcb9b commit daf9549
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 3 additions & 5 deletions quodlibet/quodlibet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,9 @@ def process_arguments(argv):
options.add("screen", arg="dummy")

def is_vol(str):
if str[0] in '+-':
if len(str) == 1:
return True
str = str[1:]
return str.isdigit()
if len(str) == 1 and str[0] in '+-':
return True
return is_float(str)

def is_time(str):
if str[0] not in "+-0123456789":
Expand Down
6 changes: 3 additions & 3 deletions quodlibet/quodlibet/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def register(self, name, args=0, optional=0):
Args:
name (str): the command name
args (int): amount of required arguments
optional (int): amoutn of additional optional arguments
optional (int): amount of additional optional arguments
Returns:
Callable
"""
Expand Down Expand Up @@ -171,7 +171,7 @@ def _volume(app, value):
if value[0] in ('+', '-'):
if len(value) > 1:
try:
change = (int(value[1:]) / 100.0)
change = (float(value[1:]) / 100.0)
except ValueError:
return
else:
Expand All @@ -181,7 +181,7 @@ def _volume(app, value):
volume = app.player.volume + change
else:
try:
volume = (int(value) / 100.0)
volume = (float(value) / 100.0)
except ValueError:
return
app.player.volume = min(1.0, max(0.0, volume))
Expand Down
1 change: 1 addition & 0 deletions quodlibet/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_player(self):
self.__send("volume +1000")
self.__send("volume 40")
self.__send("volume -10")
self.__send("volume +4.2")

self.__send("seek -10")
self.__send("seek +10")
Expand Down

0 comments on commit daf9549

Please sign in to comment.