Skip to content

Instantly share code, notes, and snippets.

@sxslex
Created October 6, 2016 21:26
Show Gist options
  • Save sxslex/4d4dfab28d62f4478eb5c7a0757e7237 to your computer and use it in GitHub Desktop.
Save sxslex/4d4dfab28d62f4478eb5c7a0757e7237 to your computer and use it in GitHub Desktop.
kill_to_window_name.py
# -*- coding: utf-8 -*-
"""Fecha todas as janelas pelo nome."""
from gi.repository import Gtk, Wnck
import os
Gtk.init([])
screen = Wnck.Screen.get_default()
screen.force_update()
nome = os.sys.argv[1]
windows = [
w for w in screen.get_windows()
if w.get_name() == nome
]
print(nome + ': ' + str(len(windows)))
for window in windows:
os.system(
'kill -9 %s' % str(window.get_pid())
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment