Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
#!/usr/bin/env python
"""
Usage:
$ python find-wallpapers.py
Example output:
http://i.imgur.com/THbJKaZ.png
"""
import re
import subprocess
COLORS_R = re.compile('.*?color([\d]+):\s*?(#[A-Fa-f0-9]+)')
COLOR_NAMES = [
'black',
'red',
'green',
'yellow',
'blue',
'magenta',
'cyan',
'white',
'alt_black',
'alt_red',
'alt_green',
'alt_yellow',
'alt_blue',
'alt_magenta',
'alt_cyan',
'alt_white',
]
URL_TEMPLATE = 'http://wallbase.cc/search?q=&color=%s&section=wallpapers&order_mode=desc'
def read_colors():
xrdb = subprocess.Popen(['xrdb', '-q'], stdout=subprocess.PIPE)
out, _ = xrdb.communicate()
return dict(
(int(idx), val) for idx, val in COLORS_R.findall(out))
def main():
colors = read_colors()
print 'Colors\n------'
for color, hexval in sorted(colors.items()):
term_color = (color % 8) + 30
if color >= 8:
escape = '1;%sm' % term_color
else:
escape = '%sm' % term_color
print '\033[%s%s\033[0m: %s' % (
escape,
COLOR_NAMES[color],
URL_TEMPLATE % hexval[1:])
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.