Skip to content

Commit 9926d50

Browse files
committed
refactoring
1 parent d44b0c1 commit 9926d50

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

wal-to-chrome.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def hex_to_rgb(hexin):
1010
rgb_out = tuple(int(hexin[i:i+2], 16) for i in (0, 2, 4))
1111
#rgb_out is like (255, 255, 255)
1212
# need to convert it to something like [255, 255, 255]
13+
rgb_out = list(rgb_out)
1314
return rgb_out
1415

1516
waltocrx = {'special.background': 'theme.colors.ntpbackground',
@@ -23,7 +24,7 @@ def hex_to_rgb(hexin):
2324
# read wal's colors
2425
with open(walfile, "r") as read_file:
2526
wal_colors = json.load(read_file)
26-
27+
2728
# read manifest's colors
2829
with open(dest_file, "r") as read_file:
2930
chrome_colors = json.load(read_file)
@@ -34,13 +35,12 @@ def hex_to_rgb(hexin):
3435
for key in waltocrx:
3536
hexcolor = wal_colors[key.split('.')[0]][key.split('.')[1]]
3637
rgbcolor = hex_to_rgb(hexcolor)
37-
rgbcolor = list(rgbcolor)
3838
chrome_colors[waltocrx[key].split('.')[0]][waltocrx[key].split('.')[1]][waltocrx[key].split('.')[2]] = rgbcolor # f.seek(0) # <--- should reset file position to the beginning.
3939

4040
os.remove(dest_file) #need to overwrite it, might be better ways
4141
with open(dest_file, "w+") as f:
42-
json.dump(chrome_colors, f, indent=None)
42+
json.dump(chrome_colors, f, indent=None) #this puts it in a compacted form but it works, not sure if its possible to preserve original form, every other indent level adds newlines to each RGB value
4343
f.truncate() # remove remaining part
4444

45-
#manifest.json should be updated now, proceed as normal packing .crx
45+
# manifest.json should be updated now, proceed as normal packing .crx
4646
# this can be done from CLI as well, additional feature

0 commit comments

Comments
 (0)