qutebrowser_configs/configs/atexit-cleanup.py

34 lines
1.1 KiB
Python

# -*- mode: python; python-indent-offset: 4; tab-width: 0; encoding: utf-8-unix -*-
# This should be execed in config.py
"""This is a simple way of deleting cookies and history at exit.
"""
import sys
import os
import atexit
@atexit.register
def atexit_cleanup():
lDels = [os.path.join(config.datadir, 'cookies'),
os.path.join(config.datadir, 'history.sqlite'),
]
bidir = os.path.join(config.datadir, 'webengine')
lDels += [os.path.join(bidir, 'Cookies'),
os.path.join(bidir, 'Cookies-journal'),
os.path.join(bidir, 'Favicons'),
os.path.join(bidir, 'Favicons-journal'),
os.path.join(bidir, 'History'),
os.path.join(bidir, 'History-journal'),
os.path.join(bidir, 'Network Persistent State'),
os.path.join(bidir, 'TransportSecurity'),
os.path.join(bidir, 'Visited Links'),
]
i = 0
for elt in lDels:
if os.path.exists(elt):
os.unlink(elt)
i += 1
sys.stderr.write(f"Cleaned up {i} files\n")