Advertisement
Guest User

launch_chrome.py

a guest
Jun 21st, 2011
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import subprocess
  4. import wnck
  5. import gtk
  6. import time
  7.  
  8.  
  9. screen = wnck.screen_get_default()
  10. while gtk.events_pending():
  11.     gtk.main_iteration()
  12.  
  13. window_list = screen.get_windows_stacked()
  14.  
  15. last_active = None
  16. for window in window_list:
  17.     if window.get_application().get_name() == "Google Chrome":
  18.         last_active = window
  19.  
  20. if last_active:
  21.  
  22.     timestamp = int(time.time())
  23.     last_active.activate(timestamp)
  24.  
  25. else:
  26.    
  27.     subprocess.Popen("google-chrome")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement