User Tools

Site Tools

The Python Cookie Daemon

This page is obsolete, uzbl no longer uses cookie daemons.

This application is a re-write of the original script found in uzbl's master branch. This script provides more functionality than the original by adding command line options to specify different cookie jar locations, socket locations, verbose output, etc. Check the usage section below for the full list of options.



Getting uzbl to talk to the daemon

In order to get uzbl to talk to the running cookie daemon you add the following to your uzbl config:

set cookie_handler = talk_to_socket $HOME/.cache/uzbl/cookie_daemon_socket

or if you prefer using XDG variables:

set cookie_handler = talk_to_socket $XDG_CACHE_HOME/uzbl/cookie_daemon_socket

Remember that talk_to_socket doesn't have the ability to launch the cookie daemon that creates the cookie socket yet so you need to start it manually before running uzbl. If you don't like this option then follow the instructions in the next section to make a uzbl wrapper that launches the when starting uzbl.

Command line options

The following is the output of ' -h' which lists the command line options available in the cookie daemon (at the time of writing).

Usage: [options]

  -h, --help            show this help message and exit
  -n, --no-daemon       don't daemonise the process.
  -v, --verbose         print verbose output.
  -t SECONDS, --daemon-timeout=SECONDS
                        shutdown the daemon after x seconds inactivity.
                        WARNING: Do not use this when launching the cookie
                        daemon manually.
  -s SOCKET, --cookie-socket=SOCKET
                        manually specify the socket location.
  -j FILE, --cookie-jar=FILE
                        manually specify the cookie jar location.
  -m, --memory          store cookies in memory only - do not write to disk
  -u, --use-whitelist   use cookie whitelist policy
  -w FILE, --cookie-whitelist=FILE
                        manually specify whitelist location

If you don't want to be manually launching the cookie_daemon every time you log on in order to use cookies in uzbl then I've found a very easy solution to that problem. I've made a hidden .bin directory in my home folder that contains a file named 'uzbl' which launches the cookie_daemon before directly launching '/usr/bin/uzbl'. An alternative would be to place the script in /usr/local/bin/uzbl.

The ~/.bin/uzbl script:

# Launch cookie daemon.
$XDG_DATA_HOME/uzbl/scripts/ start &
# Launch uzbl directly.
/usr/bin/uzbl $@

Now make the script executable:

chmod +x ~/.bin/uzbl

And remember to add the directory ”~/.bin” to your $PATH by adding the following to your ~/.bashrc

export PATH="~/.bin:$PATH"

You will need to run the following or log-out and log back in for the new path in your $PATH variable to register.

source ~/.bashrc

Running multiple cookie daemons is very easy as long as you specify unique cookie socket locations and cookie jars to each daemon.

The best way to show this in action is to modify the launcher above to always use its own cookie socket and cookie jar:

# My custom cookie socket and cookie jar locations
# Launch the daemon.
$XDG_DATA_HOME/uzbl/scripts/ -v --cookie-socket=$COOKIE_SOCKET --cookie-jar=$COOKIE_JAR start &
# Generate the new config
CONFIG="`cat $XDG_CONFIG_HOME/uzbl/config`\nset cookie_handler = talk_to_socket $COOKIE_SOCKET\n"
# Launch uzbl directly and send it the new config via stdin
echo -e "$CONFIG" | /usr/bin/uzbl $@ -c - · Last modified: 2016/08/31 14:10 (external edit)