-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsportmode.py
55 lines (40 loc) · 1.28 KB
/
sportmode.py
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
#!/usr/bin/env python
import json
import os
import sys
import subprocess
import random
from shutil import which
def get_random_element_in_a_list(list):
return list[random.randint(0, len(list) - 1)]
def get_random_classic_logo(data) -> str:
logos = []
for logo in data['logos']:
logos.append(logo)
return get_random_element_in_a_list(logos)
def get_random_minimal_logo(data) -> str:
logos = []
for logo in data['small_logos']:
logos.append(logo)
return get_random_element_in_a_list(logos)
def main(logos, mode):
if mode == '1' or mode.lower() == 'classic':
opt = get_random_classic_logo(logos)
elif mode == '2' or mode.lower() == 'minimal':
opt = get_random_minimal_logo(logos)
opt = f"{opt}_small"
else:
print("Invalid mode")
print()
sys.exit(1)
subprocess.run(["neofetch", "--ascii_distro", opt])
if __name__ == "__main__":
assert which("neofetch") is not None, "Neofetch is not installed"
file_path = os.path.realpath(os.path.dirname(__file__))
with open(file_path + "/logos.json") as f:
logos = json.load(f)
if len(sys.argv) < 2:
print("Usage: python3 sportmode.py [classic | minimal]")
sys.exit(1)
mode = sys.argv[1]
main(logos, mode)