diff options
Diffstat (limited to 'examples/data/scripts/insert_bookmark.sh')
-rwxr-xr-x | examples/data/scripts/insert_bookmark.sh | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/examples/data/scripts/insert_bookmark.sh b/examples/data/scripts/insert_bookmark.sh index d0ec84e..65fb5c5 100755 --- a/examples/data/scripts/insert_bookmark.sh +++ b/examples/data/scripts/insert_bookmark.sh @@ -1,18 +1,19 @@ #!/bin/sh -[ -d "${XDG_DATA_HOME:-$HOME/.local/share}/uzbl" ] || exit 1 -file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks +. $UZBL_UTIL_DIR/uzbl-dir.sh -which zenity &>/dev/null || exit 2 -url=$6 +[ -d "$UZBL_DATA_DIR" ] || exit 1 +[ -w "$UZBL_BOOKMARKS_FILE" ] || [ ! -a "$UZBL_BOOKMARKS_FILE" ] || exit 1 + +which zenity 2>&1 >/dev/null || exit 2 # replace tabs, they are pointless in titles and we want to use tabs as delimiter. -title=$(echo "$7" | sed 's/\t/ /') -entry=`zenity --entry --text="Add bookmark. add tags after the '\t', separated by spaces" --entry-text="$url $title\t"` +title=$(echo "$UZBL_TITLE" | sed 's/\t/ /') +entry=$(zenity --entry --text="Add bookmark. add tags after the '\t', separated by spaces" --entry-text="$UZBL_URL $title\t") exitstatus=$? if [ $exitstatus -ne 0 ]; then exit $exitstatus; fi -url=`echo $entry | awk '{print $1}'` +url=$(echo $entry | awk '{print $1}') # TODO: check if already exists, if so, and tags are different: ask if you want to replace tags echo "$entry" >/dev/null #for some reason we need this.. don't ask me why -echo -e "$entry" >> $file +printf "$entry\n" >> $UZBL_BOOKMARKS_FILE true |