Skip to content
This repository has been archived by the owner on Jul 15, 2020. It is now read-only.

Commit

Permalink
[python] Use distutils to compile and install pygmi/pyxp.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Maglione committed Jun 27, 2010
1 parent 5db8ca4 commit 23899f6
Show file tree
Hide file tree
Showing 15 changed files with 203 additions and 95 deletions.
2 changes: 2 additions & 0 deletions .hgignore
Expand Up @@ -14,3 +14,5 @@ syntax: glob
config.local.mk
cmd/menu/bindings.c
*.pkg.tar.?z
alternative_wmiircs/python/build/
alternative_wmiircs/python/dist/
5 changes: 3 additions & 2 deletions NEWS
@@ -1,15 +1,16 @@
3.10b1:
* Xft is now loaded on demand.
* /colrules widths may now be specified in pixels.
* /tagrules has been replaced with the more general /rules
* The format of the bar files has changed.
* Add witray system tray program.
* Floating clients can be collapsed by clicking their layout boxes.
* Dock windows act more like dock windows.
* Fixed some managed move bugs.
* The FocusFloating and FocusColumn events have been removed.
* The tag '!' is no longer special.
* Xft is now loaded on demand.

3.9.2:
* Fixed some managed move bugs.
* Work around mawk bug that broke wmiirc.

3.9.1:
Expand Down
53 changes: 36 additions & 17 deletions PKGBUILD
@@ -1,34 +1,53 @@

pkgname=wmii-hg
pkgver=2740
pkgname=(wmii-hg pyxp-hg pygmi-hg)
pkgver=2746
pkgrel=1
pkgdesc="The latest hg pull of wmii, a lightweight, dynamic window manager for X11"
url="http://wmii.suckless.org"
license=(MIT)
arch=(i686 x86_64)
depends=(libx11 libxinerama libxrandr)
makedepends=(mercurial "libixp-hg>="$(sed -rn <mk/wmii.mk 's/.*IXP_NEEDAPI=([0-9]+).*/\1/p'))
optdepends=("plan9port: for use of the alternative plan9port wmiirc" \
"python: for use of the alternative Python wmiirc" \
"ruby-rumai: for use of the alternative Ruby wmiirc" \
"libxft: for anti-aliased font support")
provides=(wmii)
conflicts=(wmii)
makedepends=(mercurial python "libixp-hg>="$(sed -rn <mk/wmii.mk 's/.*IXP_NEEDAPI=([0-9]+).*/\1/p'))
options=(!strip)
source=()

FORCE_VER=$(hg log -r . --template {rev})

build()
{
_make() {
cd $startdir
flags=(PREFIX=/usr \
ETC=/etc \
DESTDIR="$pkgdir")
make PREFIX=/usr \
PYPREFIX=--prefix=/usr \
ETC=/etc \
DESTDIR="$pkgdir" \
"$@"
}

build() {
_make "${flags[@]}" || return 1
}

make "${flags[@]}" || return 1
make "${flags[@]}" install || return 1
package_wmii-hg() {
depends=(libx11 libxinerama libxrandr)
optdepends=("plan9port: for use of the alternative plan9port wmiirc" \
"pygmi: for use of the alternative Python wmiirc" \
"ruby-rumai: for use of the alternative Ruby wmiirc" \
"libxft: for anti-aliased font support")
provides=(wmii)
conflicts=(wmii)
_make install PYMODULES= || return 1

install -m644 -D ./debian/file/wmii.desktop "$pkgdir/etc/X11/sessions/wmii.desktop"
install -m644 -D ./LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

package_pyxp-hg() {
arch=(any)
depends=(python)
_make -C alternative_wmiircs/python pyclean pyxp.install
}

package_pygmi-hg() {
arch=(any)
depends=(pyxp-hg)
_make -C alternative_wmiircs/python pyclean pygmi.install
}

29 changes: 15 additions & 14 deletions alternative_wmiircs/plan9port/wmiirc
@@ -1,13 +1,15 @@
#!/bin/sh -f
p="$PATH"
which rc >/dev/null || PATH="$PLAN9:$p"
which rc >/dev/null || PATH="/usr/local/plan9/bin:$p"
which rc >/dev/null || PATH="/usr/local/9/bin:$p"
which rc >/dev/null || PATH="/opt/plan9/bin:$p"
which rc >/dev/null || PATH="/opt/9/bin:$p"
which rc >/dev/null || PATH="/usr/plan9/bin:$p"
which rc >/dev/null || PATH="/usr/9/bin:$p"
test $#* '=' 0 || exec rc $0
test $#* '=' 0 || {
p="$PATH"
which rc >/dev/null || PATH="$PLAN9:$p"
which rc >/dev/null || PATH="/usr/local/plan9/bin:$p"
which rc >/dev/null || PATH="/usr/local/9/bin:$p"
which rc >/dev/null || PATH="/opt/plan9/bin:$p"
which rc >/dev/null || PATH="/opt/9/bin:$p"
which rc >/dev/null || PATH="/usr/plan9/bin:$p"
which rc >/dev/null || PATH="/usr/9/bin:$p"
exec rc $0
}

cd
scriptname=$0
Expand All @@ -30,8 +32,8 @@ noticebar=/rbar/!notice
# Theme
wmiifont='drift,-*-fixed-*-*-*-*-9-*-*-*-*-*-*-*'
wmiifont='-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*'
wmiinormcol=`{echo '#000000 #c1c48b #81654f'}
wmiifocuscol=`{echo '#000000 #81654f #000000'}
wmiinormcol=('#000000' '#c1c48b' '#81654f')
wmiifocuscol=('#000000' '#81654f' '#000000')
wmiibackground='#333333'
wmiifloatbackground='#222222'
fn setbackground { xsetroot -solid $* }
Expand Down Expand Up @@ -191,9 +193,8 @@ fn key {
key=()
for(k) {
if(! ~ $k $_keys) {
ifs=() { wmiikeyhelp = `{awk 'BEGIN {
printf "%s %- 20s %s\n", ENVIRON["wmiikeyhelp"], ENVIRON["k"], ENVIRON["help"]
exit }'} }
ifs=() { wmiikeyhelp = `{
printf "%s %- 20s %s\n" $wmiikeyhelp $k $help}}
key = ($key Key-$k)}}
~ $#key 0}
Expand Down
6 changes: 3 additions & 3 deletions alternative_wmiircs/python/Makefile
Expand Up @@ -2,13 +2,13 @@ ROOT=../..
include $(ROOT)/mk/hdr.mk
include $(ROOT)/mk/wmii.mk

PYMODULES = pyxp pygmi

DOCS = README
EXECS = wmiirc
TEXT = wmiirc.py
DIRS = pygmi \
pyxp

DIR = $(GLOBALCONF)/python
DOCDIR = $(DOC)/alternative_wmiircs/python

include $(ROOT)/mk/dir.mk
include $(ROOT)/mk/python.mk
14 changes: 14 additions & 0 deletions alternative_wmiircs/python/pygmi.py
@@ -0,0 +1,14 @@
#!/usr/bin/env python

from distutils.core import setup

setup(name='pygmi',
version='0.2',
description='Python wmii interaction library',
author='Kris Maglione',
author_email='maglione.k@gmail.com',
url='http://wmii.suckless.org',
packages=['pygmi'],
license='MIT',
)

91 changes: 67 additions & 24 deletions alternative_wmiircs/python/pygmi/fs.py
Expand Up @@ -28,11 +28,27 @@ class Never(Toggle.__class__):
pass

def constrain(min, max, val):
if val < min:
return min
if val > max:
return max
return val
return min if val < min else max if val > max else val

class Map(collections.Mapping):
def __init__(self, cls, *args):
self.cls = cls
self.args = args
def __repr__(self):
return 'Map(%s%s)' % (self.cls.__name__, (', %s' % ', '.join(map(repr, self.args)) if self.args else ''))
def __getitem__(self, item):
ret = self.cls(*(self.args + (item,)))
if not ret.exists:
raise KeyError('no such %s %s' % (self.cls.__name__.lower(), repr(item)))
return ret
def __len__(self):
return len(iter(self))
def __keys__(self):
return [v for v in self.cls.all(*self.args)]
def __iter__(self):
return (v for v in self.cls.all(*self.args))
def iteritems(self):
return ((v, self.cls(*(self.args + (v,)))) for v in self.cls.all(*self.args))

class Ctl(object):
"""
Expand Down Expand Up @@ -65,7 +81,13 @@ def ctl(self, *args):
"""
Arguments are joined by ascii spaces and written to the ctl file.
"""
client.awrite(self.ctl_path, u' '.join(map(unicode, args)))
def next(file, exc=None, tb=None):
if file:
self.file = file
file.awrite(u' '.join(map(unicode, args)))
if self.file:
return next(file)
client.acreate(self.ctl_path, callback=next, mode=OWRITE)

def __getitem__(self, key):
for line in self.ctl_lines():
Expand Down Expand Up @@ -128,7 +150,7 @@ def ctl_lines(self):
@prop(doc="If #ctl_hasid is set, returns the id of this ctl file.")
def id(self):
if self._id is None and self.ctl_hasid:
return client.read(self.ctl_path).split('\n', 1)[0]
return self.name_read(client.read(self.ctl_path).split('\n', 1)[0])
return self._id

class Dir(Ctl):
Expand All @@ -140,6 +162,8 @@ class Dir(Ctl):
represented by this class reside. e.g., /client, /tag
"""
ctl_hasid = True
name_read = unicode
name_write = unicode

def __init__(self, id):
"""
Expand All @@ -154,7 +178,7 @@ def __init__(self, id):
if isinstance(id, Dir):
id = id.id
if id != 'sel':
self._id = id
self._id = self.name_read(id)

def __eq__(self, other):
return (self.__class__ == other.__class__ and
Expand Down Expand Up @@ -218,16 +242,22 @@ def ctl_path(self):

@prop(doc="The path to this directory")
def path(self):
return '%s/%s' % (self.base_path, self._id or 'sel')
return '%s/%s' % (self.base_path, self.name_write(self._id or 'sel'))
@prop(doc="True if the given object exists in the wmii filesystem")
def exists(self):
return bool(client.stat(self.path))

@classmethod
def all(cls):
"""
Returns all of the objects that exist for this type of directory.
"""
return (cls(s.name)
return (cls.name_read(s.name)
for s in client.readdir(cls.base_path)
if s.name != 'sel')
@classmethod
def map(cls, *args):
return Map(cls, *args)

def __repr__(self):
return '%s(%s)' % (self.__class__.__name__,
Expand All @@ -243,6 +273,15 @@ class Client(Dir):
'group': (lambda s: int(s, 16), str),
'pid': (int, None),
}
@staticmethod
def name_read(name):
if isinstance(name, int):
return name
try:
return int(name, 16)
except:
return unicode(name)
name_write = lambda self, name: name if isinstance(name, basestring) else '%#x' % name

allow = Dir.ctl_property('allow')
fullscreen = Dir.toggle_property('fullscreen')
Expand Down Expand Up @@ -531,7 +570,8 @@ def __init__(self, side, name, colors=None, label=None):
self.base_path = self.sides[side]
self.ctl_path = '%s/%s' % (self.base_path, self.name)
self.file = None
self.create(colors, label)
if colors or label:
self.create(colors, label)

def create(self, colors=None, label=None):
def fail(resp, exc, tb):
Expand All @@ -548,11 +588,18 @@ def remove(self):
self.file.aremove()
self.file = None

@property
def exists(self):
return bool(self.file and File.stat(self.file))

@classmethod
def all(cls, side):
return (Button(side, s.name)
return (s.name
for s in client.readdir(cls.sides[side])
if s.name != 'sel')
@classmethod
def map(cls, *args):
return Map(cls, *args)

class Rules(collections.MutableMapping, utf8):

Expand Down Expand Up @@ -586,8 +633,7 @@ def __delitem__(self, key):
def __len__(self):
return len(tuple(self.iteritems()))
def __iter__(self):
for k, v in self.iteritems():
yield k
return (k for k, v in self.iteritems())
def __list__(self):
return list(iter(self))
def __tuple__(self):
Expand All @@ -609,8 +655,7 @@ def __unicode__(self):
return u''.join(unicode(value) for (key, value) in self.iteritems()) or u'\n'

def iteritems(self):
for item in self._items:
yield item
return iter(self._items)
def items(self):
return list(self._items())

Expand Down Expand Up @@ -659,8 +704,7 @@ def __delitem__(self, key):
def __len__(self):
return len(self._items)
def __iter__(self):
for k in iter(self._items):
yield k
return iter(self._items)
def __list__(self):
return list(iter(self))
def __tuple__(self):
Expand All @@ -687,8 +731,7 @@ def __unicode__(self):
for (k, v) in self.iteritems()))

def iteritems(self):
for i in self._items:
yield i
return iter(self._items)
def items(self):
return list(self._items)

Expand All @@ -702,10 +745,10 @@ class wmii(Ctl):
'border': (int, str),
}

clients = property(lambda self: Client.all())
tags = property(lambda self: Tag.all())
lbuttons = property(lambda self: Button.all('left'))
rbuttons = property(lambda self: Button.all('right'))
clients = Client.map()
tags = Tag.map()
lbuttons = Button.map('left')
rbuttons = Button.map('right')

rules = Rules('/rules')

Expand Down
14 changes: 14 additions & 0 deletions alternative_wmiircs/python/pyxp.py
@@ -0,0 +1,14 @@
#!/usr/bin/env python

from distutils.core import setup

setup(name='pyxp',
version='0.2',
description='Python 9P client library',
author='Kris Maglione',
author_email='maglione.k@gmail.com',
url='http://wmii.suckless.org',
packages=['pyxp'],
license='MIT',
)

0 comments on commit 23899f6

Please sign in to comment.