Last active
November 10, 2017 22:24
-
-
Save scottgwald/3835544c1b5afb598536 to your computer and use it in GitHub Desktop.
wmctrl in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gevent | |
wmctrl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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