def main(xrdb_path, output_path=None): for data in Xrdb.parse_all(xrdb_path): output = "#!/bin/sh\n# " + data.name output += '\nprintf "\\033]4' for i in range(0, 16): output += ";%d;%s" % (i, data.colors[i]) output += '\\007"' output += '\nprintf "\\033]10;%s;%s;%s\\007"' % (data.Foreground_Color, data.Background_Color, data.Cursor_Color) if hasattr(data, "Selection_Color"): output += '\nprintf "\\033]17;%s\\007"' % (data.Selection_Color) if hasattr(data, "Selected_Text_Color"): output += '\nprintf "\\033]19;%s\\007"' % (data.Selected_Text_Color) if hasattr(data, "Bold_Color"): output += '\nprintf "\\033]5;0;%s\\007"' % (data.Bold_Color) output += "\n" if not output_path: print(output) else: dest = '{0}.sh'.format(os.path.join(output_path, data.name)) with open(dest, 'w+') as f: f.write(output) # Make sure these scripts are executable os.chmod(dest, 0o755)
def main(xrdb_path, output_path=None): for data in Xrdb.parse_all(xrdb_path): output = process_file(data) if not output_path: print(output) else: dest = os.path.join(output_path, data.name) with open('{0}.txt'.format(dest), 'w+') as f: f.write(output)
def main(xrdb_path, output_path=None): for data in Xrdb.parse_all(xrdb_path): scheme = dict( colors=dict( primary=dict( background=data.Background_Color, foreground=data.Foreground_Color ), cursor=dict( text=data.Cursor_Text_Color, cursor=data.Cursor_Color ), normal=dict( black=data.colors[0], red=data.colors[1], green=data.colors[2], yellow=data.colors[3], blue=data.colors[4], magenta=data.colors[5], cyan=data.colors[6], white=data.colors[7] ), bright=dict( black=data.colors[8], red=data.colors[9], green=data.colors[10], yellow=data.colors[11], blue=data.colors[12], magenta=data.colors[13], cyan=data.colors[14], white=data.colors[15] ) ) ) if hasattr(data, "Selection_Color") and hasattr(data, "Selected_Text_Color"): scheme['colors']['selection'] = dict( text=data.Selected_Text_Color, background=data.Selection_Color ) destination = '{0}.yml'.format(os.path.join(output_path, data.name)) with open(destination, 'w+') as output_file: header = "# Colors (" + data.name + ")\n" output_file.write(header) yaml.dump(scheme, output_file, default_flow_style=False)
def main(xrdb_path, output_path=None): data = Xrdb(xrdb_path) for _ in range(1): scheme = dict(colors=dict( primary=dict(background=data.Background_Color, foreground=data.Foreground_Color), cursor=dict(text=data.Cursor_Text_Color, cursor=data.Cursor_Color), normal=dict( black=data.colors[0], red=data.colors[1], green=data.colors[2], yellow=data.colors[3], blue=data.colors[4], magenta=data.colors[5], cyan=data.colors[6], white=data.colors[7], ), bright=dict( black=data.colors[8], red=data.colors[9], green=data.colors[10], yellow=data.colors[11], blue=data.colors[12], magenta=data.colors[13], cyan=data.colors[14], white=data.colors[15], ), )) if hasattr(data, "Selection_Color") and hasattr( data, "Selected_Text_Color"): scheme["colors"]["selection"] = dict( text=data.Selected_Text_Color, background=data.Selection_Color) destination = Path(xrdb_path).stem + ".yml" with open(destination, "w+") as output_file: header = "# Colors (" + data.name + ")\n" output_file.write(header) yaml.dump(scheme, output_file, default_flow_style=False)