Created
May 28, 2020 15:36
-
-
Save QuietMisdreavus/140ba03b74f5dee55bfd0eeb70f827ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# colscheme-convert: takes a colorscheme file as based on my Konsole color scheme | |
# and converts it to something that can be pasted into a termite config file | |
# Victoria Mitchell ('QuietMisdreavus'), May 2016 | |
import sys | |
import os.path | |
fname = '' | |
if len(sys.argv) > 1: | |
fname = sys.argv[1] | |
if not os.path.exists(fname): | |
sys.exit('file does not exist') | |
def col2hex(line): | |
_, _, vals = line.partition('=') | |
rgb = ['{:x}'.format(int(v)) for v in vals.split(',')] | |
return '#' + ''.join(rgb) | |
print('[colors]') | |
colorhead = '' | |
skipcolor = False | |
for line in open('Zenburn.colorscheme'): | |
line = line.strip() | |
if not line: | |
continue | |
elif line == '[General]': | |
break | |
elif line.startswith('Color='): | |
if skipcolor: | |
skipcolor = False | |
elif colorhead: | |
print('{} = {}'.format(colorhead, col2hex(line))) | |
colorhead = '' | |
elif 'BackgroundIntense' in line: | |
skipcolor = True | |
elif 'ForegroundIntense' in line: | |
skipcolor = True | |
elif line == '[Background]': | |
colorhead = 'background' | |
elif line == '[Foreground]': | |
colorhead = 'foreground' | |
else: | |
line = line.strip('[]') | |
colornum = int(line[5]) | |
if line.endswith('Intense'): | |
line = line[0:-7] | |
colornum = colornum + 8 | |
colorhead = 'color' + str(colornum) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment