Skip to content

Instantly share code, notes, and snippets.

@scottgwald
Last active November 10, 2017 22:24
Show Gist options
  • Save scottgwald/3835544c1b5afb598536 to your computer and use it in GitHub Desktop.
Save scottgwald/3835544c1b5afb598536 to your computer and use it in GitHub Desktop.
wmctrl in python
import gevent.monkey
gevent.monkey.patch_all()
import subprocess
from wmctrl import Window
import platform
def os_detector():
uname = platform.uname()
if uname[0] == 'Darwin' and uname[-2] == 'x86_64':
return 'osx'
elif uname[0] == 'Linux' and uname[-2] == 'x86_64':
return 'linux64'
return 'other'
THIS_OS = os_detector()
def f(x):
return x**2
print f(5)
# The bash way
p = subprocess.check_output(['google-chrome', '--new-window'])
print "Did it"
#gevent.wait([p])
q = subprocess.Popen(['wmctrl','-a','New Tab - Google Chrome'])
print "Did the other thing"
# the python way
p = subprocess.check_output(['google-chrome', '--new-window'])
print "List of windows"
print Window.list()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment