From 7a16b51b8d7abca0d05d1d73ff4cb19b9cce2ca2 Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Thu, 30 Nov 2023 03:21:48 +0100 Subject: [PATCH] Added new script Allows for the addition of bookmarks outside of Qutebrowser --- src/bin/add-bookmark | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 src/bin/add-bookmark diff --git a/src/bin/add-bookmark b/src/bin/add-bookmark new file mode 100755 index 0000000..96eb9d2 --- /dev/null +++ b/src/bin/add-bookmark @@ -0,0 +1,30 @@ +#!/bin/sh + +bookmarks="${BOOKMARKS:-"$HOME/.config/qutebrowser/bookmarks/urls"}" + +usage(){ + printf "Usage: %s -c|h\n" "$(basename $0)" + printf "OR\n" + printf "Usage: %s \n" "$(basename $0)" +} + + +addUrl(){ + url="$1" + + if [ "$(grep "$url" "$bookmarks")" ] + then printf "Bookmark of url '%s' already exists\n" "$url" && exit 1 + else printf "%s %s\n" \ + "$url" \ + "$(curl -s "$url" | grep '\(.*\)<\/title>/\1/')" \ + >> $bookmarks + fi +} + +while getopts chu: flag; do + case $flag in + c)addUrl $(xclip -o);; + u)addUrl $OPTARG;; + h)usage;; + esac +done