I try to write script to check active windows and name of this active windows. But have some problem to be fix in the future.
- error for some qt windows such as Mathematica
- error when destroy windows immediately
#!/usr/bin/python
import subprocess
import time
import Xlib
import Xlib.display
import sys
old = "Nones"
while(1):
focus = Xlib.display.Display().get_input_focus()
cc = focus.focus
try:
while(cc.get_wm_class()==None):
try:
cc = cc.query_tree().parent
except:
print "error1"
cc = focus.focus
try:
if cc.get_wm_class()!=old:
print cc.get_wm_class(),cc.get_wm_name()
old = cc.get_wm_class()
except:
print "error "
continue
except:
print "error3"
continue
import subprocess
import time
import Xlib
import Xlib.display
import sys
old = "Nones"
while(1):
focus = Xlib.display.Display().get_input_focus()
cc = focus.focus
try:
while(cc.get_wm_class()==None):
try:
cc = cc.query_tree().parent
except:
print "error1"
cc = focus.focus
try:
if cc.get_wm_class()!=old:
print cc.get_wm_class(),cc.get_wm_name()
old = cc.get_wm_class()
except:
print "error "
continue
except:
print "error3"
continue

