summarylogtreecommitdiffstats
path: root/chrome-shutdown-hook.py
blob: 58cf6bc7be97f14de67acfc23c7da7123d810ebc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python2

# Author: Michael Goehler
# Description: Gently shutdown Chrome on logout from Gnome Shell.
#
# Based on a script by Seamus Phelan
# http://unix.stackexchange.com/questions/49333/

import sys
import subprocess
import datetime
import gnome
import gnome.ui
import gtk

class Namespace: pass
ns = Namespace()
ns.dialog = None

def main():
    prog = gnome.init("chrome_clean_shutdown", "1.0", gnome.libgnome_module_info_get(), sys.argv, [])
    client = gnome.ui.master_client()
    client.connect("save-yourself", chrome_clean_shutdown)

def chrome_clean_shutdown(*args):
    subprocess.call("/usr/bin/pkill -15 -P 1 chrome", shell=True)
    return True

main()
gtk.main()

# vim: set ts=4 sw=4 et: