-#!/usr/bin/python
+#!/usr/bin/env python
# Uzbl tabbing wrapper using a fifo socket interface
# Copyright (c) 2009, Tom Adams <tom@holizz.com>
# Tom Adams <tom@holizz.com>
# Wrote the original uzbl_tabbed.py as a proof of concept.
#
-# Chris van Dijk (quigybo) <cn.vandijk@hotmail.com>
+# Chris van Dijk (quigybo) <cn.vandijk@hotmail.com>
# Made signifigant headway on the old uzbl_tabbing.py script on the
# uzbl wiki <http://www.uzbl.org/wiki/uzbl_tabbed>
#
# Fix for session restoration code.
+# Dependencies:
+# pygtk - python bindings for gtk.
+# pango - python bindings needed for text rendering & layout in gtk widgets.
+# pygobject - GLib's GObject bindings for python.
+#
+# Optional dependencies:
+# simplejson - save uzbl_tabbed.py sessions & presets in json.
+#
+# Note: I haven't included version numbers with this dependency list because
+# I've only ever tested uzbl_tabbed.py on the latest stable versions of these
+# packages in Gentoo's portage. Package names may vary on different systems.
+
+
# Configuration:
# Because this version of uzbl_tabbed is able to inherit options from your main
# uzbl configuration file you may wish to configure uzbl tabbed from there.
#
# Session options:
# save_session = 1
-# json_session = 1
+# json_session = 0
# session_file = $HOME/.local/share/uzbl/session
#
# Inherited uzbl options:
# Session options
'save_session': True, # Save session in file when quit
- 'json_session': True, # Use json to save session.
+ 'json_session': False, # Use json to save session.
'saved_sessions_dir': os.path.join(data_dir, 'sessions/'),
'session_file': os.path.join(data_dir, 'session'),
error("Warning: The non-json session file %r looks invalid."\
% session_file)
return None
-
- for line in lines:
- if line.startswith("curtab"):
- curtab = int(line.split()[-1])
+
+ try:
+ for line in lines:
+ if line.startswith("curtab"):
+ curtab = int(line.split()[-1])
- else:
- uri, title = line.split("\t",1)
- tabs += [(strip(uri), strip(title)),]
+ else:
+ uri, title = line.split("\t",1)
+ tabs += [(strip(uri), strip(title)),]
+
+ except:
+ error("Warning: failed to load session file %r" % session_file)
+ return None
session = {'curtab': curtab, 'tabs': tabs}