aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helpers/__init__.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/helpers/__init__.py b/helpers/__init__.py
index 2339b9b..4b9529d 100644
--- a/helpers/__init__.py
+++ b/helpers/__init__.py
@@ -3,6 +3,7 @@ import argparse
3import sys 3import sys
4import os 4import os
5import math 5import math
6import sounddevice as sd
6 7
7class Config: 8class Config:
8 def __init__(self, **kwargs): 9 def __init__(self, **kwargs):
@@ -37,6 +38,15 @@ def parse_args():
37 action="version", 38 action="version",
38 help="Displays the current version and exits. Only use in bundled package", 39 help="Displays the current version and exits. Only use in bundled package",
39 version=show_version()) 40 version=show_version())
41 parser.add_argument("--device",
42 action=SelectDeviceAction,
43 help="Select this sound device"
44 )
45 parser.add_argument("--list-devices",
46 nargs=0,
47 action=ListDevicesAction,
48 help="List available sound devices"
49 )
40 parser.add_argument('--', 50 parser.add_argument('--',
41 dest="args", 51 dest="args",
42 help="Kivy arguments. All arguments after this are interpreted by Kivy. Pass \"-- --help\" to get Kivy's usage.") 52 help="Kivy arguments. All arguments after this are interpreted by Kivy. Pass \"-- --help\" to get Kivy's usage.")
@@ -44,6 +54,16 @@ def parse_args():
44 54
45 config.yml_file = args.config 55 config.yml_file = args.config
46 56
57class SelectDeviceAction(argparse.Action):
58 def __call__(self, parser, namespace, values, option_string=None):
59 sd.default.device = values
60
61class ListDevicesAction(argparse.Action):
62 nargs = 0
63 def __call__(self, parser, namespace, values, option_string=None):
64 print(sd.query_devices())
65 sys.exit()
66
47def show_version(): 67def show_version():
48 if getattr(sys, 'frozen', False): 68 if getattr(sys, 'frozen', False):
49 with open(path() + ".pyinstaller_commit", "r") as f: 69 with open(path() + ".pyinstaller_commit", "r") as f: