summaryrefslogtreecommitdiff
path: root/icons
diff options
context:
space:
mode:
Diffstat (limited to 'icons')
-rwxr-xr-xicons/mkicons32
-rw-r--r--icons/ni.cfg4
2 files changed, 28 insertions, 8 deletions
diff --git a/icons/mkicons b/icons/mkicons
index eb31ed3..8ecc8e2 100755
--- a/icons/mkicons
+++ b/icons/mkicons
@@ -32,6 +32,7 @@
# Email: <nico at ni.fr.eu.org>
#
"""Generate a set of icons to be used with the Awesome Window Manager."""
+import copy
import optparse
import ConfigParser
import Image, ImageDraw
@@ -65,7 +66,7 @@ class Params(object):
"""Update from dictionary."""
if 'size' in d and d['size'] is not None:
w, h = d['size'].split ('x')
- self.size = (int (w), int (h))
+ self.size = (int (w) if w else None, int (h) if h else None)
for n in ('fg', 'bg'):
if n in d and d[n] is not None:
color = d[n]
@@ -77,6 +78,21 @@ class Params(object):
if n in d and d[n] is not None:
setattr (self, n, int (d[n]))
+ def ratio (self, ratio):
+ """Return a Params object, updating size for a given ratio."""
+ if self.size[0] is None:
+ p = copy.copy(self)
+ p.size = ((p.size[1] * ratio[0] + ratio[1] - 1) / ratio[1],
+ p.size[1])
+ return p
+ elif self.size[1] is None:
+ p = copy.copy(self)
+ p.size = (p.size[0],
+ (p.size[0] * ratio[1] + ratio[0] - 1) / ratio[0])
+ return p
+ else:
+ return self
+
def part (a, b, i, n, rounding = 'nearest'):
"""Return the ith separator position when partitioning the space between
a and b. Rounding methods:
@@ -223,11 +239,13 @@ def icon_taglist_sel (icon, draw, p):
x1, y1, x2, y2 = p.coords
y2 = y1 + x2 - x1
draw.rectangle ((x1, y1, x2, y2), outline = p.fg, fill = p.bg)
+icon_taglist_sel.ratio = (1, 4)
def icon_taglist_unsel (icon, draw, p):
x1, y1, x2, y2 = p.coords
y2 = y1 + x2 - x1
draw.line ((x1, y2, x1, y1, x2, y1), fill = p.fg)
+icon_taglist_unsel.ratio = (1, 4)
def icon_awesome (icon, draw, p):
draw.rectangle (p.coords, outline = p.bg, fill = p.bg)
@@ -241,6 +259,9 @@ def icon_awesome (icon, draw, p):
icons = dict((f[5:].replace ('_', '/'), globals ()[f])
for f in dir () if f.startswith ('icon_'))
+for name, func in icons.iteritems ():
+ if not hasattr (func, 'ratio'):
+ func.ratio = (1, 1)
parser = optparse.OptionParser (description = __doc__)
parser.add_option ('-c', '--config', metavar = 'FILE', action = 'append',
@@ -255,7 +276,7 @@ parser.add_option ('-b', '--bg', metavar = 'COLOR',
parser.add_option ('-i', '--include', metavar = 'PATTERN', action = 'append',
help = 'only include icons matching given shell PATTERN')
parser.add_option ('-s', '--size', metavar = 'WIDTHxHEIGHT',
- help = "use specified size for icons")
+ help = "use specified size for icons (one length can be missing)")
parser.add_option ('--margin-top', metavar = 'PIXELS', type = 'int',
help = "keep a margin, define y1")
parser.add_option ('--margin-bottom', metavar = 'PIXELS', type = 'int',
@@ -287,7 +308,7 @@ else:
sections = [ None ]
# Output icons for every sections.
for section in sections:
- p = Params ((12, 12), 'white', 'black')
+ p = Params ((None, 12), 'white', 'black')
output_dir = '.'
include = [ '*' ]
# Merge config and command line.
@@ -306,11 +327,12 @@ else:
for name, func in icons.iteritems():
for pattern in include:
if fnmatch (name, pattern):
- icon = Image.new ('RGBA', p.size, (0, 0, 0, 0))
+ lp = p.ratio (func.ratio)
+ icon = Image.new ('RGBA', lp.size, (0, 0, 0, 0))
draw = ImageDraw.Draw (icon)
if not options.quiet:
print "Generating %s..." % name
- func (icon, draw, p)
+ func (icon, draw, lp)
del draw
filename = os.path.join (output_dir, name + '.png')
try:
diff --git a/icons/ni.cfg b/icons/ni.cfg
index a72b0c5..96b02f1 100644
--- a/icons/ni.cfg
+++ b/icons/ni.cfg
@@ -2,7 +2,7 @@
fg = trans
bg = #aaaaaa
output_dir = ../ni/icons
-size = 12x12
+size = x12
[ni-layout]
include = layouts/*
@@ -10,12 +10,10 @@ include = layouts/*
[ni-taglist-sel]
fg = white
bg = white
-size = 3x12
include = taglist/sel
[ni-taglist-unsel]
fg = %(bg)s
-size = 3x12
include = taglist/unsel
[ni-awesome]