-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
70 lines (58 loc) · 2.36 KB
/
main.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import argparse
import os
import pathlib
from typing import Dict, List
import pyron
parser: argparse.ArgumentParser = argparse.ArgumentParser(
"Use your pywal colorscheme with COSMIC Terminal")
parser.add_argument('--pywal-colors', type=pathlib.Path, nargs=1, help='Path to colors file generated by pywal',
default=pathlib.Path(os.environ['HOME']+'/.cache/wal/colors'), required=False)
parser.add_argument('--sample-ron', type=pathlib.Path, nargs=1,
help='Path to a .ron file for COSMIC Terminal (Either export one or download one)',
default=pathlib.Path('COSMIC Dark.ron'), required=False)
parser.add_argument('--output', type=pathlib.Path, nargs=1,
help='Path to output file', default=pathlib.Path('pywal.ron'), required=False)
args: argparse.Namespace = parser.parse_args()
ron: Dict[str, str | Dict[str, str]] = pyron.load(
path=str(args.sample_ron.absolute()))
with open(args.pywal_colors.absolute(), 'r') as file:
colors: List[str] = file.read().split('\n')
'''
Repetition is the programmer's worst enemy.
- dharmik2319
'''
ron['name'] = 'pywal'
ron['foreground'] = colors[15]
ron['cursor'] = colors[15]
ron['bright_foreground'] = colors[15]
ron['dim_foreground'] = colors[0]
ron['normal']['black'] = colors[0]
ron['normal']['red'] = colors[1]
ron['normal']['green'] = colors[2]
ron['normal']['yellow'] = colors[3]
ron['normal']['blue'] = colors[4]
ron['normal']['magenta'] = colors[5]
ron['normal']['cyan'] = colors[6]
ron['normal']['white'] = colors[7]
ron['bright']['black'] = colors[0]
ron['bright']['red'] = colors[1]
ron['bright']['green'] = colors[2]
ron['bright']['yellow'] = colors[3]
ron['bright']['blue'] = colors[4]
ron['bright']['magenta'] = colors[5]
ron['bright']['cyan'] = colors[6]
ron['bright']['white'] = colors[7]
ron['dim']['black'] = colors[0]
ron['dim']['red'] = colors[1]
ron['dim']['green'] = colors[2]
ron['dim']['yellow'] = colors[3]
ron['dim']['blue'] = colors[4]
ron['dim']['magenta'] = colors[5]
ron['dim']['cyan'] = colors[6]
ron['dim']['white'] = colors[7]
ron_ls: List[str] = pyron.to_string(ron).replace(
'{', '(').replace('}', ')').split('\n')
for i, _ in enumerate(ron_ls):
ron_ls[i] = ron_ls[i].replace('"', '', 2)
with open(str(args.output.absolute()), 'w') as out:
out.write(''.join(line+'\n' for line in ron_ls))