Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View find-wallpapers.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#!/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.