be more friendly to people who have no XDG variables set + bitter checking and such
authorDieter Plaetinck <dieter@plaetinck.be>
Mon, 8 Jun 2009 19:16:25 +0000 (21:16 +0200)
committerDieter Plaetinck <dieter@plaetinck.be>
Mon, 8 Jun 2009 19:16:25 +0000 (21:16 +0200)
examples/data/uzbl/scripts/cookies.py
examples/data/uzbl/scripts/cookies.sh
examples/data/uzbl/scripts/formfiller.pl
examples/data/uzbl/scripts/formfiller.sh
examples/data/uzbl/scripts/history.sh
examples/data/uzbl/scripts/insert_bookmark.sh
examples/data/uzbl/scripts/load_url_from_bookmarks.sh
examples/data/uzbl/scripts/load_url_from_history.sh
examples/data/uzbl/scripts/session.sh

index 3cc7eb0..8d7027b 100755 (executable)
@@ -61,7 +61,10 @@ class FakeResponse:
         return FakeHeaders(self.argv)
 
 if __name__ == '__main__':
-    jar = cookielib.MozillaCookieJar(os.environ['XDG_DATA_HOME']+'/uzbl/cookies.txt')
+       if os.environ['XDG_DATA_HOME']:
+               jar = cookielib.MozillaCookieJar(os.environ['XDG_DATA_HOME']+'/uzbl/cookies.txt')
+       else:
+               jar = cookielib.MozillaCookieJar(os.environ['HOME']+'.local/share/uzbl/cookies.txt')
     try:
         jar.load()
     except:
@@ -79,4 +82,4 @@ if __name__ == '__main__':
         res = FakeResponse(sys.argv)
         jar.extract_cookies(res,req)
         jar.save(ignore_discard=True) # save session cookies too
-        #jar.save() # save everything but session cookies
\ No newline at end of file
+        #jar.save() # save everything but session cookies
index 78139d6..56b9c79 100755 (executable)
 # http://kb.mozillazine.org/Cookies.txt
 # don't always append cookies, sometimes we need to overwrite
 
-cookie_config=$XDG_CONFIG_HOME/uzbl/cookies
+cookie_config=${XDG_CONFIG_HOME:-$HOME/.config}/uzbl/cookies
 [ -z "$cookie_config" ] && exit 1
-[ -d "$XDG_DATA_HOME/uzbl" ] || exit 1
-[ -d $XDG_DATA_HOME/uzbl/          ] && cookie_data=$XDG_DATA_HOME/uzbl/cookies.txt
+[ -d ${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/ ] && cookie_data=${XDG_DATA_HOME:-$home/.local/share}/uzbl/cookies.txt || exit 1
 
 
 notifier=
index c590836..9ac6959 100755 (executable)
@@ -3,7 +3,7 @@
 # a slightly more advanced form filler
 #
 # uses settings file like: $keydir/<domain>
-
+#TODO: fallback to $HOME/.local/share
 # user arg 1:
 # edit: force editing of the file (fetches if file is missing)
 # load: fill forms from file (fetches if file is missing)
index d54c626..bbb9d1a 100755 (executable)
@@ -12,8 +12,9 @@
 
 # something else (or empty): if file not available: new, otherwise load.
 
-keydir=$XDG_DATA_HOME/uzbl/forms
-[ -z "$keydir" ] && exit 1
+keydir=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/forms
+[ -d "`dirname $keydir`" ] || exit 1
+[ -d "$keydir" ] || mkdir "$keydir"
 
 #editor=gvim
 editor='urxvt -e vim'
index 69f4034..ccc6b40 100755 (executable)
@@ -1,3 +1,5 @@
 #!/bin/bash
 #TODO: strip 'http://' part
-echo "$8 $6 $7" >> $XDG_DATA_HOME/uzbl/history
+file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/history
+[ -d `dirname $file` ] || exit 1
+echo "$8 $6 $7" >> $file
index b3a7011..23c0d31 100755 (executable)
@@ -1,8 +1,7 @@
 #!/bin/bash
-# you probably want your bookmarks file in your $XDG_DATA_HOME ( eg $HOME/.local/share/uzbl/bookmarks)
 
-[ -d "$XDG_DATA_HOME/uzbl" ] || exit 1
-file=$XDG_DATA_HOME/uzbl/bookmarks
+[ -d "${XDG_DATA_HOME:-$HOME/.local/share}/uzbl" ] || exit 1
+file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks
 
 which zenity &>/dev/null || exit 2
 
index eb04873..78ee726 100755 (executable)
@@ -2,8 +2,8 @@
 
 #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes.
 
-file=$XDG_DATA_HOME/uzbl/bookmarks
-[ -z "$file" ] && exit 
+file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks
+[ -r "$file" ] || exit 
 COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
 if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'
 then
index 39ef302..57d634a 100755 (executable)
@@ -1,5 +1,6 @@
 #!/bin/bash
-history_file=$XDG_DATA_HOME/uzbl/history
+history_file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/history
+[ -r "$history_file" ] || exit 1
 
 # choose from all entries, sorted and uniqued
 # goto=`awk '{print $3}' $history_file | sort -u | dmenu -i`
index e2642c7..4dbae55 100755 (executable)
@@ -8,9 +8,10 @@
 # and doesn't need to be called manually at any point.
 # Add a line like 'bind quit = /path/to/session.sh endsession' to your config
 
+[ -d ${XDG_DATA_HOME:-$HOME/.local/share}/uzbl ] || exit 1
 scriptfile=$0                          # this script
-sessionfile=$XDG_DATA_HOME/uzbl/session # the file in which the "session" (i.e. urls) are stored
-configfile=$XDG_DATA_HOME/uzbl/config   # uzbl configuration file
+sessionfile=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/session # the file in which the "session" (i.e. urls) are stored
+configfile=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/config   # uzbl configuration file
 UZBL="uzbl -c $configfile"           # add custom flags and whatever here.
 
 fifodir=/tmp # remember to change this if you instructed uzbl to put its fifos elsewhere