#!/usr/bin/python
# Uzbl tabbing wrapper using a fifo socket interface
-# Copywrite (c) 2009, Tom Adams <tom@holizz.com>
-# Copywrite (c) 2009, quigybo <?>
-# Copywrite (c) 2009, Mason Larobina <mason.larobina@gmail.com>
+# Copyright (c) 2009, Tom Adams <tom@holizz.com>
+# Copyright (c) 2009, quigybo <?>
+# Copyright (c) 2009, Mason Larobina <mason.larobina@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# and inherit configuration options from the user's uzbl config.
#
# Contributor(s):
-# (None yet)
+# mxey <mxey@ghosthacking.net>
+# uzbl_config path now honors XDG_CONFIG_HOME if it exists.
# Issues:
# === Default Configuration ====================================================
# Location of your uzbl configuration file.
-uzbl_config = os.path.join(os.environ['HOME'],'.config/uzbl/config')
+if 'XDG_CONFIG_HOME' in os.environ.keys() and os.environ['XDG_CONFIG_HOME']:
+ uzbl_config = os.path.join(os.environ['XDG_CONFIG_HOME'], 'uzbl/config')
+else:
+ uzbl_config = os.path.join(os.environ['HOME'],'.config/uzbl/config')
# All of these settings can be inherited from your uzbl config file.
config = {'show_tabs': True,
self._outgoing = []
self._configured = False
+ # Probe commands
+ self._probeurl = 'sh \'echo "url %s $6" > "%s"\'' % (self.pid,\
+ self.parent.fifo_socket)
+
+ # As soon as the variable expansion bug is fixed in uzbl
+ # I can start using this command to fetch the winow title
+ self._probetitle = 'sh \'echo "title %s @window_title" > "%s"\'' \
+ % (self.pid, self.parent.fifo_socket)
+
# When notebook tab deleted the kill switch is raised.
self._kill = False
-
+
# Queue binds for uzbl child
self.parent.config_uzbl(self)
# Ugly way of getting the socket path. Screwed if fifo is in any
# other part of the fifo socket path.
-
socket = 'socket'.join(self.fifo.split('fifo'))
-
- # I feel so dirty
+ # Hackish & wasteful way of getting the window title.
subcmd = 'print title %s @<document.title>@' % self.pid
cmd = 'uzblctrl -s "%s" -c "%s" > "%s" &' % (socket, subcmd, \
self.parent.fifo_socket)
-
subprocess.Popen([cmd], shell=True)
+ self.send(self._probeurl)
+
+ # Wont work yet.
+ #self.send(self._probetitle)
self._lastprobe = time.time()
-
-
+
+
def send(self, msg):
'''Child fifo write function.'''
if len(cmd) > 2:
uzbl = self.get_uzbl_by_pid(int(cmd[1]))
if uzbl:
- setattr(uzbl, cmd[0], ' '.join(cmd[2:]))
+ old = getattr(uzbl, cmd[0])
+ new = ' '.join(cmd[2:])
+ setattr(uzbl, cmd[0], new)
+ if old != new:
+ self.update_tablist()
else:
error("Cannot find uzbl instance with pid %r" % int(cmd[1]))
else: