From 0e09bed542904fbdf269a523cae156a3964870d5 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Fri, 4 Dec 2020 14:57:21 +0100 Subject: [PATCH] Add save_buffers script for Qutebrowser Copy and adapted from https://gist.github.com/aeghn/0b5db63c3d4290fa487aa48ab7f1264c#file-save_buffers-py --- save_qutebrowser_buffers.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 save_qutebrowser_buffers.py diff --git a/save_qutebrowser_buffers.py b/save_qutebrowser_buffers.py new file mode 100644 index 0000000..ae9af14 --- /dev/null +++ b/save_qutebrowser_buffers.py @@ -0,0 +1,28 @@ +## Script to load in Qutebrowser configuration file +## config.source('~/bin/save_qutebrowser_buffers.py + +## Add "save-window-and-buffers" function in Qutebrowser +## in order to save buffers to a temp file + +## Thanks to aeghn ! +## https://gist.github.com/aeghn/0b5db63c3d4290fa487aa48ab7f1264c#file-save_buffers-py + +from qutebrowser.utils import objreg +from qutebrowser.api import interceptor, cmdutils + +@cmdutils.register() +def save_window_and_buffers(): + """ + Save buffer list + like: + window_id/buffer_id buffer_title + """ + qbuffers = open('/tmp/qutebrowser_buffers_zsbd', "w") + print_buffers = '' + for windows_id in objreg.window_registry: + tabbed_browser = objreg.get('tabbed-browser', scope='window', + window=windows_id) + for buffer_id in range(tabbed_browser.widget.count()): + print_buffers = print_buffers+str(windows_id)+'/'+str(buffer_id+1)+' '+str(tabbed_browser.widget.widget(buffer_id).title())+' '+str(tabbed_browser.widget.widget(buffer_id).url())+'\n' + qbuffers.write(str(print_buffers)) + qbuffers.close()