aboutsummaryrefslogtreecommitdiff
path: root/helpers/actions/volume.py
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/actions/volume.py')
-rw-r--r--helpers/actions/volume.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/helpers/actions/volume.py b/helpers/actions/volume.py
new file mode 100644
index 0000000..7dda3c1
--- /dev/null
+++ b/helpers/actions/volume.py
@@ -0,0 +1,28 @@
1def run(action, music=None, value=100, fade=0, delta=False, **kwargs):
2 if music is not None:
3 music.set_volume(value, delta=delta, fade=fade)
4 else:
5 action.mapping.set_master_volume(value, delta=delta, fade=fade)
6
7def description(action, music=None,
8 value=100, delta=False, fade=0, **kwargs):
9 message = ""
10 if delta:
11 if music is not None:
12 message += "{:+d}% to volume of « {} »" \
13 .format(value, music.name)
14 else:
15 message += "{:+d}% to volume" \
16 .format(value)
17 else:
18 if music is not None:
19 message += "setting volume of « {} » to {}%" \
20 .format(music.name, value)
21 else:
22 message += "setting volume to {}%" \
23 .format(value)
24
25 if fade > 0:
26 message += " with {}s fade".format(fade)
27
28 return message