Last active
January 26, 2016 15:58
-
-
Save david-wm-sanders/451284ea6a941761ed73 to your computer and use it in GitHub Desktop.
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 subprocess | |
def active_window_name(): | |
window_id_cmd = ["/usr/bin/xprop", "-root", "_NET_ACTIVE_WINDOW"] | |
window_id = subprocess.check_output(window_id_cmd).decode("utf-8").strip().split()[-1] | |
window_name_cmd = ["/usr/bin/xprop", "-id", window_id, "_NET_WM_NAME"] | |
window_name = subprocess.check_output(window_name_cmd).decode("utf-8").strip()[29:-1] | |
return window_name | |
print(active_window_name()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment