From 359851586606aa984bfa4ce7759d1315c278d6fa Mon Sep 17 00:00:00 2001 From: portnov Date: Wed, 5 Nov 2008 23:59:14 +0500 Subject: [PATCH] Some adaptations. Now it runs on Windows! (not works, just run ;)) --- qwerty.py | 38 +++++++++++++++++++++++++------------- 1 files changed, 25 insertions(+), 13 deletions(-) diff --git a/qwerty.py b/qwerty.py index 38ddbc5..89685d3 100755 --- a/qwerty.py +++ b/qwerty.py @@ -8,8 +8,13 @@ from getopt import getopt import time from copy import copy -from Xlib import X,display,Xatom -import Xlib.protocol.event +try: + from Xlib import X,display,Xatom + import Xlib.protocol.event + XLIB=True +except ImportError: + XLIB=False + import gtk from gtk import gdk import cairo @@ -50,7 +55,10 @@ BUTTON_BORDER_ACTIVE = (0,0,0) BUTTON_FILL = (0.9, 0.9, 0.9) BUTTON_FILL_RUNNING = (0.7, 0.7, 0.7) -config_file = os.path.expanduser('~/.config/qwerty.conf') +if os.name=='posix': + config_file = os.path.expanduser('~/.config/qwerty.conf') +else: + config_file = os.path.expanduser('~/qwerty.conf') sections = {} speckeys = {} @@ -677,11 +685,12 @@ class GUI(object): self.window.show_all() self.taskbar.hide() - try: - self.collect_windows() - except: - self.clients_list = [] - print 'Could not get list of open windows!' + if XLIB: + try: + self.collect_windows() + except: + self.clients_list = [] + print 'Could not get list of open windows!' def calc_sizes(self): global LABEL_FONT_SIZE @@ -769,6 +778,8 @@ class GUI(object): self.exit() def switch_taskbar(self): + if not XLIB: + return self.taskbar_shown = not self.taskbar_shown if self.taskbar_shown: self.keyboard.hide() @@ -937,11 +948,12 @@ class GUI(object): if not mods: mods = [] - try: - self.collect_windows() - except: - self.clients_list = [] - print 'Could not get list of open windows!' + if XLIB: + try: + self.collect_windows() + except: + self.clients_list = [] + print 'Could not get list of open windows!' id = (int(k)-1)%10 try: -- 1.7.2.3