Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert .Xresources colours to st config format
#!/bin/python3
from sys import argv
with open(argv[1]) as f:
lines = f.readlines()
d = dict()
for line in lines:
if line[0] != '*' or 'color' not in line:
continue
color_num = int(line.split(':')[0][len('*.color'):])
d[color_num] = line.split()[1]
print("/* 8 normal colors */")
for color in sorted(d.items()):
if color[0] == 8:
print()
print("/* 8 bright colors */")
print('"{}",'.format(color[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment