You are not logged in.

#1 2018-04-17 19:06:44

CountZukula
Member
Registered: 2017-11-04
Posts: 48

Powerline colors through .Xresources or pywal

Hi all,

I'm currently trying to configure my i3 environment as a first attempt at getting a nice and unified environment. I decided to base myself on pywal to generate the .Xresources file, which creates #xxxxxx color codes in .Xresources. Those codes I can reference from i3's config, qutebrowser's config, urxvt, rofi ... The only thing I cannot seem to manage is powerline.

As far as I understand, powerline's color configuration is a 256 index based system, and I cannot use any of the pre-generated files of pywal (in .cache/wal) as they all contain the #xxxxxx format. Has anyone had success in marrying powerline and pywal? I'm also open for suggestions of alternative programs, I'm not necessarily pinned down on either of the two.

Thanks!

Last edited by CountZukula (2018-04-17 19:07:21)

Offline

#2 2018-04-17 20:12:34

progandy
Member
Registered: 2012-05-17
Posts: 5,190

Re: Powerline colors through .Xresources or pywal

You should be able to use use hex colors (term_truecolor), but you have to define a fallback color index as well https://powerline.readthedocs.io/en/mas … efinitions

You can try something like this to get an approximate color index:
https://gist.github.com/MicahElliott/719710
https://jonasjacek.github.io/colors/

Edit: You could also set a fixed color scheme as the color index fallback which will be used if the truecolor representation is not supported. Then you won't have a uniform color scheme in unsupported terminals, though.

Last edited by progandy (2018-04-17 20:17:54)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#3 2018-05-08 20:21:18

CountZukula
Member
Registered: 2017-11-04
Posts: 48

Re: Powerline colors through .Xresources or pywal

Eventually I wrote a small script myself that overwrites the colors.json file of powerline. It takes the values from the pywal .cache folder and converts them appropriately. I'll leave the snippet below, it might be of use to someone!

#! /usr/bin/env python

import colortrans
import json

# open the current config.json and potentially overwrite the right values
colorjsonfile = '/home/username/.config/powerline/colors.json'
with open(colorjsonfile) as pywaljsonfile:	
	pywaljson = json.load(pywaljsonfile)

# read the pywal cache file
pywalcolors = open('/home/username/.cache/wal/colors', "r")
i = 0
for row in pywalcolors:
	# clean up the color
	colorstring = row.strip()
	# remove the hashtag
	colorstring = colorstring.lstrip('#')
	# convert it to short
	colorshort = colortrans.rgb2short(colorstring)[0]
	# print the color
	print(colorshort)
	# overwrite the setting in the json file
	colorname = 'pywal'+str(i)
	pywaljson['colors'][colorname] = int(colorshort)
	i = i+1

# write the json object back to the file
with open(colorjsonfile, 'w') as outfile:
	json.dump(pywaljson, outfile)

Offline

Board footer

Powered by FluxBB