Skip to content

Instantly share code, notes, and snippets.

@david-wm-sanders
Last active January 26, 2016 15:58
Show Gist options
  • Save david-wm-sanders/451284ea6a941761ed73 to your computer and use it in GitHub Desktop.
Save david-wm-sanders/451284ea6a941761ed73 to your computer and use it in GitHub Desktop.
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