#!/usr/bin/env python2 # Copyright 2008-2010 Calculate Ltd. http://www.calculate-linux.org # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import pygtk pygtk.require('2.0') import gtk import os import sys import re import subprocess def select_color(): try: if filter(re.compile(r"(cld|cldx|cldg|cmc|cls)-themes-12").search, os.listdir('/var/db/pkg/media-gfx')): return "#73a363" except: pass return '#30648b' if __name__ == "__main__": if gtk.gdk.get_display(): window = gtk.Window(gtk.WINDOW_TOPLEVEL) # Here we connect the "destroy" event to a signal handler window.connect("destroy", lambda w: gtk.main_quit()) pipe = subprocess.Popen(["xdpyinfo"], stdout=subprocess.PIPE, env=os.environ) reRes = re.compile("dimensions:\s+(\d+)x(\d+)\s+pixels") cx, cy = 1024, 768 if pipe.wait() == 0: for line in pipe.stdout: searchRes = reRes.search(line) if searchRes: cx, cy = int(searchRes.group(1)), int(searchRes.group(2)) break pipe.stdout.close() window.set_size_request(cx,cy) window.maximize() window.set_border_width(0) window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.rgb_get_colormap().alloc_color(select_color())) window.show() pid = os.fork() if not pid: gtk.main() sys.exit(0)