blob: c6ef9f30accb8c57d896396f1a895f15b296f039 (
plain)
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
|
#!/usr/bin/env python
import os
HOME=os.environ['HOME'] + '/'
XCDIR=f'{HOME}.config/xcolors/'
CSLIST=os.listdir(XCDIR)
XRPATH=f'{HOME}.Xresources'
ALPATH=f'{HOME}.config/alacritty/alacritty.yml'
def update_xresources(csname):
"""
Updates the ~/.Xresources file with new color scheme.
"""
if csname not in CSLIST:
return f"{csname} not in {XCDIR}"
with open(XRPATH, 'r') as infile:
lines = infile.readlines()
with open(file_dir, 'w') as outfile:
for i, line in enumerate(lines):
if i == 4:
nline = line.split('/')
nline[-1] = csname + '"\n'
nline = '/'.join(nline)
outfile.write(nline)
else:
outfile.write(line)
def update_alacritty(csname):
"""
Updates the ~/.config/alacritty/alacritty.yml file with new color scheme.
"""
if csname not in CSLIST:
return f"{csname} not in {XCDIR}"
with open(ALPATH, 'r') as infile:
lines = infile.readlines()
for line in lines:
if 'background' in line:
print(line)
return None
with open(file_dir, 'w') as outfile:
for i, line in enumerate(lines):
if i == 4:
nline = line.split('/')
nline[-1] = csname + '"\n'
nline = '/'.join(nline)
outfile.write(nline)
else:
outfile.write(line)
if __name__=="__main__":
print('Test')
|