-
Notifications
You must be signed in to change notification settings - Fork 11
/
meetjitsi
executable file
·87 lines (69 loc) · 2.08 KB
/
meetjitsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/python3
import textwrap
import sys
import yaml
import os.path
import os
def help():
help_=textwrap.dedent(
"""\
usage: meetjits [handle|--list|--help|URL]
--list will dump your config
Otherwise will start bromium on the
given Jitsi Meet channel or on the give URL.
You can configure your channels like this:
$ cat ~/.meetjitsi.yaml
urls:
default: https://meet.jit.si/example-default
myown: https://meet.jit.si/example-myown
Jitsi Meet uses 4000 - 6000kbps.
""")
print(help_)
def get_handle_from(argv):
if len(argv) == 1:
return "default"
else:
return argv[1]
def read_urls_from_config( dump = False ):
config_file = os.path.join( os.path.expanduser("~"),
".meetjitsi.yaml")
try:
with open(config_file, 'r') as yaml_config:
try:
config = yaml.safe_load(yaml_config)
except Exception as err:
print(err)
exit(1)
except IOError as err:
print("I need to access my config file, but can't:")
print(err)
print("Please create that file or make it accessible.")
exit(1)
try:
urls = config["urls"]
except KeyError:
print("Please create a list named 'urls' in the %s" % config_file)
exit(1)
if dump == True:
print(yaml.dump(config, default_flow_style=False))
return urls
def get_url_from(urls, handle):
try:
url = urls[handle]
except KeyError:
print("There is no defined URL for handle/key %s in the config file" % handle)
exit(1)
return url
handle = get_handle_from(sys.argv)
if handle == "--help":
help()
exit(1)
elif handle == "--list":
read_urls_from_config(dump = True)
exit(1)
elif handle[0:7] == "http://" or handle[0:8] == "https://" :
url=handle
else:
urls = read_urls_from_config()
url = get_url_from(urls, handle)
os.execlp("bromium", "meetjitsi", ("--app=%s" % url))