From 1b19db603c37080f3ca4141d4a69c4ca4a075409 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 26 Feb 2014 01:03:26 +0100 Subject: place a black panel either on the top or the bottom MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/__main__.py | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/__main__.py b/src/__main__.py index ad195f4..36ee486 100755 --- a/src/__main__.py +++ b/src/__main__.py @@ -1,12 +1,20 @@ #!/usr/bin/env python3 -import time -import Xlib.display, Xlib.Xatom +import time, sys +import Xlib.display, Xlib.Xatom, Xlib.ext.randr, Xlib.X + +WIDTH, HEIGHT, LEFT, TOP, Y = 1600, 12, 1600, 24, 1200 - 24 - 12 display = Xlib.display.Display() screen = display.screen() -window = screen.root.create_window(0, 0, 100, 100, 0, screen.root_depth) +window = screen.root.create_window(LEFT, Y, WIDTH, HEIGHT, 0, screen.root_depth, + Xlib.X.InputOutput, Xlib.X.CopyFromParent, + event_mask = ( + Xlib.X.StructureNotifyMask | + Xlib.X.ButtonReleaseMask + ), + colormap = Xlib.X.CopyFromParent) window.set_wm_name('xpybar') window.set_wm_icon_name('xpybar') @@ -14,21 +22,34 @@ window.set_wm_class('bar', 'xpybar') _CARD = display.intern_atom("CARDINAL") _PSTRUT = display.intern_atom("_NET_WM_STRUT_PARTIAL") -window.change_property(_PSTRUT, _CARD, 32, [0, 60, 0, 0, 0, 0, 24, 767, 0, 0, 0, 0]) +window.change_property(_PSTRUT, _CARD, 32, topx(LEFT, TOP, WIDTH, HEIGHT)) + +top = lambda x, y, width, height : [0, 0, y + height, 0, 0, 0, 0, 0, x, x + width, 0, 0] +bottom = lambda x, y, width, height : [0, 0, 0, y + height, 0, 0, 0, 0, 0, 0, x, x + width] _ATOM = display.intern_atom("ATOM") _TYPE = display.intern_atom("_NET_WM_WINDOW_TYPE") _DOCK = display.intern_atom("_NET_WM_WINDOW_TYPE_DOCK") window.change_property(_TYPE, _ATOM, 32, [_DOCK]) +gc = window.create_gc() window.map() display.flush() -time.sleep(1) +e = None +while True: + try: + e = display.next_event() + if e.type == Xlib.X.DestroyNotify: + break + except KeyboardInterrupt: + break + gc.change(foreground = screen.black_pixel) + window.fill_rectangle(gc, 0, 0, 1600, 12) + display.flush() window.unmap() display.flush() display.close() - -- cgit v1.2.3-70-g09d2