Skip to content

Instantly share code, notes, and snippets.

@louisswarren
Created June 11, 2016 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save louisswarren/1ea064216d4fb481b19c0de32f6d4c37 to your computer and use it in GitHub Desktop.
Save louisswarren/1ea064216d4fb481b19c0de32f6d4c37 to your computer and use it in GitHub Desktop.
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